[LINUX] Wiimote Daemon for XBMC, Emulators, etc.
#1
Hello all! After a lot of searching for a way to connect wiimotes to my XBMC box in what I decided would be the right way to do it, I finally ended up having to write my own program. I figure this will probably be useful for others, so here it is!

This is a small application to let you connect up to four wiimotes, and translate any button presses into joystick buttons! Essentially, when run, the program creates four virtual joysticks: "Wiimote 1 Virtual Joystick", "Wiimote 2 Virtual Joystick", etc. It then sits in the background, listening for wiimotes to connect. When a wiimote is connected, it is assigned the lowest available number, and any button presses are translated to joystick buttons!

The classic controller is supported, but you'll need to connect it to the wiimote after connecting the wiimote. Note that the classic controller and wiimote currently share virtual joystick buttons, so you won't be able to use both of them for two different purposes, but I don't think that'll be a problem.

Also included is a keymap file for XBMC. This keymap only works for Wiimote 1, but you can easily see how to extend it to work for other Wiimotes. It's based off the wiimote keymapping included with XBMC, and after using it for a bit, it seems to be a very good keymap.

Why this?
This solution allows the wiimotes to be shared between different applications in linux very easily. The downside of the current solution, the wiimote eventclient, is that XBMC steals the wiimote and won't let any other application use it. I wanted a way to keep wiimotes connected whilst switching applications. This means I can connect a wiimote, browse for the game I want to play in XBMC, and play the game without having to do anything goofy with the wiimote! Depending on the emulator, you might even be able to map the home button to the "exit" function, to allow the wiimote to be the only controller you need for XBMC and gaming!

Requirements
Java compiler/interpreter -- sudo apt-get install openjdk-6-jdk
gcc -- sudo apt-get install build-essential
libsuinput:
Code:
sudo add-apt-repository ppa:tuos/codegrove
sudo apt-get update
sudo apt-get install libsuinput-dev
This archive: http://truejournals.com/wiimote.tar.gz

How to Install
Inside the archive, you'll find a file, wiimotes.conf, and a folder, wiimotes-java
First, put the wiimotes-java folder somewhere on your drive. It could be anywhere, really. Mine's in my home folder.
Next, modify the last line of wiimotes.conf to reflect the path to your wiimotes-java folder.
Finally, open a terminal, cd to wiimotes-java, and run:
Code:
./build.sh
This should compile everything needed. If you want to do a quick test, run:
Code:
./run.sh
and make sure it runs! The next time your computer boots up, it will start automatically. Simply press 1 and 2 on a wiimote to connect it!
(I realize this is a pain. I'll see if I can perhaps get a repository running on my server to make this a simple apt-get install. If someone wants to/can help with packaging, that would be much appreciated!)

How it works
If anyone is really interested, the source code is all there! Basically, the main part of the code that handles the wiimotes is written in Java. There's then a small library, libUInput, that is called via the Java Native Interface, and sends commands to UInput to simulate the joystick.

The source code is there, so feel free to modify and redistribute! I do ask that you credit me if you redistribute it -- a link to this post, or my website (http://truejournals.com) is fine! Hope it works for everyone! If anyone has any issues installing, etc, post here and I'll try to help!
Reply
#2
This is amazing!!!! This may be too much to ask, but is there any possibility of porting this to Windows? I am having so much trouble syncing my Wiimote in a HTPC setup
Personally Created Stock Footage and Animated Videos for Backgrounds or Screensavers
100+ video files can all be found on my blog: Beachfront B-Roll. All are free.
The clips are a simple "Right click, save" and there is no signup or registering required either.
Reply
#3
It doesn't work for me

In file included from UInput.c:6:
UInput.h:2: fatal error: jni.h: No such file or directory
compilation terminated.
javac: file not found: AdvancedDiscovery.java
Usage: javac <options> <source files>
use -help for a list of possible options
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] Wiimote Daemon for XBMC, Emulators, etc.0