View previous topic :: View next topic |
Author |
Message |
AgentMascan n00b


Joined: 04 May 2004 Posts: 29 Location: Idaho, USA
|
Posted: Mon Mar 06, 2006 12:41 am Post subject: [HOWTO] MS Natural Multimedia Keyboard (The Natural Way) |
|
|
MS Natural Multimedia Keyboard (The Natural Way)
The following method can be used to enable all the multimedia keys on the Microsoft Natural Multimedia Keyboard1.0A. I am uncertain how well it will work for other Microsoft keyboards.
Many Natural Multimedia Keyboard owners know that xorg does not have an xkb model for their keyboard. You could define your own keyboard model to solve this problem. I suppose it wouldn't be too difficult either, but I prefer not to manually edit or create anything in /usr/ if I can avoid it. There is also an xkb model for the Wireless Multimedia Keyboard. It's not a perfect match, but it's close enough. (In fact, if you look at both models, you will see that they have the same mltimedia buttons.) Instead of creating a new xkb model for the Natural Multimedia Keyboard, we will be adapting our keyboard to behave like the Wireless Multimedia keyboard.
(Hint: Jump to the "Shortened Version" if you know what's good for you.)
So here's how we will enable all of the multimedia keys:
To use this XkbModel, we'll have to edit /etc/X11/xorg.conf. Find the following options, and edit them accordingly.
Code: | Option "XkbRules" "xorg"
Option "XkbModel" "microsoftmult"
Option "XkbLayout" "us"
Option "XkbVariant" ""
|
You will have to restart X for the new xkb configuration to load.
The problem with using this particular XkbModel is that not all of the multimedia keys seem to work ("My Music," "Log Off," and all alternate F-Keys to name a few). This is because no keycodes have been assigned to the scancodes for these keys.
In order to enable them for any system to use, we'll have to assign a system keycode to each unassigned raw scancode, but we shouldn't just go assigning them any keycode value that isn't currently in use. Instead, we will determine what scancodes the "microsoftmult" model is configured to use and adapt our keyboard to match.
To do this, we'll have to look at two files. /usr/X11R6/lib/X11/xkb/symbols/inet contains keysymbol definitions for a for a handful of internet and multimedia keyboard models, including "microsofmult" (aka Microsoft Wireless Multimedia Keyboard). Within each keyboard section, keysymbols are matched to codes that are used internally within xkb. from now on we'll call these internal codes xkbcodes (feel free to step in and tell me their real name).
Code: | keysymbol xkbcode
XF86Pictures I64
XF86Music I3C
XF86Messenger AE13
XF86LogOff I16
...
|
/usr/X11R6/lib/X11/xkb/keycodes/xfree86 contains a table that maps each xkbcode to a system keycode.
Code: | xkbode keycode
I64 228
I3C 188
AE13 133
I16 150
...
|
The xev utility can be used to determine the scancodes of each key and if a keycode has already been assigned to a scancode. If you press a multimedia key and xev returns its assigned keycode, then you don't have to worry about that key (it's already been configured). If you press a multimedia key, and nothing happens, read the output of the dmesg command in another terminal, and it will tell you what the scancode is.
Using xev, and the two files mentioned above, a table can be built that matches all of the key information.
Code: | scancode keysymbol xkbcode keycode
e064 XF86Pictures I64 228
e03c XF86Music I3C 188
e005 XF86Messenger AE13 133
e016 XF86LogOff I16 150
e03b Help I3B 187
e008 Undo I08 136
e007 Redo I07 135
e03e XF86New FK14 119
e03f XF86Open FK15 120
e040 XF86Close FK16 121
e041 XF86Reply FK17 122
e042 XF86Forward I42 194
e043 XF86Send I43 195
e023 XF86Spell I23 163
e057 XF86Save I57 215
e058 Print I58 216
|
The setkeycodes command can be used to assign the keycodes. The syntax for setkeycodes is setkeycodes [scancode] [keycode].
Here's where things get weird. Looking at the above table, you would think that to assign a keycode to the XF86Pictures key, you would input setkeycodes e064 228. For some reason that I haven't determined yet (if you know please tell me), every keycode is automatically altered. If we open up xev again after assigning keycode 228, the "My Pictures" button returns the number 215 (the number for XF86Save). I guessed that maybe there was a slim chance that all keys were offset by 13, but that wasn't the case.
Having given up on trying to determine how the numbers were being mutated, I eventually went through a trial and error process, trying keycodes 130-250 to determining which keycodes mutated into the keycodes we need.
Code: | keycode keycode-to-be-mutated
228 232
188 137
133 129
150 196
...
|
To ensure that the keycodes are always configured, we should add the following sequence of commands to /etc/conf.d/local.start. We'll enable the keys for the current session as well by executing the same sequence in an available terminal.
Code: | setkeycodes e064 232
setkeycodes e03c 137
setkeycodes e005 129
setkeycodes e016 196
setkeycodes e03b 212
setkeycodes e008 176
setkeycodes e007 131
setkeycodes e03e 214
setkeycodes e03f 215
setkeycodes e040 216
setkeycodes e041 136
setkeycodes e042 218
setkeycodes e043 219
setkeycodes e023 160
setkeycodes e057 228
setkeycodes e058 229
|
After that you are free to use whatever key mapping software you choose too (I am currently using KHotKeys).
Shortened Verion:
1. modify xorg.conf to point to the MS Wireless Multimedia Keyboard.
Code: | Option "XkbRules" "xorg"
Option "XkbModel" "microsoftmult"
Option "XkbLayout" "us"
Option "XkbVariant" ""
|
2. Restart X with new configuration.
3. Add the keycodes to local.start so that they are always loaded during boot.
Code: | setkeycodes e064 232
setkeycodes e03c 137
setkeycodes e005 129
setkeycodes e016 196
setkeycodes e03b 212
setkeycodes e008 176
setkeycodes e007 131
setkeycodes e03e 214
setkeycodes e03f 215
setkeycodes e040 216
setkeycodes e041 136
setkeycodes e042 218
setkeycodes e043 219
setkeycodes e023 160
setkeycodes e057 228
setkeycodes e058 229 |
4. Enable the keycodes for the current session by executing them in an available terminal.
5. Use key mapping software to assign tasks to each key.
-----
Thanks to to following sources.
http://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys for providing information about xev, scancodes, keycodes, keysymbols, and setkeycodes
https://forums.gentoo.org/viewtopic.php?p=1896734 for providing the location of files buried deep within the X11's folder hierarchy. _________________ Day 6 and my Skittles are still nowhere to be found. I fear for tommorrow, for I shall not be able to taste the rainbow.
Last edited by AgentMascan on Thu Apr 06, 2006 9:33 pm; edited 3 times in total |
|
Back to top |
|
 |
YukataNinja n00b


Joined: 15 Mar 2006 Posts: 14 Location: Seattle, WA
|
Posted: Mon Mar 27, 2006 12:34 am Post subject: |
|
|
Hey, Thanks!
I had been trying for an hour or so to dig through all of these scancodes and keycodes nonsense and then they just started mutating on me. What is up with that? Should this be filed as a bug to xorg?
I have the wireless version and your codes matched perfectly to get the four unmaped keys and then the f keys going. Only thing I had to add was this to my ~/.Xmodmap (exec at session load by xmodmap):
Code: | keycode 239 = XF86Documents |
It had been marked as NoSymbol.
Thanks again for saving me the major hassel. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|