Wii remote control

Okay, so I’m trying to look at coding some bluetooth-related stuff, and there’s a lot of stuff about using sockets to communicate (in the windows API stuff). Now, never having used sockets, I’m not quite sure what it’s going to involve, but I’m wondering if the Juce sockets are going to be enough?

I’d be very surprised if they were! But I thought I’d ask all the same. Has anyone else done anything with Bluetooth yet? I’m sure I’ll figure out some kind of wrapping of the windows API to a juce-friendly form [i’ve already managed that with Joystick and Tablet support, i see no problems with bluetooth] but was curious as to what people have done so far.

I’ve no idea at all how bluetooth works, but sockets are pretty straightforward beasties - you open them and squirt data in and out of them, so there’s a good chance that the juce wrapper would do the job just fine. If you do hit something that it can’t handle, we can always add it, of course.

Well, trying to see what can be done using what’s already in place WRT sockets in juce, i’ve discovered at least the following:

The MSDN section on using sockets for bluetooth has the following information:

The juce socket function ‘connect’ has the following line:

    handle = (int) socket (AF_INET, SOCK_STREAM, 0);

For a bluetooth socket, this line would need changing. I’m going to try my hand at hacking these juce socket files to get a working bluetooth socket, (to wrap into a more friendly ‘BluetoothDevice’ class) but it’d be nice if there were a way to specify the address family and protocol options in the socket class.

Looks like i may not need to bother, actually. As cool as it would be to make a neat Bluetooth wrapping set, i only personally have one use for it - so i’m not fully motivated to create one. What i’m doing is making a class set for a Nintendo Wii remote. I’ve managed to stumble upon some nice looking code to wrap into what i need (although it does require the Windows DDK).

If anyone is interested in this, let me know! I’ll post the code for it (should i find somewhere to host it - may sort out my webhosting today actually) when it’s usable. Hopefully it should be a nice simple WiiRemote type you can just create and listen to. This should give a fun way of getting input from the user, and would only require a bluetooth adapter along with a Wii remote (no Wii required naturally).

And in case you somehow don’t know what a Wii remote is… it’s the controller for the Nintendo Wii, which has various motion sensing capabilities along with a stack of buttons [and a little speaker and some LEDs] and a little IR tracker that is used for pointing. It could be used as a general purpose remote control (mapping the buttons to actions), a pointer (when there is an simple infra-red emitter - even a candle - placed near your screen), or some other motion-based input device.

Granted, it may not turn out to be remarkably useful, but it should be a bit of fun anyway. :wink:

Sounds like a cool toy! I’ve not got a wii but thought about trying to make a theremin out of one…

I don’t have a Wii either, but I do have a Wiimote. This thing is fun to program for. Just for common use I have it control my house audio from anywhere within about 40 meters (my bluetooth adapter is cheap). I even use the motion sensor for things, to change volume hold a button and move it up/right or down/left (it doesn’t have many buttons so reducing volume to one button is nice).

yeah, lots of fun possibilities.

I’ve been playing with GlovePIE, and it’s really a very very neat piece of software. It’s a bit fiddlesome though mapping controls, what with having to create scripts (the GUI feature is very handy but doesn’t help with complex setups). I’d like to make something similar, but designed specifically for the WiiMote, offering simpler ways of mapping functions to buttons/motions.

On top of that, it’d be fun to have a different kind of musical app.

For example, a plugin could read two remotes (or a remote and a nunchuck) and respond to their movements as if they were mallets acting upon a virtual tonal purcussion instrument (e.g. a glockenspiel), ‘beating’ virtual bars to create MIDI note data. Scales could be set and switched using the buttons on the remote, which would restrict the notes present to play with, and an on-screen representation of the mallet positions over the bars could respond lightly to left/right motion.

Or, motions of a remote could be mapped to filter parameters to modulate a sound via 3D movements.

There are lots of exciting possibilities, so it’d be nice to have a little class to wrap them up for any juce program to use.

well i’ve got a system working that lets me read the buttons and axis orientation of the remote. nice! :slight_smile:

so far i just have a test panel that shows sliders for the 3 axes of orientation. i guess one simple application would control 3 CCs depending on how you hold it. i need to put in a nice way of smoothing the data so that it’s not so jittery, but it’s receiving fine :slight_smile:

Nice one. Would love to see what sort of code is involved in interfacing with this beastie.

conveniently, most of it was already done thanks to a guy named Kevin Forbes, who wrote a class called ‘cWiiMote’ and kindly put it into the public domain. I don’t like how some of it is written though so i’ve changed quite a big chunk of it, but the low level stuff of connecting to the device is largely untouched.

Sadly i’ve got no webspace to bung an example up :frowning: but i’m not totally happy with it yet anyway. On a lighter note though, my new PC arrives on friday!!! :PARTY: [although i’m working all day so i need to figure out how i’m going to get out of that one]

Hi there,

Haydxn, are you still working on this ?
Did you finally use cWiiMote ? does it work for other platforms than windows ? is it possible to see your code ?

In the mac you can talk to the WiiMote with the DarwiinRemote Framework:

On the PC a.o. WiinRemote

It would be superb to have all this wrapped in Juce! :smiley:

WiiJuce is here!: