You are viewing hughsient

Technical Blog of Richard Hughes - Mapping keys : unfucking one keyboard at a time

Richard Hughes
Date: 2007-07-09 23:10
Subject: Mapping keys : unfucking one keyboard at a time
Security: Public
So the "unfuck my keyboard" project is going well. We now have a way to map scancodes to keycodes even for the vendors that choose non-standard scancodes that don't get input events.

The thinkpad-acpi and sony-laptop kernel drivers now also support the setkeycode ioctl and report key presses over input. This means we can map the acpi events to keys, even when vendors do crazy things and move the decal on the button between models and ranges for no apparent reason.

ALL LINUX USERS:

So now I need your help.

Do you get something similar to this in dmesg?:

atkbd.c: Unknown key pressed (translated set 2, code 0x97 on isa0060/serio0).
atkbd.c: Use 'setkeycodes e017 ' to make it known.


Try using all the fn-buttons and the special multimedia buttons, you might find you could help make this work.

SONY USERS:


I need to know what button does what on your laptop. You can already see I've fixed Bastiens laptop by looking at this file. This gives you an idea how simple it is.

THINKPAD USERS:

I also need to know what mapping you have. See this file and send me a patch to make it "just work" for you in the future.

Big Note:


You'll need to be using a very new HAL and hal-info to make this work right now. If you want the sony and thinkpad bits to work you'll also need kernel modules from git. Actually getting it working now is unimportant - getting the data as soon as possible makes sure it should work for as many people as possible for Fedora 8, or the next version of Ubuntu or Suse.

So please, visit the quirk site and help me try to fix broken keys by sending patches. I need your help.
Post A Comment | 13 Comments | Share | Link






simosx
User: simosx
Date: 2007-07-09 22:50 (UTC)
Subject: New hal and hal-info?
Can you give some info on how new the hal/hal-info should/must be?

If someone is running F7 or Ubuntu 7.04, would that be enough?

Would you be able to get usable information if you got those "atkbd.c: ..." and the details of the laptop, for people that do not have a recent HAL/hal-info? (assuming people are happy to help but do not mind if their system will not be fixed yet).
Reply | Thread | Link



Richard Hughes
User: hughsient
Date: 2007-07-09 22:58 (UTC)
Subject: Re: New hal and hal-info?
hal and hal-info from git. You can get packages from the utopia repo here: http://people.freedesktop.org/~hughsient/fedora/

> Would you be able to get usable information if you got those
> "atkbd.c: ..." and the details of the laptop, for people
> that do not have a recent HAL/hal-info?

Good question. Yes, you'll need to be using 0.5.9 for the system.* keys, although the dmesg warning has been the same since the beginning of time.

If you use the fedora rpm's listed above, then you can actually get things working now... :-) I'll be sending backports of the kernel modules soon, or we can just wait for 2.6.23.

Thanks for the help.
Reply | Parent | Thread | Link



simosx
User: simosx
Date: 2007-07-10 03:14 (UTC)
Subject: Re: New hal and hal-info?
Thanks for the reply and all the work on this.

I got hal and hal-info installed (compiled from git, on Edgy) in /usr/local/, and I run from command line after I have killed the standard hald daemon.

I created a section in /usr/local/share/hal/fdi/information/10freedesktop/30-keymap-misc.fdi for my laptop (NEC) and made sure it matches both product and model.
I put a line for scancode "6a" which controls the WiFi card. After I restarted and made sure that
$ lshal | grep keymap
info.capabilities = {'input', 'input.keyboard', 'input.keypad', 'input.keys', 'input.keymap', 'button'} (string list)
input.keymap.data = {'6a:wlan', '5a:mute'} (string list)
I continue to see the atkdb.c lines in dmesg.

I'll check again tomorrow. I think that the Edgy DBus is not happy with the recent hald.
Reply | Parent | Thread | Link



User: pvanhoof
Date: 2007-07-09 22:59 (UTC)
Subject: Why not make a little ui
Why not make a little ui that tells the user something in the lines of: You just pressed an unknown button. Do you want to participate in helping some cool hackers to help supporting this button?

o. No, never ask me again
o. Yes

And in case they answer yes, they get a list of possible actions that the button would do, get to fill in their laptop model and keyboard layout, etc etc
Reply | Thread | Link



Richard Hughes
User: hughsient
Date: 2007-07-09 23:05 (UTC)
Subject: Re: Why not make a little ui
>...You just pressed an unknown button...

Userspace knows nothing about a scancode, it just gets ignored in the kernel, hence why people have ignored it for so long :-)

For KEY_UNKNOWN and KEY_RESERVED we have problems as X will ignore the events. I don't think we can't really do this in a nice way, unless we sit and monitor every /dev/input/eventX. I suppose we could do this in HAL, but I'm not sure it belongs. I'll have a play, but I'm not sure it's possible.

Ideas welcome tho!

Richard.
Reply | Parent | Thread | Link



User: woojoh
Date: 2007-07-29 20:31 (UTC)
Subject: Re: Why not make a little ui
Hi Richard,

I made a keymap file 30-keymap-logitech.fdi for the keyboard i have, which has a function key mode button. This mode button turns the 12 function keys into new keys. So I mapped their scancode into the fdi file, and lshal shows results. But, they are still not recognized.

Shouldn't these fdi files require all the elements needed to duplicate the setkeycodes command's functionality. They do not at present have the keycode portion. Does Hal make up for this somehow?
I am really tugging at my distro trying to get this 0.5.10 built.

john
Reply | Parent | Thread | Link



User: woojoh
Date: 2007-07-30 15:08 (UTC)
Subject: Ok, Got it building...
trashed the Sabayon partition and threw in Slackware 12. Now I'm trying to not trash this partition... and build hal the same way it was built for 0.5.9.1

but autogen has alot of options. Here is what I'll try.

./autogen.sh --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--datadir=/usr/share

I sure hope this works.
Reply | Parent | Thread | Link



User: woojoh
Date: 2007-07-30 20:22 (UTC)
Subject: Ok, Got it WORKING!!!
pkg-config --modversion hal
0.5.10

slackware 12, with hal from git repository.

Now all the "Enhanced" function keys are firing events that xev sees.
I did not have to use any setkeycodes command, xmodmap... nothing else but a 30-keymap-logitech.fdi file.

Not all have keysyms, but mute, volumedown, volumeup work without any further configuring. Now I just need to find legitimate keysyms for the rest of the keys.

Where can I find the keysyms list that will be understood? Is it this?
hal-setup-keymap-hash-name.h.

I did get this in the syslog:
woojo kernel: keyboard.c: can't emulate rawmode for keycode 240
woojo last message repeated 9 times
Reply | Parent | Thread | Link



User: woojoh
Date: 2007-08-01 20:38 (UTC)
Subject: One more unfucked keyboard
Yeeeeeees... I have all keys working on this keyboard... and these were the kind atkbd.c bitched about to the kernel. Logitech EX110 with 12 Enhanced function keys, and some other easy keys to configure. I tried to post it on the hal mailing list... but I am just so happy, I probably messed it up there.

Between the mailing list, and the bug 11686 in freedesktop you can see how stubborn I am. Thanks for a decent hal.
Reply | Parent | Thread | Link



User: rpavlik
Date: 2007-07-10 00:02 (UTC)
Subject: Bluetooth Stowaway
Out of curiosity, would something like this eventually be able to enable the numerous "Fn+Key" shortcuts silkscreened onto my Stowaway Sierra bluetooth keyboard? (I use it with my N800, but none of the "special keys" work, since the n800 sees only a 104-key keyboard.) If I get a Bluetooth dongle for my desktop, I will see if I get those messages and let you know.

Thanks for your work on this! This is one of those things where I anticipate it will work better on Linux than on Windows soon (libgphoto and 900+ cameras supported without additional drivers :D )
Reply | Thread | Link



User: dsdrake
Date: 2007-07-11 23:51 (UTC)
Subject: what about keys that dont generate that message?
Nice site and project! Patch for my system coming up...

What about keys that don't produce those messages in dmesg? The site does mention them but isn't clear about what to do with them.

I have several multimedia keys on my laptop, which do not produce the dmesg warning. I can bind these keys using GNOME's keyboard shortcut program. However, it would be really cool if these worked out of the box. Is there another project that handles this, or is this something for the future?
Reply | Thread | Link



FallibleDragon
User: fallibledragon
Date: 2007-07-12 10:15 (UTC)
Subject: Level of key definition
I, for one, will be very glad to have my keyboard "unfucked" :)

Thinking on a longer-term basis, I've always thought that X/Unix did keyboard mapping wrongly. There's the hardware level keycodes, console keycodes, SDL, X...

To me, it would make more sense for the device drivers to know what the keys are on a device, and to pass them to a virtual input mapping layer. That layer could then provide input to user space at a high symbolic level, such as 'a' pressed/released, etc. X could understand those same symbols through a simple (possibly sparse) one-to-one mapping, and would therefore need no configuration of keyboards etc. Likewise, for the console, for SDL, etc. This HAS been done, for the freebsd mouse device, so it could be done similarly on linux, for keyboards, mice, tablets, etc.

All that's required is a good virtual input layer that supports the required event types, and maintainers that are willing to add codes that new low-level devices and/or high-level UIs know about.
Reply | Thread | Link



Richard Hughes
User: hughsient
Date: 2007-07-12 10:31 (UTC)
Subject: Re: Level of key definition
>X could understand those same symbols through a simple (possibly sparse) one-to-one mapping

That's the plan. It's called evdev, but it's still pretty young.
Reply | Parent | Thread | Link



browse
my journal
April 2008