X4Daemon

X4Daemon is created to make it possible to use the extra keys on Microsoft’s Sidewinder X4 keyboard, which weren’t usable under linux until now. It takes control over the second interface of your X4 keyboard (first interface controls the “standard” keys, second interface controls the “special” keys like all media keys, calculator, S1 to S6,etc.) and passes all presses to uinput.

Under Windows you can record macros and switch between 3 banks on your X4 keyboard. I didn’t implement this feature because it is entirely done in software and my primary objective was to get the special keys working. I am also working on something for the 5 LEDs, it should be possible to use them for notifications or something like that. This will be released in some future version of X4Daemon.

Depending on your windowmanager you should be able to define keys somewhere, I use S1-S6 and Bank_Switch for switching between my virtual desktops in AwesomeWM, which is very nice. I didn’t test this in Gnome or KDE, but it should work fine. You can check if X4Daemon works correctly with xev. Mail me if you have problems getting it to work!.

I have no X6 keyboard, so if you have a X6 keyboard try it! You need to change the ProductID to the correct one (get it with lsusb) and then compile it. I don’t know if X6 has more keys or uses other keycodes, but if you mail me correct X6 keycodes I think I can implement them. But I don’t know how to get those keycodes, I didn’t need to find them for X4 because someone else did it already (see “Special thanks..”).

I made this package for Archlinux, I didn’t test it on any other distros. It should work fine, but you have to write your own init script I think. (I only wrote one for Archlinux.). If you got a working init script for your distro, mail it to me;-)

Special thanks go to tolga9009 for posting the keycodes on ubuntu forums and on libg15 forums. I have no idea how he got those keycodes… :D

You can download the latest source here (latest version is 0.4.2).
Here you can find the package in AUR.

md5sum: b2964ce1d21f3031ccc4cfa449c0f05d
sha256sum: d65058b5a76cb7161010d097af3de9064230f179ac9fddfb7ec4d13664c047f1

Howto compile it on other distros than Archlinux:

  1. I assume that you have build-essential (gcc,make,..), checkinstall, autoconf>=2.68 and libusb-1.0.0-dev installed. (package names depend on used distro)
  2. Download the sources
  3. tar -xvjf <archivename>
  4. autoconf (maybe not needed, only try if you have autoconf >= 2.68)
  5. ./configure
  6. make
  7. sudo checkinstall (or sudo make install <- not recommended)
  8. Start x4daemon (sudo x4daemon -w)
  9. For automatic start, just put x4daemon -w -D to /etc/rc.local (or create a init script for you distro ;) )

Changelog:
2011/12/30 Version 0.1
- initial release

2011/12/31 Version 0.2
- added daemon mode (-D)
- added reinitalization when disconnecting device
- added waiting mode if disconnecting device (-w)
- added syslog for daemon mode
- added init script for arch linux
- added waiting for device at start when using -w

2012/01/07 Version 0.3
- added better checks to configure.ac
- added check for uniput module
- added auto load function for uinput module
- fixed some warnings while compiling (for some other distros)

2012/01/10 Version 0.4
- fixed help buffer error for -h
- added some more help/readme stuff (mainly XF86Keycodes)
- fixed pipes for some older shells (&> does not work on some sh)
- added waiting code after loading uinput module (for some distris like debian)

2012/01/14 Version 0.4.1
- changed version scheme
- fixed a bug for siduction, NULL for standard context in libusb_get_device_list does not work there

2012/01/14 Version 0.4.2
- fixed new version scheme problems…

Known Bugs:
- It works fine on virtualbox (stop X4Daemon on the host before trying!) until you want to end X4Daemon. X4Daemon then can’t release the interface correctly until you disconnect the usb device in virtualbox’s menu (X4Daemon will hang until you do this). This is not caused by X4Daemon (I think), it seem to be some problem with virtualbox’s usb drivers.

X4Daemon is reported/tested as working on following Distributions:
- Archlinux (of course)
- Linux Mint 11
- Debian Squeeze
- Siduction

Usage: x4daemon [OPTION]…

-d,–debug Activate debug mode.
-D, –daemon Activate daemon mode, alle messages go to syslog.
-h, –help Show this help page.
-r, –reset Reset device when starting (shouldn’t be necessary).
-v, –version Show version.
-w, –waiting Wait for device at start and if it disconnects.

 

Standard assignment of keys is:

Key: Keycode (input.h): Keycode: Keycode (XF86):
S1 KEY_PROG1 148 XF86Launch1
S2 KEY_PROG2 149 XF86Launch2
S3 KEY_WWW 150 XF86WWW
S4 KEY_MAIL 155 XF86Mail
S5 KEY_COMPUTER 157 XF86MyComputer
S6 KEY_PHONE 169 XF86Phone
Bank_Switch KEY_MEDIA 226 XF86AudioMedia
Record KEY_RECORD 167 XF86AudioRecord
Play_Pause KEY_PLAYPAUSE 164 XF86AudioPlay
Previous KEY_PREVIOUSSONG 165 XF86AudioPrev
Next KEY_NEXTSONG 163 XF86AudioNext
Mute KEY_MUTE 114 XF86AudioMute
VolumeUp KEY_VOLUMEUP 115 XF86AudioRaiseVolume
VolumeDown KEY_VOLUMEDOWN 114 XF86AudioLowerVolume
Calculator KEY_CALC 140 XF86Calculator

 

You can change the keys in source code, see keys[] array.
(I just used some unused keycodes for the special keys.)
Mute,Prev,Next,PlayPause,VolDown, VolUP and Calc use the same keycodes as before.
See /usr/include/linux/input.h for more information.
It is not possible to switch banks or to record macros.
If you find any bugs or if you want to tell me something click here.

X4Daemon comes with absolutely no warranty.
It is licensed under the GPL (General Public License), version 2 or later.
Details should be in the src package or at http://www.gnu.org/licenses/licenses.

Older versions of X4Daemon:
X4Daemon 0.4.1
md5sum: c749935260f9ad91b2305c4fe58d8111
sha256sum: d8d77531f343e68cad5e9b11008953b7b14f82c8157828985d0286aa3f9032be

X4Daemon 0.4
md5sum: 23c77844940fe9f1bb351de7fe701cb1
sha256sum: 508277ea7bb7d227dc16eff98402eddff96fe3cedc63a84d5145db70d4ade7e2

X4Daemon 0.3
md5sum: e1cc8aa21ad17eb9475af2d2043c1839
sha256sum: fa21d8bf4074972a78bc4c2154fc0fa93dcc2667c9af3fe60a4cc5d802ba0d59

X4Daemon 0.2
md5sum: f5ba0722429911fb3cb669e56f98fe52
sha256sum: c9e4741a1432d4ddda2ca45a5f1b323d86c244909cea83e05fd9f28522461016

Comments (9)

  1. 19:14, January 10, 2012Timsche  / Reply

    Hi,

    ./x4daemon -w
    Starting…!
    uinput 6400 2
    Memory Access Error

    I started it as root and installed like you described it for other distros.
    I’m on Debian.

  2. 21:28, January 10, 2012Andreas  / Reply

    Which Debian do you use? Squeeze?

    I try that later ;)

  3. 02:19, January 11, 2012Andreas  / Reply

    I tried on debian squeeze, works fine. I also fixed some other problems for debian, please try again with 0.4. If you still got errors please post debug output (“x4daemon -w -d”).

  4. 20:06, January 12, 2012Timsche  / Reply

    ./x4daemon -w -d
    Starting…!
    Debug: Uinput module already loaded.
    Debug: Uinput initalized…
    Debug: Waiting for device…
    Debug: Trying to reinitalize the device…
    Speicherzugriffsfehler

    Ist immer noch wie vorher – benutze Debian Siduction was aber kein Problem darstellen sollte… Hoffe du kannst was mit den Debugausgaben anfangen, wäre echt nice das Teil zum Laufen zu kriegen.

  5. 16:38, January 14, 2012Andreas  / Reply

    Liegt irgendwie an Siduction selbst, er mag da den standard context in libusb_get_device_list nicht, geht aber nun in 0.4.1 ;)

  6. 17:59, January 14, 2012Timsche  / Reply

    $ make
    make all-am
    make[1]: Entering directory `/home/tim/Downloads/x4daemon-0.4.1′
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT x4daemon.o -MD -MP -MF .deps/x4daemon.Tpo -c -o x4daemon.o `test -f ‘src/x4daemon.c’ || echo ‘./’`src/x4daemon.c
    src/x4daemon.c: In function ‘interpret_args’:
    src/x4daemon.c:344:25: error: too many decimal points in number
    src/x4daemon.c:352:50: error: too many decimal points in number
    make[1]: *** [x4daemon.o] Fehler 1
    make[1]: Leaving directory `/home/tim/Downloads/x4daemon-0.4.1′
    make: *** [all] Fehler 2

    Habe das #define version in Zeile 33 auf 0.41 gesetzt statt 0.4.1 – das müsstest vll noch anpassen und ansonsten laufen die S-Tasten jetzt soweit – danke dir =)

  7. 00:05, January 15, 2012Andreas  / Reply

    Ups.. vllt. sollte ich es nachdem ich die Version geändert hab auch nochmal testen :D

  8. 09:02, January 27, 2012no  / Reply

    Hi Andreas,

    Klasse Arbeit, danke dafür.
    Der Daemon in Version 0.42 läuft hier auf einem debian sid mit vanilla kernel ohne Probleme

    • 17:38, January 29, 2012Andreas  / Reply

      Danke, freut mich zu hören!

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>