WIIMOTE LIB 2010 Release

Blitz3D Forums/Blitz3D Userlibs/WIIMOTE LIB 2010 Release

Charrua(Posted 2010) [#1]
First English release.

New features:

I rewrite many parts of the lib to support multiple wiimotes.

Almost no global variables needed.

All function names start with: "wii_" and so for the globals.

Function Names now are in english and most comments too.

The lib includes an introduction/doc about the wiimote/lib

I'm testing the use of Threads to read the wii, with success if you don't enable debug.

Take a look: http://sites.google.com/site/odriozolajuanignacio/wii.zip

Kind Regards

Juan


Blitzplotter(Posted 2010) [#2]
Looks interesting Charrua, will have a delve in tomorrow.


ZJP(Posted 2010) [#3]
Hi,

Good work. Speed and accuracy ..

JP


Panno(Posted 2010) [#4]
thx


Charrua(Posted 2010) [#5]
if you test/use it, plese send me comments about easy of use, bugs and the like.

thank's

Juan


Blitzplotter(Posted 2010) [#6]
Charrua,

I do not have the hardware to interface my Wii mote to the computer(yet) however I thought I'd try compiling it. Initially upon compiling the exsample functionpointer could not be found - so I uncommented the functionpointer within the lib file (which appeared to be empty anyway) but this did not resolve the functionpointer cannot be found compile error.

So I uncommented the other three functions (which were also empty) if you do not have fast lib - however the createthread function was passing too many params - seeing as the empty createthread function expects no params its not surprising.

Help?


Charrua(Posted 2010) [#7]
thank's my bad, if you don't use threads or don't have FastPointer the idea is to have declared the funtions FastPointer dll has in it, so the Bla function not found don't appear. The empty funtions are just for that.

the correct declaration should be:

;Function CreateThread (FunctionPointer, Value)
;End Function

;Function FunctionPointer()
;End Function

;Function IsThread(Thread)
; Return False
;End Function

;Function FreeThread(Thread)
;End Function

if you donīt have the hardware, the example simply says: "no wiimote detected" waits 2 seconds and end!, not too much, im sorry

hope you will sonn have a wiimote to play with.


Juan


Charrua(Posted 2010) [#8]
i asume that if you donīt have FastPointer lib (a free one) is because you choose not to use threads. For that reason i wrote (wrong but correct them thank's to you) empty functions just to not change the rest of the lib.

in brief, without FastPointer threads could not be used. Recently ZJP launch a thread functionality for blitz:

http://blitzbasic.com/Community/posts.php?topic=84325

i didn't test this one yet, but i think it should work like the other.

Juan


ZJP(Posted 2010) [#9]
Hi,
Rewrite the Wiimote library in FreeBasic (or PureBsic) would be a good thing. I thought to make a dll, but no time. ;)

JP


Charrua(Posted 2010) [#10]
time?
and skills, i do what i can, i have no formal programming studies, each new thing takes me a lot of effort, but, i still have intentions to go on.

i'm not a gamer neither a programmer, so many of the topics, words and terminology are completely new for me, but, on the other way, lot of fun!

Juan


Blitzplotter(Posted 2010) [#11]
@Charrua,

I am impressed with what you have accomplished already within Blitz3D, and I have No preference towards Free or Pure basic for that matter.

Thanks for the feedback, I may now check out the list of components you recommend for making an IR receiver for the PC to interface my Wii mote.

I'm impressed you manage to create both interface code for a Wii-mote and the 3D path code with beziers and stuff... you sir are most definitely a programmer in my book.


Charrua(Posted 2010) [#12]
thank's for your comments.

see: http://en.wikipedia.org/wiki/Bluetooth

in this article, there are some pictures of BlueTooth Adapters (dongles) required to connect the wiimote to the pc (if in didn's has one already instaled)

have you already make a connection with your wiimote?

i'm particulary interested in the detection phase. It gave me more headaches than the rest. My first verison works on XP but not in vista. I tested this second version on vista and indirectly on xp runing a VMWare virtual machine on my Vista Laptop with success. I hope the detection phase and the rest work for you.

Juan


Blitzplotter(Posted 2010) [#13]
Hmm, never dipped my toe into the murky depths of Vista - I've got an XP & a W7 machine, & this certainly intrigues me - might be a little while before I manage to get the necessary hardware, I might treat myself at the start of May.

Thanks for the extra link Charrua.


ZJP(Posted 2010) [#14]
I am impressed too ;)

JP


Blitzplotter(Posted 2010) [#15]
Like this:-

http://en.wikipedia.org/wiki/Bluetooth#Bluetooth_devices

Excuse my ignorance, I thought the Wii mote was an infrared device...?

Maybe not though:-

http://www.wiiprojects.org/bluetooth.html

then again:-

http://www.instructables.com/id/Low-Cost-Multi-touch-Whiteboard-using-the-Wii-Remo/


xlsior(Posted 2010) [#16]
Excuse my ignorance, I thought the Wii mote was an infrared device...?


It uses infrared leds in the sensorbar to sense its position, but it uses bluetooth to communicate that information back to the console


Charrua(Posted 2010) [#17]
we don't need to have a nintendo wii, it includes one wiimote, so if you or your children has one, good. But the wiimote is sold separately just because many of them may be used with one console. I don't have a nintendo wii console, i just have a wiimote. We are lucky that the desigers uses a standar protocol: bluetooth for the wireles comunication, so, it would be seen by any bluetoot capable device, the only thing is to know the protocol and presto!

The system sees it as a BlueTooth Joystick.

Like a Joystick, has buttons, but also accelerometers and an infra red camera with software that keeps track of 4 ir points sending us its x,y coordinates. The values sent are in the range 0..1023 for x and 0..767 for y, but the real camera inside the wiimote is 128x96 pixels..

There are a lot of applications not for the wiimote buttons!. Buttons are everywhere: keyboards, joystikcs and the like, the good part of the wiimote are the new capabilities: accelerometers and ir points seen by it's camera. With few additional hardware (some ir leds, resistors and a voltage source) many new things could be made.

the lib i wrote (and any all over the planet, normally written in C) speaks with windows and ask for a list of devices, then scan the list looking for Bluetooth joystics and then search the vendor id and product id of the wiimote. All wiimotes instaled then are listed, Having the Names windows uses to hadle them, the lib open a file to write (send info to the device) and other file to read (status from the input device) for each wiimote detected.

knowing the fields of the protocol and some other info posted for good people on the web we can read each piece of information from the wiimote.
And finally read the individual values: button state, acceleromter value, x,y coords of an ir source and the like simply reading fields on a BlitzType object.

As an example, placing 4 ir leds one on each corner of the screen, and reading the coord the wiimote sees, then we can calculate the exact point in the screen seen by the wiimote (center of the camera view: 512,384)
and use this for our weapon. The whiteboard demo of johny lee has the math's involved, Warp is called inside the c source published a couple of years ago.


Juan


Blitzplotter(Posted 2010) [#18]
@Charrua, thankyou for the extra info, it all helps....


FiNegirO(Posted 2010) [#19]
Great piece of code Charrua!
Yhanks very much!
finegiro


Charrua(Posted 2010) [#20]
thank's
if you use it, pleas send me some feedback about it

Juan


nanahuatzin(Posted 2010) [#21]
here i am using this code for this:

http://www.youtube.com/watch?v=2sL17b6pP-Q

The first part is flash, i am using blitz to read the wiimote and emulate the mouse.

The second part, it is done in blitz3D.

I am using the ideas from the Lee hacks, you will see in the lower part of the screen a dark squeare where i put the IR led and the wii.

It is very fun to use. I am working to use the two hands.. aka minority report...

The system is sensible to hot lamps, but with a little efort, you can program to ignore some sources


Charrua(Posted 2010) [#22]
man!

congratulations, i'm glat to see your work

(shoud it be posted in the Blitz ShowCase, isn't it?)

the first one is you?

Juan


nanahuatzin(Posted 2010) [#23]
yes.. i am... :)

i have more ideas to use it... glad you like it. Maybe a chea motion capture system.. that would be fun.

Javier Delgado


wmaass(Posted 2010) [#24]
Anyone have trouble getting the example to work? I can connect my wiimote and it works with other programs on my PC, just not WiiMoteLib. I always get "No wiimote detected". I tried on Windows 7 and XP. The axe.wiimote mod for Bmax works for me.

Last edited 2010


Charrua(Posted 2010) [#25]
hi

the 2010 edition has some changes to make it work under vista.
try the original version i made for XP:
http://blitzbasic.com/Community/posts.php?topic=78384#966619

hope it works for you

Juan


wmaass(Posted 2010) [#26]
I'll check that out, thanks for the tip.

UPDATE: It works!

Last edited 2010


Charrua(Posted 2010) [#27]
i'm glad to hear it!

enjoy

Juan


wmaass(Posted 2010) [#28]
Something strange in that the sample app does not find a Wiimote unless I first run something like the Wiiyourself demo or Desktop VR. If I run one of those demos first the bb demo works fine.


Charrua(Posted 2010) [#29]
the detection phase is what i found problematic.

basically i do some api calls to get from the OS a filename wich is used to open a file for write and another for read. Basically the OS sees the wiimote as a Stream or some thing similar.

once you have this "filename" no matter wich detection metod you did, the rest of the lib works ok.

if you want to use the 2010 edition, you can use the DevicePathName$ obtained in the old version, look at the function ObtenerHID()
this filename could be used as a parameter for wii_Connect


Juan


wmaass(Posted 2010) [#30]
Thanks Charrua.

By the way I had a very similair problem with the axe.wiiyourself mod for BMax and it had to do with the version on BMax I was using. > 1.39 does not detect Wiimote.