From: Brad H. <bh...@bi...> - 2002-10-08 03:13:53
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to finish off my documentation, and it's down to EVIOC[G,S]KEYCODE. The problem is that I don't think I understand what the arguments are. EVIOCGKEYCODE takes a int[2], and the first int looks like it should be passed in (ie I set int[0] to some value, then call ioctl(fd, EVIOCGKEYCODE, int), and then read back the other value in int[1]). I guess that the first argument is a scancode, and the second is a keycode. However when I pass in what I think is a reasonable value (as given by showkeys -s), I'm getting -EINVAL. Example: showkey -s gives me 0x39 for a space bar held down. I assumed if I codes[0] = 0x39; if(ioctl(fd, EVIOCGKEYCODE, codes)) perror("evdev ioctl"); printf("[0]= %d, [1] = %d\n", codes[0], codes[1]); Then I would get back codes[1] == KEY_SPACE. However I get evdev ioctl: Invalid argument [0]= 57, [1] = 1073784704 Anyone familiar with this? Or can provide a hint? I guess EVIOCSKEYCODE just assignes the int[1] keycode to the int[0] scancode. I can't make that work until I understand the scancodes business more, I think. Brad - -- http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9oktrW6pHgIdAuOMRAlfVAKCQvVThsCrOlkxIutLH/osW8hOEJgCdFiTJ 5sdLuX+KSl5K9G6P4cq/t4w= =LfXd -----END PGP SIGNATURE----- |
From: Vojtech P. <vo...@su...> - 2002-10-08 08:36:16
|
On Tue, Oct 08, 2002 at 01:05:15PM +1000, Brad Hards wrote: > I'm trying to finish off my documentation, and it's down to EVIOC[G,S]KEYCODE. > > The problem is that I don't think I understand what the arguments are. > > EVIOCGKEYCODE takes a int[2], and the first int looks like it should be passed > in (ie I set int[0] to some value, then call ioctl(fd, EVIOCGKEYCODE, int), > and then read back the other value in int[1]). > > I guess that the first argument is a scancode, and the second is a keycode. > > However when I pass in what I think is a reasonable value (as given by > showkeys -s), I'm getting -EINVAL. > > Example: showkey -s gives me 0x39 for a space bar held down. I assumed if I > > codes[0] = 0x39; > if(ioctl(fd, EVIOCGKEYCODE, codes)) > perror("evdev ioctl"); > printf("[0]= %d, [1] = %d\n", codes[0], codes[1]); > > Then I would get back codes[1] == KEY_SPACE. > > However I get > evdev ioctl: Invalid argument > [0]= 57, [1] = 1073784704 > > Anyone familiar with this? Or can provide a hint? Are you by any chance trying to do this on a USB keyboard? Bad luck, USB keyboards don't have scancode->keycode tables. (at least not yet) Try a normal PS/2 keyboard (or a Sun keyboard, or whatever). > I guess EVIOCSKEYCODE just assignes the int[1] keycode to the int[0] scancode. > I can't make that work until I understand the scancodes business more, I > think. Yep. -- Vojtech Pavlik SuSE Labs |
From: Brad H. <bh...@bi...> - 2002-10-08 08:46:04
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 8 Oct 2002 18:36, Vojtech Pavlik wrote: > Are you by any chance trying to do this on a USB keyboard? Bad luck, USB > keyboards don't have scancode->keycode tables. (at least not yet) Of course I'm trying it on a USB keyboard! Grrr. Thought I was reading the code all wrong.... > Try a normal PS/2 keyboard (or a Sun keyboard, or whatever). The keyboard has two cables. I'll give it a whirl. > > I guess EVIOCSKEYCODE just assignes the int[1] keycode to the int[0] > > scancode. I can't make that work until I understand the scancodes > > business more, I think. > > Yep. Brad - -- http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9opl/W6pHgIdAuOMRApetAJ4gU6z3Qgb33noftC/VsISGD/x8DACgnUuj y4vYJkNUw/ltr/TWz276w3E= =xhVW -----END PGP SIGNATURE----- |
From: Vojtech P. <vo...@su...> - 2002-10-08 08:55:38
|
On Tue, Oct 08, 2002 at 06:38:23PM +1000, Brad Hards wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tue, 8 Oct 2002 18:36, Vojtech Pavlik wrote: > > Are you by any chance trying to do this on a USB keyboard? Bad luck, USB > > keyboards don't have scancode->keycode tables. (at least not yet) > Of course I'm trying it on a USB keyboard! Grrr. Thought I was reading the > code all wrong.... Because the USB keyboard tells us which keys it has, we don't need a scancode->keycode table. (We have something like that in the HID driver, because the HID codes aren't the same as Linux keycodes, but the table is fixed.) For PS/2 you unfortunately cannot have a fixed table, and thus EVIOCSKEYCODE is needed. Btw, the classic KD* scancode loading ioctls should now be supported as well. -- Vojtech Pavlik SuSE Labs |
From: Brad H. <bh...@bi...> - 2002-10-08 09:12:10
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 8 Oct 2002 18:54, Vojtech Pavlik wrote: > Because the USB keyboard tells us which keys it has, we don't need a > scancode->keycode table. (We have something like that in the HID driver, > because the HID codes aren't the same as Linux keycodes, but the table > is fixed.) Except that some people like to remap the keyboard layout. I guess you need to do it in userspace (ie X) now. > For PS/2 you unfortunately cannot have a fixed table, and thus > EVIOCSKEYCODE is needed. > > Btw, the classic KD* scancode loading ioctls should now be supported as > well. This is only on the legacy keyboard driver, right? I'm really concentrating on the event interface. Brad - -- http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9op+hW6pHgIdAuOMRAhOZAJ4+3PAO1a9jsETxGa1gtkqFdaScwgCgol7r +UIJzxLconX6TnG9+IezFg4= =cSBP -----END PGP SIGNATURE----- |
From: Vojtech P. <vo...@su...> - 2002-10-08 09:18:45
|
On Tue, Oct 08, 2002 at 07:04:32PM +1000, Brad Hards wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tue, 8 Oct 2002 18:54, Vojtech Pavlik wrote: > > Because the USB keyboard tells us which keys it has, we don't need a > > scancode->keycode table. (We have something like that in the HID driver, > > because the HID codes aren't the same as Linux keycodes, but the table > > is fixed.) > Except that some people like to remap the keyboard layout. I guess you need to > do it in userspace (ie X) now. > > > For PS/2 you unfortunately cannot have a fixed table, and thus > > EVIOCSKEYCODE is needed. > > > > Btw, the classic KD* scancode loading ioctls should now be supported as > > well. > This is only on the legacy keyboard driver, right? > I'm really concentrating on the event interface. > > Brad > - -- > http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you? > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.6 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE9op+hW6pHgIdAuOMRAhOZAJ4+3PAO1a9jsETxGa1gtkqFdaScwgCgol7r > +UIJzxLconX6TnG9+IezFg4= > =cSBP > -----END PGP SIGNATURE----- -- Vojtech Pavlik SuSE Labs |