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 |