LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 11-27-2016, 02:01 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
USB mouse, keyboard assigning to process not desktop, how to?


Hi group,
I need to assign my USB devices ( mouse and keyboard ) to a special program.
Currently, when these devices are plugged in they are assigned to the desktop. I wish to mimic the actions of Qemu. My program will capture
the actions of the devices and preform special programmed actions.

I hope I have made myself clear? Any suggestion?

Thanks for your time,
 
Old 11-27-2016, 11:09 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I don't understand how what you want to do is different than a simple window capture.
 
Old 11-29-2016, 02:26 PM   #3
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by AwesomeMachine View Post
I don't understand how what you want to do is different than a simple window capture.
I do not understand what you mean by "simple window capture'?

Let us use a laptop as an example, you have the mouse pad and keyboard as input to the desktop. Now you attach a USB mouse or keyboard. Normally these new devices are added to the desktop as input devices. I want to be able to use these new devices as input to a program, the program will read the input of the USB HID devices and redirect them to another process.

I believe this will require 2 steps:
  1. Remove the USB devices from Xorg.
  2. Attach the HID devices to a program.

Does that make thing clearer?

Last edited by MrUmunhum; 12-03-2016 at 06:32 PM.
 
Old 12-13-2016, 02:33 PM   #4
Fat_Elvis
Member
 
Registered: Oct 2016
Distribution: FreeDOS 1.2
Posts: 309

Rep: Reputation: 92
Quote:
Originally Posted by MrUmunhum View Post
I do not understand what you mean by "simple window capture'?

Let us use a laptop as an example, you have the mouse pad and keyboard as input to the desktop. Now you attach a USB mouse or keyboard. Normally these new devices are added to the desktop as input devices. I want to be able to use these new devices as input to a program, the program will read the input of the USB HID devices and redirect them to another process.

I believe this will require 2 steps:
  1. Remove the USB devices from Xorg.
  2. Attach the HID devices to a program.

Does that make thing clearer?
You will need to go through X.org (if that's the display server on your distro) for that. The focuses of both the keyboard and mouse should be on the new program as soon as you click on its window.

Can you elaborate?

If you need lower level access to input devices, you will need to go into the source code and program it in yourself. I'm not certain it's possible to bypass X even then. Maybe read directly from /dev/hid-foo? At any rate, probably out of the scope of this section of the forums.

Last edited by Fat_Elvis; 12-13-2016 at 02:35 PM.
 
Old 12-20-2016, 09:11 PM   #5
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by MrUmunhum View Post

I believe this will require 2 steps:
  1. Remove the USB devices from Xorg.
  2. Attach the HID devices to a program.
I found this which solves part 1.
Code:
root:~; xinput 
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              	id=12	[slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                   	id=15	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=8	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=9	[slave  keyboard (3)]
    ↳ HD WebCam                               	id=10	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]
    ↳ Acer WMI hotkeys                        	id=13	[slave  keyboard (3)]
    ↳ Logitech USB Receiver                   	id=14	[slave  keyboard (3)]
    ↳ Logitech USB Receiver                   	id=16	[slave  keyboard (3)]
root:~; xinput --set-prop 15  "Device Enabled" O
will disable the USB mouse from Xorg.

As for part 2, I used evtest to verify I can still read from the USB mouse.
Also found this page with source:
http://cboard.cprogramming.com/linux...ted-mouse.html
Thanks for your time.

Last edited by MrUmunhum; 12-20-2016 at 10:30 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gdm3 fails to start if usb keyboard or usb mouse are moved to different ports sr_25 Debian 2 08-27-2011 05:07 PM
Loss of desktop control (mouse and keyboard) wadesmart Ubuntu 15 01-23-2011 12:15 PM
How to send keyboard/mouse events to a process? shamju Linux - Software 0 12-14-2006 04:27 AM
Assigning keyboard shortcuts to keyboard keys the who Linux - Hardware 3 02-20-2004 09:36 PM
USB mouse, keyboard, hid, console mouse problems jqcaducifer Linux - General 1 08-05-2003 09:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration