linux wii remote :: help me help you

hey everyone

ok so I made this app that can connect to your wii remote, it’s not very fancy. there is nothing even in the draw portion of the code because nothing IS drawn. It is also mega important to note that this is built using Ubuntu. So unless you want the Cwiid code, then i don’t think there’s anything here for you.

it only allows you to use the wii remote as a wireless joystick for 2/3 button games (atleast, that’s the idea with which i built the app with). you will see it’s not very hard to modify any portion of the code to fit your needs so you may end up using this code anyway

there are many features i wanted to implement/bugs i wanted to fix right now but i’ve been on and off on this for 2 weeks and i want to stop and take a break and see what people here have to say

If you want to just give it a try, then I invite you to take/download the source folder and dump it in your openframeworks version 0.05 apps examples folder:
http://www.procrastinatorstangent.com/r-…-d2.tar.bz2

from there read the README and it has instructions as well as packages to get.

If you want to read a bit more here before playing around my terribad code, then please read on and please feel free to contribute code/solutions to my problem:

the biggest problem you will notice is that this has to run as root. when you’re done shuddering in disgust, you can go to the next paragraph.

The reason why you have to sudo the app is because i could not get the cwiid_get_mesg function to work.
http://abstrakraft.org/cwiid/wiki/libcw-…-d-get-mesg

so in order to go around this i decided to parse the hcidump -x, which is the bluetooth data dump of a system, to decipher which keys were being pressed when.

This first “workaround” bring about a world of hurt. first, i don’t think the app works if you remove the accelerometer flag or the infra red camera flag. What those flags do is turn those features on in the wii remote (the IR flag also turns on the accelerometer, you can’t have the IR with the accl.) having those features turned on make the wii remote send a signal many many times a second to the computer about it’s state. and without this refresh of state, your draw function does not progress - no i’m not kidding - the app is only as fast as hcidump -x is.

This is probably the biggest problem and anyone who can share insight on how to use the get_mesg function from cwiid correctly, please, share on.

the 2nd problem is not being able to auto connect to a wiimote. this isn’t so much a bug as it is a feature i want to make. I don’t forsee problems building this, it’s just i don’t want it to attempt to connect to any bluetooth address and i don’t want to spend time reading the bluez dev doc right at this moment, but it’s certainly something i can do later. or you know, you can help =]

3rd problem, and really a something i didn’t implement - players. the ability to have several wiimotes connected at once. why not? the hcidump returns a handle: XX with 2 numbers, that corresponds to that wiimote’s unique Id. it’s something i could do but takes a lot of time and not quite worth it yet given the quality of the app.

4th problem is really linked to the first that the get_mesg workaround is making the app slow and not as responsive as i think it could be. playing an NES game through my emulator to test it out, i would describe is as being, at best an awkward controller. sometimes you actually need to release a D-pad direction and press it again for it to register correctly.

anyway, the list goes on and on, but i guess you get the idea.

now you may not like my app, but it’s what i’ve built so if you don’t want to help finish it then please don’t complain about it :frowning: it really only passes as “good enough” at this stage.

if you want to see how the buttons on the wii remote affect the hcidump you should try typing:
sudo hcidump -x

while the app is running to see what each button press does to which bit of data. how the accelerometer data is measured in the dump, etc.

there’s also a lot of documentation on this wiki, stuff your face there if you prefer:
http://www.wiili.org/index.php/Main-Page

oh, and consider the code GPL

try it and tell me what you think :stuck_out_tongue:
thx
ramy

EDIT: PS: i know you must be thinking, why would i build this kind of app inside openframeworks? well it was good motivation to build it as joystick and i am also working on other projects in of_. To me, getting this done allows me to pick up the wii remote and say “i want to use this to make the screen change colour” and within the half hour it’s done, compiled, and running. I hope some of you get to do that too

yay,

wii remote acts like a true controller now. responsiveness is fixed.

still need to run as root though
still need to compile the bluetooth address
still nothing drawn in the app itself, but it’s snazzy as it is and the code is simple enough to do with what ever. The responsiveness is so good, I know i’ll be using it for a project later on.

any further updates will be on my site:

http://www.procrastinatorstangent.com/r-…-v3.tar.bz2