LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Linux Answers > Hardware
User Name
Password

Notices


By titopoquito at 2007-07-27 07:55
This HOWTO should give you the information to use an Microsoft Natural Ergonomic Keyboard 4000 (vers. 1.0) under X in Slackware 12.0. It probably will be useful for other distros, too, but I have not tested it on any other system.

The steps we will take:
  • Apply a patch from Li Yu to the kernel
  • Activate support for the USB HID simple interface and keyboard in kernel
  • Test if the patch works
  • Assign Symbol names to the extra keys
  • Decide what to do with lots of new keys :)


Get and apply the kernel patch
Slackware 12.0 comes with the 2.6.21.5 kernel. I have only tested the following with the stock SMP kernel. * (footnote text at bottom of this section)

You can get the patch from Li Yu at http://marc.info/?l=linux-usb-devel&m=117791396632096&w=2
Save the post in RAW format (there is a link at the top named "Download message RAW"). Edit it with any text editor, so that your patch file contains all between the first line that starts "diff -Naurp..." and ends right after the last patch line "+#endif /* __HID_SIMPLE_H */". To show it you exactly I post the first and last three lines of the patch file after removing the not needes lines.

Code:
diff -Naurp linux-2.6.21.1.orig/drivers/hid/hid-core.c \
                linux-2.6.21.1.new/drivers/hid/hid-core.c
--- linux-2.6.21.1.orig/drivers/hid/hid-core.c	2007-04-28 05:49:26.000000000 +0800

...

+/***** The private section end.  *****/
+#endif /* __KERNEL__ */
+#endif /* __HID_SIMPLE_H */
Now let's apply the patch. You have the kernel sources already installed, right? Else please do this right now. Then open up a terminal and do

Code:
cd /usr/src/linux-2.6.21.5
patch -p1 < /path/to/your/edited/patchfile
where of course you have to replace the path of the patch file.


Now let's jump to the next section ...

* If you use a 2.6.22 kernel there's a newer version (now, 2007-07-27) at http://marc.info/?l=linux-usb-devel&m=118429024024363&w=2 - I have not tested it, but it seems you need this if you run 2.6.22 because of some changes that won't let the older patch apply correctly to this newer kernel.



Kernel configuration and compilation
Now issue make xconfig or whatever config option you like most to configure your kernel.
Go to "Devices" --> "HID Devices". Activate "HID simple driver interface", so that it gets build into the kernel.
Then go to "Devices" --> "USB support". Activate "Microsoft Natural Ergonomic Keyboard 4000 Driver". I have build it as module myself, which seems to work without any problem.

I guess you know how to build a new kernel, else read the nice guide from xushi: http://xushi.co.uk/guides/kernel.php, you need stage 1 step 2 and stage 4.


Test if the patch works
The time has come to reboot your kernel. Start your GUI, then a console. From within the console run "xev". Place the xev window so that you can view the console output and start typing. All special keys of your keyboard should give some output like the following:

Code:
KeyPress event, serial 30, synthetic NO, window 0x2400001,
    root 0x156, subw 0x0, time 127400146, (-227,566), root:(324,974),
    state 0x0, keycode 170 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x2400001,
    root 0x156, subw 0x0, time 127400258, (-227,566), root:(324,974),
    state 0x0, keycode 170 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
The above output should appear when you type the "3" special key at the top middle of your keyboard.

If it doesn't work make sure that the module usbnek4k is loaded properly. I read on the net that sometimes you have to remove the module and load it again if you unplug the keyboard temporarily. Although I did not try it, keep it in mind if you unplug and re-plug your keyboard.

Nota bene: I have not altered my xorg.conf to include two keyboards, like it is written in older HOWTOs, this seems to be needed no longer.


Assign Symbol names to the extra keys
Now let's assign symbol names to the keys. You need that to get any Desktop Environment like KDE or Xfce4 or also Window Managers like IceWM or fluxbox to use the keys. How to apply these differs depending on if you boot into runlevel 3 (console) or 4 (GUI).

runlevel 3:
Create a file $HOME/.Xmodmap if it doesn't exist. Put the following stuff in there.

runlevel 4:
Create a file $HOME/.xprofile if it doesn't exist. Put the following stuff in there.

Code:
! Microsoft Ergonomic Keyboard 4000
! Zoom should work like mouse wheel already
! Homepage, Search, E-Mail
keycode 130 = XF86HomePage
keycode 229 = XF86Search
keycode 120 = XF86Mail
! 1 - 5 special keys
keycode 247 = XF86Launch1
keycode 132 = XF86Launch2
keycode 170 = XF86Launch3
keycode 219 = XF86Launch4
keycode 249 = XF86Launch5
! Audio Mute, Volume Lower, Volume Raise, Play
keycode 160 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 162 = XF86AudioPlay
! Calc
keycode 161 = XF86Calculator
! Favourites
keycode 93 = XF86Favorites
! Back/Forward
keycode 234 = XF86Back
keycode 233 = XF86Forward
! F1 - F12 second row without F-Caps-Key (right side of F12)
keycode 245 = osfHelp
keycode 135 = osfUndo
keycode 138 = osfRestore
keycode 137 = XF86New
keycode 191 = XF86Open
keycode 175 = XF86Close
keycode 228 = XF86Reply
keycode 142 = XF86MailForward
keycode 218 = XF86Send
keycode 184 = XF86Spell
keycode 213 = XF86Save
keycode 185 = XF86Launch6
! the three keys top left in number block
! the backspace key right has code 22 already and works like backspace
keycode 157 = XF86Launch7
keycode 246 = XF86Launch8
keycode 251 = XF86Launch9
Let's test it again. Fire up console and xev like you did before and look it the output of xev has changed. You should see the following now, if you type the "3" special key at the top:

Code:
KeyPress event, serial 30, synthetic NO, window 0x2400001,
    root 0x156, subw 0x0, time 129615035, (279,39), root:(830,447),
    state 0x0, keycode 170 (keysym 0x1008ff43, XF86Launch3), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x2400001,
    root 0x156, subw 0x0, time 129615155, (279,39), root:(830,447),
    state 0x0, keycode 170 (keysym 0x1008ff43, XF86Launch3), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
I have selected quite common names for the most keys. For some of them I found no equivalent and decided to call them XF86Launch1 - XF86Launch9. The Zoom handle works like mouse wheel with Li Yu's patch. In case you want to change the symbol names, take a look at /usr/share/X11/XKeysymDB.

Please notice that all F-keys have to possible symbols, which depends on the state of the F-Shift-key (it's right of the F12 key). I'm sure you have already seen the LED beneath your thumbs that indicates the key's state.


What now?
In most Window Managers and Desktop Environments you can assign short cuts to keys and/or key combinations. For example:

KDE: In KDE control center go to "Regional & Accessibility" --> "Keyboard shortcuts"
Xfce4: Start Xfce menu --> "Settings" --> "Keyboard Settings" --> go to tab "Shortcuts"
IceWM: Edit the file ~/.icewm/keys
Fluxbox: Edit the file ~/.fluxbox/keys


Thanks
... go to Li Yu for making this wonderful patch that makes the keyboard just work :)
... to trantorvega: http://gentoo-wiki.com/HOWTO_Microsoft_Natural_Ergonomic_Keyboard_4000
... to zerwas: http://ubuntuforums.org/showthread.php?s=ff19044ae62b53c1e8e2f5e1d9e6010...


  



All times are GMT -5. The time now is 10:53 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration