Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I found that I had to patch setkeycodes under MDK 10.1 to allow me to specify keycodes greater than 127. For my Logitech Access Keyboard I managed to map most of the multimedia keys so that I can use the xkb layout unmodified:
Code:
#!/bin/sh
#
# setkeycodes-logiak Use setkeycodes to map the unmapped Logitech Access
# Keyboard multimedia keys to keycodes that allow the xkb
# layout to be used unmodified.
#
# Scancode Keycode Key
# e011 ? Messenger
# e012 152 Webcam
#
# e03b 212 New
# e03c 137 Reply
# e03d 213 Forward
# e03e 214 Send
#
# e043 219 My Computer
# e044 220 My Documents
# e057 228 My Pictures
# e058 229 My Music
setkeycodes e012 152 \
e03b 212 \
e03c 137 \
e03d 213 \
e03e 214 \
e043 219 \
e044 220 \
e057 228 \
e058 229
I used an exhaustive method to find kernel keycodes that match the keycodes seen by xkb. It involves running xev and a loop to cycle through the keycodes above 127, pressing the key I chose to map, and making a note a bit of paper when a keycode I recognised in xev came up. I ran the following shell script as root in an X terminal.
Code:
#!/bin/sh
#
# Usage: scankeycodes SCANCODE
#
SCANCODE=$1
let i=128
while [ $i -lt 240 ]; do
echo "set scancode $SCANCODE to keycode $i"
setkeycodes $SCANCODE $i || exit 1
sleep 5
let i=i+1
done
Quote:
Originally posted by TheVisionary I am also trying to setup a media USB keyboard and found that some keys don't show anything.
Maybe this info can help: http://www.tcnj.edu/~tolboom2/globlink_rf88.html
The USB keyboard driver doesn't appear to have any code in it that would print a message when a unmapped key is pressed. Try using "showkey -s" in a virtual console to find the scancode of keys that don't show up in xev. Then you can use setkeycodes as described above to map the unmapped keys to some keycodes.
Since there doesn't appear to be an xkb layout defined for your keyboard you could use the keycodes defined in include/input.h of the kernel source. For example, if you had a Mail multimedia key with a scancode of e06c, then you could use the keycode defined in input.h:
Ok, bare with me, ... this is going to be long and wordy, but I'm tired and it's just easier to put my train of thought down in words than to concentrate on making it short/comprehendable.
I just bought a Logitech COrdless Desktop LX 700 combo, and was trying to get it setup on gentoo (Gnome 2.8, gentoo-dev-sources 2.6.9 kernel). I spent a lot of time on this forum and many others trying to figure out all my problems, and bit by bit, I was able to figure some things out, while others still remain a mystery.
My old Dell Multimedia keyboard was having problems where it would not send any scancodes that were greater than a certain max (not sure where it cut off, but I would assume at 255, or even 127). The keys wouldn't even show up in `showkey -s`, which means the kernel was dropping it at a very early stage. So anyway, I had heard a lot of good things about Logitech in general for linux, so I decided to try it.
One thing I noticed is that it was reading scancodes, which was good, but no keycodes, and checking dmesg explained why (use setkeycodes). So I mapped the scancodes to available keycodes, and stuck that in my local.start -- now xev was able to pick up the keycodes (NOTE that the keycodes you feed to setkeycodes are NOT the same keycodes that xev/X detects!)
So, next I wanted to get all the buttons working on my mouse (10 buttons including scroll, 2 of which are the tilt wheel) Well, no matter what I did with xorg.conf, it wouldn't detect the 2 side buttons, the top "extra" button, or the tilt positions. I read that only evdev would allow more than 7 buttons, but before trying that, I wanted to see if connecting it via USB would help any, so I removed the USB-to-PS/2 adapter from the keyboard cord and unplugged the mouse cord, and tried it out.
At that point I could get all the mouse buttons to work (including tilt wheel, woohoo!), but then realized that my media keys stopped working again. I checked showkey -s and got nothing (well, certain keys do work, like Mute, Vol Up/Dn, E-mail, Play, Prev, Next, but none of the others), but showkey -k surprisingly did show keycodes for those keys (all > 255, ... not surprisingly) So basically, I was back at the same point with my old keyboard, not being able to use the extra keys because the keycodes were too high. It's kind of strange that the only difference was the USB/PS2 connection. With PS/2, the scancodes work properly and you can map them to a good keycode, which you can then map to a XF86 symbol, which can then be mapped to an action (whew), but with USB, you get no scancode, invalid keycode, and thus no way to use those keys.
So... I'm back at PS/2, my keyboard works (at least all the keys are usable - I haven't done anything useful with any of them other than the media keys, mainly because Gnome's new keyboard shortcut handler sucks), and I've managed to get 7 buttons working on the mouse (tilt L/R don't work, nor does the top extra button, but the scroll wheel and the two side buttons get a response from xev on unique Button numbers).
I know that's a lot of rambling (excuse me, it's 2am and I need sleep), but that might help someone out who runs into the same issues. If I had more time I would look through keyboard.c, hid-input.c, atkbd.c, etc, and just hack my way through it, but right now I don't feel like it.
So at the moment, the only part that is not working are those 3 "buttons" on the mouse. I think the tilt wheel is just because it's new and hasn't been fully supported in evdev yet (soon I hope), and I have no clue why button #8 doesn't work.
By the way, it seems that some actions would work best as keystrokes, and others as commands, but I'm running into problems with Gnome... Gnome only lets you map a key to a preset action, and it doesn't let you customize it any further than that. For example... the "Media" key would usually be used to execute XMMS or something like that, but Gnome doesn't give you that option. SO what would be the most logical way to have that key execute xmms? And for the zoom in/out buttons, I know of the symbols XF86ZoomIn and ZoomOut, but once it's mapped to that, what can you actually do with it? I'd like them to adjust text size in applications that allow it (^+/^-). I really hate to have to use multiple programs to handle the keys like that, but it seems with Gnome's key binding, we really don't have much of a choice. :/
Oh, and does anyone know what the point of the "%" key is, next to zoom in and out?
I've also bought the LX700 combo, and I'm starting to set up the multimedia keys.
Can you post your scancodes and keycodes?
btw, I can't get the mouse to work. If I connect the mouse, the keyboard won't respond, and if I then connect the keyboard, the mouse stops working.
Right now I have my mouse in Xfree assigned to /dev/psaux (or /dev/input/mice, works too). How did you assign the mouse?
I kept running into problems of assigning keys to already-used keycodes, so I had to reassign some of them a few times until I found something that worked. So basically here is what I added to my local.start (commands that get executed on boot, after everything else):
I got those scancodes by pressing the keys and watching the dmesg output for the scancode, and the keycode is pretty much trial and error unless you know which kernel keycodes are free (since the xev keycode will vary greatly from what you enter here, for example: all the numbers above are more or less consecutive, but the xev scancodes vary from 120 to 220 or more.)
By the way, you mention one device working while the other isn't -- make sure you aren't using the USB connection and the PS/2 at the same time. It is designed to work either a) Mouse and Keyboard both connected via PS/2 (with the USB->PS/2 converter on the keyboard cable), or b) ONLY the keyboard connected via USB. Mine is currently working using the two PS/2 connectors.
If you are working on mapping the multimedia keys of a keyboard that doesn't already have an XKB layout in X then this script will help with finding keycodes to use with setkeycodes:
It will output key symbols defined in the kernel header input.h that have a keycode above 127. I added a few keycodes with a value below 128 manually. As has been noted above these keycodes are same as those in X. I'm interested to know if anyone has worked out a formula to convert between the two as I was unable to find one.
I used getkeycodes (as root) to show a list of all the used keycodes. The output is somewhat difficult to read, but at least I didn't had an issue assinging the correct keycodes
This is a complete list of my keycodes, functions, scancodes and the issues setkeycodes:
Just tested the mouse on a Win 2k machine. Doesn't work either.
Guess i simply bought the wrong box..
I also found out that having a .xmodmap config file in your homedir doesn't work in Gnome, because gnome has its own keyboard shortcuts, and those overrule the xmodmap settings.
So now I am setting my machine up like this: http://foolish.fedorausers.org/gnome...uts/index.html
Works fine, though it takes more time to set it up..
Originally posted by Lightner I also found out that having a .xmodmap config file in your homedir doesn't work in Gnome, because gnome has its own keyboard shortcuts, and those overrule the xmodmap settings.
I had a workaround to load the xmodmap settings after the keyboard layout for KDE. I've looked into whether this could be done with GNOME but it doesn't look likely. It would require somehow stopping GNOME from loading a keyboard layout using XKB. That leaves the option of creating a new XKB layout and a patch for it so you can post it. It's possible now to have a somewhat generic XKB layout using the keycodes defined in the kernel header input.h if you have a 2.6.x version of it.
I'm sorry --- I think I still don't understand well enough. It seems from other examples in this thread, that SOMETHING happens to the second argument to setkeycodes inside --- it seems like those numbers from 0-127 turn into some other numbers internally. Is there any way, short of reading the code, to figure out what that process is?
If I'm restricted to only 0-127, and those are just 0-127, don't I end up crushing the normal alphanumeric keys?
I'm sorry to be asking such dumb questions, but I haven't had much luck figuring out how the keyboard driver works from just the manpages.
Originally posted by rpg I'm sorry --- I think I still don't understand well enough. It seems from other examples in this thread, that SOMETHING happens to the second argument to setkeycodes inside --- it seems like those numbers from 0-127 turn into some other numbers internally. Is there any way, short of reading the code, to figure out what that process is?
If I'm restricted to only 0-127, and those are just 0-127, don't I end up crushing the normal alphanumeric keys?
I'm sorry to be asking such dumb questions, but I haven't had much luck figuring out how the keyboard driver works from just the manpages.
Thanks!
You need to patch setkeycodes as it restricts the keycodes to 0-127:
I haven't read all of this post, so if this is in the wrong direction excuse me. To use the multimedia functions on my keyboard I use a simple utlity called lineak http://lineak.sourceforge.net/ , what it does is its a daemon that waits for the multimedia function to be pressed. Hence when I press the play button xmms starts or pauses depending on the state. Forward for the next song, previous for the previous song. And its simple to set up. Also I checked using lineakd -l command and your keyboard is supported. Using this config paramter, lineakd -c LTCDP Logitech Cordless Desktop Pro, then you edit the .lineak file for what you want each command to do. Plus if you install the on display program, it comes up with a cool little text on your monitor depending on what your doing.
As usual I've noticed the rather odd behaviour where mapping a key to a keycode changes its scancode. If anyone has some inside knowledge into predicting this change in scancode it would be handy to know.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.