Tuesday 15 July 2014

c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -



c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -

i know there has been few topics similar one, don't inquire same question , answers not need. seek explain briefly situation.

i have 2 keyboards, 1 standard usb keyboard (hid), other gpio keyboard. there keys commonly reported both keyboards need take different actions in qt application depending on keyboard key pressed.

at moment both keyboards work fine @ same time, can't find way identify keyboard comes pressed key.

is possible? i'm, using qt 4.8.5 , can recompile in case needed accomplish need.

any help, hint, tip highly appreciated.

thank help,

william

qt not have feature observe keyboard pressed. should utilize linux event interface distinguish between 2 inputs. when input available 1 of hardwares, can access reading character devices under /dev/input/ directory. instance have file /dev/input/by-id/usb-0b38_0010-event-kbd read see input specific keyboard.

you can read specific files 2 keyboards in 2 separate threads , each time read new info 1 of them, send signal main thread notify input of keyboards :

in first thread :

qfile file("/dev/input/by-id/fileforkeyboard1"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard1_pressed(); } }

in sec thread :

qfile file("/dev/input/by-id/fileforkeyboard2"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard2_pressed(); } }

note should have root access read these files.

c++ linux qt keyboard keystrokes

No comments:

Post a Comment