Slashdot Mirror


How do you Define Extra Keys for X?

baadpuppy asks: "Ok, so I bought this nifty (and cheap) keyboard that has 'Internet multi-media' features: silly little buttons that do things like BACK in your browser, and scrolling, and controlling your CD and volume, etc. It was only 19.95 and had a $10.00 rebate, so I figured 'what the heck, it's only 10 bux wasted if I can't use them'. I read keyboard howto, and got the keys recognized by the Linux kernel, and everything is groovy for console apps. However, I spend 99.99999% of my time in X, not at the console, so I want to make these keys work in X. I have the list of scan codes (the kernel was kind enough to list them when it didn't recognize them). What has to be done to make X understand them? baadpuppy continues...
"I looked at the "XKB" extensions, and if there's any good documentation there, it's well hidden. I've downloaded the source code for the X server, and spent more than 5 hours perusing that code trying to figure out exactly where I might go about adding these keys!"

12 comments

  1. xev by Anonymous Coward · · Score: 0

    See what xev says when you press the keys. If it notices them, then you can use xmodmap to bind them to some keysym, and then tell your wm or apps to use this keysym. If you're lucky, xkeycaps will know about your keyboard, which makes the whole thing easier.

  2. Meta_L by Anonymous Coward · · Score: 0
    I just set up my Xfree config to see a 'Microsoft' keyboard ... then In my windowmanager (windowmaker) I've set Meta_L to work as a front/back key ... works wonders.

    -al

  3. Linux Gazette last summer by Anonymous Coward · · Score: 0

    June or July I think had an article on how to map those win95 keys to window manager functions. Works for an FVWM derivative WM. The following month had a KDE source patch to achive the same effect. Check that out and apply/extend the concepts.

    Rick

    rick@bart.phys.strath.ac.uk.earth.sol.milky-way

  4. type 5 kb by John+Kozan · · Score: 1

    I dont know anything about PC but on Suns our keyboards have buttons like Stop, Again and Undo at the side of the keyboard. These keys work in Netscape and Emacs.

  5. Map key combo to run a program? by Jeff+Lightfoot · · Score: 1

    I'd like to map SHIFT-CTRL- to run a certain programs but I can't figure out how.

    Does my window manager need to look for the combo and launch it or is there a generic way to set it up.

  6. Fun ways to (ab)use those extra MS keys... by Peter+Amstutz · · Score: 1

    Actually I fine the windows keys to quite useful for "meta" in Emacs. In fact, I have a full complement of shift bits - shift, control, alt, altgr(language shift), meta, hyper, & super. Hop over to here to see my xmodmap map. Oh, one catch - it's for a dvorak layout :)

  7. Use xev and xmodmap by Tet · · Score: 1
    First, you need to find the X keysyms for the keys. The easiest way to do this is probably to use xev. Move the cursor to the xev window, and press the key you want to know about. You should see a KeyRelease event, with a line like:
    state 0x0, keycode 125 (keysym 0xff6a, Help), same_screen YES,

    This says that the key generates the key code 125, which is currently mapped to the Help keysym. You can either try and find out how to assign the Help key to "back" in Netscape (probably by setting something in your X resources file), or you can use xmodmap to map this key to something that Netscape might already use to go back.

    --
    "The invisible and the non-existent look very much alike." -- Delos B. McKown
  8. More Clarification by baadpuppy · · Score: 1
    I realize I should have included all the relevant data in the initial question.

    What I have done:

    I used 'xev' to see if any events were generated for the extra keys. Only the MickeySoft keys generated any events. From my (admittedly limited) knowledge of the X event system, if the keyboard handler isn't generating a key pressed event, then nothing I do with xmodmap or xkeycaps is going to help. I first have to convince the X server's keyboard code to generate some kind of events for key presses of those keys.

    Once that part is done, I'm fairly confident that I can deal with xkeycaps/xmodmap to make the keys actually useful (and yes, I intend to try to create the stuff for xkeycaps so others can use it later).

    I suppose I'm a bit confused as to why X has to have it's own code to do hardware scancode conversion to software events, when (at least under linux) this seems like a kernel thing to do. I have my linux kernel being very happy about the extra keys, but X seems to just quietly ignore them. I fear I'll have to delve into the XKB extensions to get it to work.

    Thanks for all the comments so far folx.

  9. How about those Lose95 keys? by A+nonymous+Coward · · Score: 1
    This new computer of mine has one of these Lose95 104 key keyboards.
    1. How do I get X to recognize them? I don't see anything obvious in keysymdefs.h.
    2. FVWM's 'Key' function doesn't have any modifiers for these keys. Will I have to modify the sources? Probably trivial to add 'W' for instance, but I'd just as soon not if I don't have to.
    3. How about regular programs from then on? I suppose Xkeycaps would help, although I tried it. I don't know how to reference them, since X doesn't appear to recognize them.


    --
  10. I think you need at least one "real" key in there by A+nonymous+Coward · · Score: 1

    xkeycaps man page implies that modifier keys are just that - modifiers. They can't do anything by themselves, they can only modify other keys' actions. Now you could redefine them as non modifiers...

    --

  11. Have you tried adding the key codes to a xmodmap.. by ixx · · Score: 1

    You could try just adding the keycodes to a file
    and run xmodmap on it

  12. Modifying X Keymap by phuse · · Score: 1

    The program you want is called xkeycaps. It lets you select a keyboard from a database of lots of different ones, and then writes out a file that is readable by xmodmap (the program that loads modifications to the keyboard map into X).

    Get it at: http://www.jwz.org/xkeycaps/

    So, just use xkeycaps to set up the keys to do whatever you want, save to a file (say, ~/.xmodmap-localhost) and put in your .xsession:
    xmodmap ~/.xmodmap-localhost

    You should read the xkeycaps man page after you install it, it sheds a lot of light about keyboards and how X handles keys. Good luck.