Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Wiimote DLL request

Author
Message
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd May 2008 11:06
I know, it has been requested before, but could one of our DLL experts create a Wiimote DLL for DBPro?

Here's some of my homework that I have done so far:

This was a good attempt at getting the Wiimote to work for DBPro. And it works for what it is supposed to do (I tested it), but was never finished. It is probably a very good starting point.

http://forum.thegamecreators.com/?m=forum_view&t=98263&b=2

Here's a great site that describes the data feed, or 'report,' from the Wiimote, as well as some source code to play with.

http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx

And last, but not least, my inspiration for this request; Johnny Lee's work. It has been posted several times before in these forums, but I figure the least I can do is save folks the time of searching for these:

http://www.cs.cmu.edu/~johnny/projects/wii/

http://www.ted.com/talks/view/id/245


Open MMORPG: It's your game!
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 2nd May 2008 16:04
Those all use .NET/managed code, and turn right around and use PInvoke, and standard Windows Bluetooth Sockets. I take a more direct approach which is much simpler in the long run. (No DLLs to redistribute along with the plug-in, for one thing.)

I have a class already done for normal sockets, but I am still putting Bluetooth support in. I don't have a Bluetooth receiver, but I do have the wireless XBox360 receiver. I think it may be Bluetooth, as well.

I agree about Johnny Lee's work, I really like the whiteboard concept alot. There are some other applications in 3D that I think would benefit from the WiiMote as an input device. They use the arcball control type well, I think.

Hopefully, I can get my hands on a receiver and a WiiMote, but I can actually write it in the blind, if you are willing to test it. I don't think this is a particularly difficult task for C++.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd May 2008 17:54
Thanks jinzai. I am certainly willing to test.


Open MMORPG: It's your game!
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 6th May 2008 17:34 Edited at: 6th May 2008 17:54
Okay, here is something that can find an HID that is present already on a system. I can only verify that it can find my XBox360 controller...if it is already active. It cannot find it if it is not connected. This is a result of how I am writing the code for now.

The zip file includes a small user plug-in that contains only 6 functions, and only 5 of them do anything at all:
integer = initialize winsock()
integer = bluetooth device selector()
integer = enumerate HID devices()
string = HID device name(devicenumber as integer)
integer = find HID device(vendorID as dword, productID as dword)
dword = create bluetooth HID stream() DOES NOTHING!

The project contains enough code to attempt to find a WiiMote, as long as the WiiMote is connected to the receiver...I think the code will find it.

The bluetooth device selector is a common dialog, straight from Windows...a single function call. I am curious about what your dialog says...mine can't find any...because I don't have any. It does allow me to search repeatedly, a nice touch.

I am hoping that it finds your WiiMote using the method in the HID devices project. I followed very nearly the same procedure that was used in the link you provided, except I just use naked Windows calls. (That's what I am going to call it, anyway...no .NET)

Its odd, but I had to find the Windows Driver Developer Kit, which was difficult to find. Then, I had to burn the iso image to CDRW and install...just to get the proper include files and lib files. I think I got it just in time. (No, there is no pun there. You have to pay to get the latest version of the DDK!)

The real hoot is that the plug-in will be very small when its done, and I think it will (eventually) work much better than the ones I've seen so far. Also, this plug-in will be used to communicate with other HIDs and other Bluetooth devices.

To use, download the zip to your DBPro directory, and unzip there. It will install the plug-in, and create a project directory called "HID devices". That project has the relevant calls for searching for the WiiMote.

Attachments

Login to view attachments
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 7th May 2008 05:26
I gave it a try and it seems to work, but crashes. I am running Vista 64, so that might be my problem. The problem line is this one:

Quote: "devpaths() = HID device name(i)"


After some playing with the code, I am guessing this is a Vista problem where null strings cause a problem with DBPro... assuming the HID device name() is returning a null string since it runs through the first pass of the for/next loop just fine.


Open MMORPG: It's your game!
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 7th May 2008 05:40
Well, I was hoping it wouldn't crash, but...I am not surprised or anything like that. As long as it said Device found, it found your WiiMote. Otherwise, it just gives a message box with the PID and VID of the devices it finds while looking for the WiiMote.

I should have cautioned you that I never delete the list, so you can't call enumerate HID devices() more than once per execution.

I am going to rewrite it a bit tonight to fix that, and also I think I will make the WiiMote specific part:
find first WiiMote()
find next WiiMote()
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 14:58 Edited at: 9th May 2008 15:00
I've been as dumb as Fry, Rii.
I was trying to use my XBox 360 controller and simple read and write, but I had a parameter wrong, so I started searching the net for HID code for the XBox360 controller. There isn't any for mine!

So, I decided to use these remote controls for PCs that my roommate has, except I couldn't find any AAA batteries.

Okay, so what about my other wireless controller? (No batteries!)

I finally found a wired controller here, and it works!

Some things about HID that I've learned:
Everytime you plug an HID into a different USB port...you get a new device installed. That's not really an issue, except that I have 32 phantom USB HID devices in there from various places. Fortunately, there is a flag that is used to detect only connected devices.

I've read alot about using the WiiMote in various ways, almost all of them use .NET, which I do not use. (Its more that I use VS2003, and my .NET Framework 1.1 is just a mess.) The main thing about most of the ways people are using them is that you cannot connect more than one at a time, and there is no provision for opening one up during execution. I can't abide either restriction!

So, now that I can actually talk to the device...I am going to shore up my code to accomodate those situations, and also I am going to include the code necessary to install and remove HID devices. I think that I will find that some of those devices are my flash drive on the three USB ports I have. (Also, I did an experiment in January where I had the entire RockBand setup connected, with a wireless PC joystick, and also this converter with PS/2 and GameCube controllers connected!)

Although HID is supposed to be a standard, it is only standard to a very limited extent in its implementation. There is a device discovery process that is supposed to allow you to get enough information to utilize an HID, but the implementation of that is very spotty. Apparently, however...Nintendo has done a pretty decent job with the Wii. Most of what I have read (Which is currently supported by my tests, although I'm not done testing.) indicates that Microsoft has not been as good as Nintendo. In their defense, the XBox 360 controller is easy to get to with XInput, even with DBPro and load dll...it works great. (Hardly fair, though...HID is not supposed to be that way.)

I think your trouble was related to the DBPro side, and not the DLL. The error is mine, and not DBPro. That null string thing is what causes it. My for loop was wrong!

I changed it on my side, and as long as I get 4 good hours in today, I can post up a version that will allow you to talk to the WiiMote using the report format with Read/WriteFile. I have an idea that will take some time to implement that will make the data appear in a memblock at a predetermined rate with no intervention on the programmer's part after setting it up.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 9th May 2008 18:15
Sounds like a lot of progress jinzai! I certainly wouldn't mind a bit of work on the DBPro coding side. On the other hand, the more user-friendly you can make this, the more folks will likely want to use it. I am looking forward to that update


Open MMORPG: It's your game!
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 9th May 2008 20:14 Edited at: 9th May 2008 20:16
You do realize that the Xbox 360 doesn't use Bluetooth, but rather Microsoft's own bit of the 2.4gHz frequency, right?

Also, if I'm reading
Quote: "Read/WriteFile"
correctly, you're going to be writing a file every time the controller sends out an update? That's guaranteed to destroy flash disks and wear out hard drives.


I fail at life. No, really.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 20:24 Edited at: 9th May 2008 20:40
Bluetooth has nothing to do with this at this point. I am using the HID interface...after Bluetooth. I am able to open the controller fine. You are right, however. XBox 360 does not use Bluetooth. I have Bluetooth in there for other purposes...mostly because the WiiMote uses it, but also so I can connect to my Razr, and other Bluetooth devices.

I don't have Bluetooth, or a WiiMote, but I am trying to write this so RiiDii can use it with his WiiMote, so I need to use some HID device to get the code working. It has already found the WiiMote, now I am going to get the reports, and send them, too.

ReadFile and WriteFile work on handles. You can use them for pipes and devices, and you must use them for comm ports for example. There is no disk I/O involved at all.

It works fine, and this is the correct way to do it. No worries.
Omega gamer 89
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: Pittsburgh, PA
Posted: 9th May 2008 22:38 Edited at: 9th May 2008 22:39
Try this:

http://www.youtube.com/watch?v=2KtFVlUaMRA

its not a DLL or anything, but it works. My friend has been messing around with it.

...but I am the ferret king!!!! BWAHAHAHAHAHAHA!!!! tremble before my ferret minions!

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th May 2008 10:04 Edited at: 10th May 2008 10:59
Well, that's cute. I always enjoy watching people literally hacking with razor blades like that. That kid needs to get some tools that he didn't steal out of the kitchen drawer. The payoff was a little anti-climactic. I still like the guy playing Half-Life better.

I have to imagine that RiiDii will come up with something better, too.

Here is a better version of the code and plug-in. Same drill as before; it will overwrite. I did change the name of the function HID device name, since it is really the device path. I have a window that is invisible and a window that only handles messages in there, too. The intent of the invisible window is a terminal window, which is very useful when developing and troubleshooting external device communications. I also use it to output things from the plug-in sometimes. The sample program display is somewhat like what I mean. The message only window is helpful when using sockets, and in using modeless dialogs.

I have exposed the first few items in the device discovery process I mentioned earlier. They are all strings.

Here's hoping this behaves better. It hiccups twice with the xbox360 controller, but then it reads the data just fine. It also reads the AxisPad Colors controller that I used it with.


EDIT : updated zip attached.

Attachments

Login to view attachments
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 10th May 2008 20:02
I gave it a run and, after finding the Wiimote, it printed out a few things, then crashed. Then when I ran it again, I believe it finds the Wiimote, then crashed immediately - without printing anything. I disconnected and reconnected the Wiimote, but that didn't get the printout back.

I will play with it some more later this evening.


Open MMORPG: It's your game!
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 12th May 2008 08:15 Edited at: 12th May 2008 12:29
I'm sorry about that one...I was being very methodical about exposing things that returned strings, and that did not have to use any sort of overlapped I/O. BUT, I was not returning them properly. They worked fine on my machine without calling CreateDeleteString. I'm not sure if that was the issue, however. (I have it fixed in this version.)

The other thing about the functions that return strings (except get HID device path) is that they call the driver of the device that is open directly. If they are the source of the crash, it might mean that I need to implement a Vista driver model, and might explain the difficulty I had in finding the XP (WDM) Driver Developer Kit. I hope that is not the case, however.

If you still get crashes, you might try commenting out the functions that get the vendor, product and serial number because the get report function uses ReadFile, and does not call the driver directly. If that is still failing, that is not so bad, because there is ReadFileEx available to do the job, and I think it would work where ReadFile might not. In that case, it just means that I have to implement the other things I told you about before to get even a simple interface going, but I was going to do that already, so....

EDIT: Now that I've thought about it a little more, I would not be surprised if the problem is related to the calling of the driver because there really is no driver for your Wiimote, but there is for my XBox 360 controller. That might also be significant.

One question: What is the brand/model of your Bluetooth receiver?

Attachments

Login to view attachments
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 12th May 2008 18:10
I'm going to give this a run on my XP system and see if I get the same results (I had loaned it to a friend for a while, but have it back now).

Quote: "What is the brand/model of your Bluetooth receiver?"

The package says "Cables Unlimited" and the system says ITV Corp. The package also refers to www.cablesunlimted.com.

I ran it in step mode and it crashed on this line:
Quote: "tempstr = get HID device path(i)"

on the second pass, where i=1.

So I changed the line
Quote: "For i = 0 to 0"


Then it crashed on this line:
Quote: "mfgstr = get HID device manufacturer str(device)"


Then I remmed out the manufacturer lines as indicated, and it crashed on this line:

Quote: "text 10, 10, str$(j) + "/" + str$(device)"


It did run through the previous section of lines Where Device>=0

Running off to work now, so other tests will have to be when I get back.


Open MMORPG: It's your game!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 21st May 2008 15:49
Any updates on this?


Open MMORPG: It's your game!
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 21st May 2008 16:03
I was waiting to see what your results were when running on XP, since the DLL works fine on my machine using the controllers I have checked, and I don't have Vista, or a Wiimote. Also, I was somewhat disappointed at the large number of views with noone else trying it out.

I'd certainly like to move this forward, too...especially since the WiiFit is now out...there would be a nice market for games and apps that were able to make use of this plug-in.

I have been working on another plug-in too, but...I will research it more rigorously today. I'll post something up in the next day, or so.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 22nd May 2008 08:11
Sorry about not following up on the XP tests. My XP machine was recently restored and, being lazy about it, I haven't updated it to the latest Window's updates since it won't connect wirelessly to the internet without the updates (I have to plug it in ). Anyway - it's really me being lazy.

Quote: "Also, I was somewhat disappointed at the large number of views with no one else trying it out."

I agree.


Open MMORPG: It's your game!
Final Epsilon
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: CA, USA
Posted: 25th May 2008 02:44
I'd be willing to help test the plugin, although i'm not terribly good with managing hardware input/output.

So, if someone posts code for me to run, I wouldn't mind trying it out.

I'm running Vista 32-bit on a Lenovo T60 with an internal bluetooth radio, and I have two wiimote controllers with which to test.

Cheers.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 25th May 2008 22:00
@Final Epsilon - That's great news, glad to have you aboard on this. There are downloads attached to my posts above with the files you need.

I was hoping that someone with XP would try it because I am anxious to confirm my suspicion that Vista is not currently retaining good backward compatibility with the Windows Driver Model (WDM) that was introduced in 98/NT, and has been the birthplace of the generic Human Input Device interface. It is supported by DirectX, as well and also DBP through the control devices and joystick commands. The downside to this is that it only supports one format for the information, which is an older controller model, and doesn't support all of the functions of modern controllers.

For starters, could you see if DBPro can see the Wiimote when it is connected? This code might be able to produce the name Nintendo RVL-CNT-01, which the plug-in I posted before attempts to do. If that is the case, there may be an alternative path to the Wiimote through DirectInput, which might mask this difference better. (It might also be possible that is in DirectX 10, but I hope not because that eliminates DirectInput as an adequate solution.)




What I am doing now is researching the newer Windows Driver Template model, but the documentation is scant, and this is looking like a major issue for Vista in general. Unfortunately, VisualStudio 2008 Express and the .NET framework just don't work well at all on my machine, which is absolutely ancient at this point.

I can find some documentation about writing device drivers using WDT that are compatible with XP and Vista, I just need to find the implementation of WDT in library files. As I already mentioned, Microsoft is distributing the newer Device Driver SDKs by its subscription development service, MSDN. That's a pretty sweet deal, except that I don't have $2500+/yr to throw at it. I am an MSDN member, but only by virtue of owning MS development products. I might be able to find it somehow; its like MS to make it hard to find...its not like them to make it impossible to obtain at all.
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th May 2008 00:05
It usually sees a blank HID called "Bluetooth HID device".


I fail at life. No, really.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 26th May 2008 03:19 Edited at: 26th May 2008 04:35
Okay, that's a start at least. Now, that is why I was on about Bluetooth before, and also why I put in that function to select the Bluetooth device in the plug-in...the dialog should be able to see something there, as well. It may be that we can only see the radio, and an unknown device beyond that. (Which may be a Wiimote, Bluetooth phone...anything, really.) Then, it might be best to approach it from the Bluetooth socket angle.

So, then...what happens when you try to use it? Do the normal joystick commands return any information at all? If that's the case, we can probably get at the Wiimote in a much simpler manner.

Here is a function that will control a camera with the joystick interface. Anyone care to try that with the Wiimote after selecting it as an input device?



Actually, here is a little program to allow you to test any device that might be connected. Please let's test it on some things and see what information the standard HID interface will return with Wiimotes, and other devices. The XBox360 wireless controller works with this scheme, and if the Wiimote returns anything, then we can get this going much more quickly.

NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th May 2008 22:37 Edited at: 26th May 2008 22:38
I've already said it's blank.



I fail at life. No, really.

Attachments

Login to view attachments
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 26th May 2008 23:47
I sense frustration, but lucky for us I'm not as stoopit as I appear to be. Assuming that you ran the code, and those dialogs were a response to that...

The Wiimote is installed as a game controller, but it is not configured because you don't have a driver from Nintendo. You should be able to install it either by using the Settings tab in the second dialog and opting for default settings, or by adding a custom controller using the Add button in the first dialog.

The idea is to get DirectInput to accept the Wiimote as a generic HID device. Otherwise, the generic HID code will not work. My controllers are all "not blank"...i.e. they have been installed already, and the XBox360 controller has its own driver, too.
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 27th May 2008 00:49 Edited at: 27th May 2008 00:50
Quote: "Settings tab in the second dialog and opting for default settings"

How can I do that when all of the buttons are greyed out?

Quote: "adding a custom controller using the Add button"

A custom controller called "1Wiimote" shows promise, but refuses to function.

I just sincerely can't see how this is going to achieve anything, and can't see anything wrong with GlovePIE being run by the Dark Basic app myself.


I fail at life. No, really.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 27th May 2008 00:56
Well, I have ferreted you out at least now. Thanks for helping. I never said that there was anything wrong with anything...that's your true agenda speaking there, I think.
Cheers.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 27th May 2008 09:18
I'm still with you here jinzai. After taking the weekend off, I am back. I am still trying to get my XP laptop running nice enough to work with. I can't get the wireless lan to connect, so the laptop is in an odd place to really spend any lengthly amount of time sitting down with it - and remain connected. Still no luck on getting it to work with Vista.


Open MMORPG: It's your game!
Ocho Geek
17
Years of Service
User Offline
Joined: 16th Aug 2007
Location: Manchester, UK
Posted: 27th May 2008 12:54
what if you could get the computer to think its a gamepad? then you could put it in programs like xpadder

just a thought, but then again i dont touch DLLs with a ten foot pole

Ocho

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 27th May 2008 19:19
@Ocho Geek - Yes, that is what I am trying to do, but...not with the notion of creating a wireless Nintendo gamepad! (You know what I mean, I'm sure.) That path that you are mentioning shows a lot of promise...it was MS's intent to allow you to connect anything to that interface, and have it available to applications programs. DX would take care of the details on both ends. That is how DBPro can talk to HIDs...and also why it does not always get all of the information. The DX side is programmable beyond the control set exposed using the control device commands in DBPro. DBPro uses the same interface that other games have used for years now.

I will obtain the hardware and get this going, but when I do...hopefully someone will have the proper models for the DBPro version of "Masters of Teras Kasi" ready. I think they will need bone frame animation, but...I've already used limb animation to control the DMI tank using the XBox360 controller. It is HUGE for gameplay. The Wiimote would have an enormous impact, but only if we can get it going without alot of machinations.

I like the new technology, but personally I have never been able to afford to live on the bleeding edge and being dragged along by MS is not the way to get me there, either. So, I am committed to improving what I already have; and what I feel most folks have, too. Right now, that's DBPro and DX9.0C

Today, I am going to write to DirectInput, and ignore the various Bluetooth interfaces and driver interfaces altogether. I should have new code in a day, or two.
Wilf
Valued Member
18
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 28th May 2008 20:06
jinzai check your email (the @yahoo.com one)
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 4th Jun 2008 13:51 Edited at: 4th Jun 2008 14:09
I've received my hardware, and...the first way I tried works fine with the Wiimote...no crashes, or anything...however,

It is vital that the Wiimote be connected, and that the HID service has been started on your Bluetooth stack...in our case, that's BlueSoleil. BlueSoleil does not have the best reputation in the PC Wiimote world, but...it works fine if you help it out a little.

Refer to this pic, which shows my Wiimote using the HID service:



When I got my radio and installed BlueSoleil, it found my Razr (which was broadcasting...Find Me is the setting I used on the phone.) immediately. Not only that, it negotiated with the phone, and discovered file transfer, dialup networking and object push services. I was able to transfer my phone pictures using BlueSoleil very easily. The Wiimote gets found, but the service discovery fails. I fixed that by holding the 1 + 2 buttons on the Wiimote and clicking on the Wiimote icon in BlueSoleil. It discovered the HID service then. Next, I had to repeat the 1 + 2 while I clicked on the HID service icon (Its a mouse in BlueSoleil.). You will know that it is working when you see a dashed line connecting the Wiimote icon to the Bluetooth device icon in the center. Also, the BlueSoleil Bluetooth icon turns green when the HID service is active. At this point, you can get the same results Nex got when he ran the snippet I posted above...DBPro knows there's a device there, but does not know how to talk to it, because it is not configured and has no easily discernible driver, either.

That is why I chose to use the DDK in the first place. Anyway, I was also successful in getting the HID collection information using DirectInput, so I will continue to develop both sides. I was happy that I did not have to resort to raw Bluetooth sockets, because that is a major difference in Vista and XP. The new Bluetooth API is rich in discovery functions, and has a nice native SDP and L2CAP API, but I can't use them in XP.

So, I will go back to the point where I said that I would get all the reports using the DDK method. There is a similar path in DirectInput, but it is not nearly as simple as the DDK method, which I quite like.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2008 11:43 Edited at: 5th Jun 2008 13:06
Here is an updated DLL and sample application. As always, put it in your DarkBASIC Pro folder, and unzip it. The sample application sets the data reporting format to use report 0x35, which is buttons, accelerometer and 16 bytes from the extension. I am not sure why the extension data is not coming in...I've yet to configure the Wiimote, but I am studying it alot more now that I can talk to it easily. I am going to experiment with the IR camera later today, but I won't need the tea lights, I've got the IR LED bar. btw, here is what I use tea lights for in a pinch:
This is from my Razr camera 0n 02/10/2008


I also want to make the same sort of light pen that Johnny Lee made, it would not be difficult, and probably can be done for ~ $10-20. I think he used an actual dry erase marker, or other plastic tube. I was most impressed with the way he sized that grid, and also the glasses made a very impressive 3D illusion in his demonstration.

To expand the sample code to suit your needs...go to one of the links that explain the reports, and use the method I use just before the start of the main loop to send the output report.

If you nice people would just try this and provide feedback, I would start including help files, and also I will write higher level functions into both sides if that is deemed necessary.

Whether you like the Wii or not, this controller is a brilliant new piece of hardware that has a great deal of potential. I wanted to get one eariler this year, and its too bad that I didn't. I could have used it to try to catch one of the 18 earthquakes we had a few weeks ago. It also has internal memory, although I am not sure if it is of much immediate use.

Finally, I left some code in a large remark block that uses DirectInput to access the Wiimote. I left that on the wayside, but it opens fine for me, although I never tried to get any data with it.

Attachments

Login to view attachments
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 5th Jun 2008 13:14
Quote: "It also has internal memory, although I am not sure if it is of much immediate use."

It only has 4kb, which is a bit pants.


I fail at life. No, really.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2008 13:29 Edited at: 5th Jun 2008 13:31
Yes, and probably it is for the microcontroller in there? I'm not really sure. I was hoping to use it to store data...like recording the accelerometer data for short periods. (Then, if there is any activity...the computer could start recording.)

I can do the same thing using the computer's memory, however. I used to work for a company that makes fault recorders. They work the same way, constantly recording small circular buffers until their triggering algorithm is satisfied, at which point they recorded a record to the hard drive.

Anyway, it is likely for something related to the microprocessor, and to store configuration information. I have noticed lately that you have alot of savvy and experience in that regard. I think that that IR camera is a piece that bears some special consideration. In JL's video, he obviously has got the thing working to satisfaction. He was in a poorly lit auditorium. however.

I had thought to suggest that you install louvers (tape and opaque paper?) on your power LEDs, but...that's a little silly. Although it would probably work.
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 5th Jun 2008 14:21 Edited at: 5th Jun 2008 14:22
The EEPROM inside the Wiimote writes really slowly, and is used by the Mii channel to store Mii characters. I think you can store about 16 characters, can't remember. It's useless as a buffer, because I don't think it's really designed to be that quick and it would likely wear out the memory. I like the sound of your progress, though. I read somewhere that the data returned by expansion controllers needs to be XORed by 0x17 for some reason or something.


I fail at life. No, really.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2008 14:33 Edited at: 5th Jun 2008 14:50
Good point. It is EEPROM, like a flash drive, and writing should be kept to a minumum in order to extend its life. Probably, it is serial, and it might be on the microcontroller, too. I think I will study the MCU in more depth. I also want to get the data sheet for the accelerometer, because the Linux guys seem confused about the LSBs for it, which are also presented in the button data bytes. Its made by Analog Devices, a company I am familiar with. Probably it is the remainder after the last compare, and not simply extra bits to be tacked onto the MSB. The devices in the One-Wire Weather Station thread are similar...you need to crunch the numbers using a vendor supplied algorithm to get the extra accuracy. Now...that is likely the trouble that some people have with the accelerometer data, and the IR camera data, too. I'm going to get the data sheets for all of them later today. It will go a long way in improving the performance over what we have seen already, and it should make the configuration and calibration much easier and more accurate.

Soon, we will see.

Okay, this is VERY interesting. The Bluetooth chip in the Wiimote uses an integrated 8051 microprocessor, and as such...is likely to be very hackable. The 8051 is the most prolific MCU I know of, and it is a breeze to program. I have some 8051 tools somewhere around here.

Also, the EEPROM is separate, but the MCU chip also has its own memory, too. Anyway, its serial EEPROM, and it will be terribly slow. However, it would not be a bad idea to use it to store user calibration data...maybe those Mii files do some of that already. Again, I don't know.

I've got all of the data sheets now, except the camera.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th Jun 2008 15:25 Edited at: 10th Jun 2008 15:34
Okay, here is a new zip file. The DLL has not changed much, but this version is a little more useful than some others I've seen.

To those of you that suddenly cannot connect using various other plug-ins, etc...I think I know your problem, and I am trying to get it sorted. This plug-in has a function to close HID devices, too.

One thing I still lack is the ability to use the read data report properly, so detecting the extension that is plugged in is not yet possible. I will get that going...if you would just help me out with this a little.

I found a very interesting link in the Wiimote Project forums for some templates you can have laser cut from thin plexiglas for making glasses and a frame to mount a second Wiimote above your IR bar for head tracking.
http://www.pixelpartner.de/openKMQen.htm

Right now, I only allow one Wiimote to be connected through the find device function.

I added a project called Wiimote, which will configure a connected Wiimote, and produce some data from report 0x37, which requires an IR bar and that a Nunchuk be connected.

The screen consists of a green cube, and a red cube. The mouse cursor is controlled with the IR camera, and the Nunchuk controls the camera using its motion sensor and the thumb stick. If you get lost, press the C button to return to 0.0, 0.0, 0.0. If you put the mouse cursor on a cube, it will spin. It takes a little coordination, and is by no means complex; it just shows what you can do with the data without needing alot of math.

Some of the functions in the Wiimote project could exist in the plug-in, too.

Next, I will make a 1 player raquetball game, and perhaps WiiTris, or a similar simple game. (I want Rock'em Sock'em Robots.)

Cheers.

Attachments

Login to view attachments
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 13th Jun 2008 21:40
I have duplicated the crashing on Vista, I think...using my XP machine and BlueSoleil 6.0.227.0

Users at the WiimoteProject have also experienced this in Vista. Their fix was to downgrade to BlueSoleil 5.0

My crash was a BSOD crash. BAD_POOL_HEADER

I also had the same result when running the Whiteboard project, so I reinstalled my BlueSoleil that came with my Bluetooth dongle. It is version 2.7.0.13

My plug-in works fine with this, as does the Whiteboard project that uses Brian Peek's original library. I have used my plug-in to verify that the crash occurs in the function that calls the Win32 API function WriteFile.

I am going to investigate this further to attempt to get a workaround figured out.

Would someone that uses a different Bluetooth stack please run the above application? If you have BlueSoleil 5.0 or lower, or maybe another Bluetooth stack entirely?

Seriously...if you have a Wiimote and Bluetooth is it too much to ask one of the 500+ people that have viewed this thread to assist me on this? After all, I am providing code here for free...and I've helped you guys out in the past, and have already provided ImageMagick++ for free, among other things.

I'm getting zero sense of community spirit here, apart from a handful of people.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 21st Jun 2008 00:59
Jinzai, I will give it a try this weekend. Work has been taking its toll on me, so please forgive my lack of involvement.


Open MMORPG: It's your game!
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 21st Jun 2008 02:46
jinzai: If I could help you on this kind of thing I would spend all of my time on it, but unfortunately I can't. Please don't think that I am (rather, we are) not incredibly appreciative of everything you have given us. Its just that most of us either don't have a Wiimote or a Bluetooth dongle to test your dll yet, which is a shame considering the doors which this will open for the community. Thank you for working on this, then giving it away for free when you could easily sell the finished product.
Washington_Irving
21
Years of Service
User Offline
Joined: 1st Jun 2003
Location:
Posted: 21st Jun 2008 06:46
Hey! I stumbled upon this thread last night and have great interest. I bougt the wiimote today and will pick up the bluetooth dongle this weekend to test it out.

p.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 25th Jun 2008 04:30
I had lazik on my right eye on Saturday. I figured I would be able to work on testing this (at least by Sunday), but was sadly mistaken. My sight is even worse now, but it should start improving later this week <crosses fingers>. I also need to find something other than BlueSoleil.


Open MMORPG: It's your game!
Washington_Irving
21
Years of Service
User Offline
Joined: 1st Jun 2003
Location:
Posted: 25th Jun 2008 07:31
Ok, didn't get my bluetooth dongle until monday and after futzing around most of the day I can report that:

I can connect two remotes successfully with the widcomm stack

Blue soleil gives me the bad_pool_header bsod

The wiiyourself demo program works with at least one remote at a time

The wiiuse demos (IR and general) can recognize both remotes simultaneously

jinzai's dll will recognize and report data on one remote at a time. whatever object is created at the beginning of the program flies right off the screen and I cant get it to come back

commands 11,16,13, and 1A are not acknowleged and the rest go by to quickly to report.

I can load the wiiuse dll and init, find and connect to my two remotes from within dark basic.

I need to re-learn everything i forgot about creating dll wrappers.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 25th Jun 2008 10:15
@RiiDii - I hope that is normal, and things will improve in a few days. My eyesight is deteriorating rapidly, and it is frustrating to read. I am at the point where my arms are getting too short to read, and I'm trying to learn kinematics, which looks like Greek to begin with.

BlueSoleiel is both disappointing and encouraging. The older free versions work well in XP, but version 6.0 seems to be a problem for everyone. Version 5.0 has had some good reports, however. The really frustrating part is that BS gives you an inconsistent interface using the normal (Win32 and .NET) methods, while at the same time providing an SDK that is clunky, proprietary, uneven and not free. They have not responded to my enquiries, either. Most discouraging all round. The SDK does not even work with versions prior to 5.0!

I think that it will become increasingly more apparent that a dongle that uses the native Windows Bluetooth stack is the best choice, albeit one that involves more programmer work. It would at least be more consistent. Just look at how much infromation Linux users can get with their CL programs compared to what BlueSoleil provides to Windows.

widcomm won't work on my system, it appears. I think that has to do with the dongle's Bluetooth chip. Mine is from ISSC. They only make two, and one works with widcomm. Apparently, I have the other one.

That snippet was written specifically for a Wiimote with a Nunchuk installed. Sorry about that. The two objects flew off the screen because I did not base the code on time, and you don't have a Nunchuk. Oops. The negative acknowledge is related to the extension check failing. Also, the response for some reports is a little different. I have some updated code in the form of a new plug-in (written from the newer DDK and with VC++ 2005), some Wiimote specific DBPro routines, and a ping-pong game that I am writing to use the accelerometer. I am also writing a simple 3D rigid body physics engine to manage it in DBPro, but right now, all I have is a ping-pong ball that bounces in a way that is almost, but not quite entirely unlike a ping-pong ball. (I have no forces, except gravity acting on it, and my collision response is just hacked in for now.) It decays for a bit, and then it finds some extra energy, and goes all wonky...eventually surpassing collision detection, and passing magically through the table top!) Actually, it is funny to watch, except that I wrote it! My contribution to zero-energy research, I suppose.

The upside is that the physics will not rely on anything except DBPro native commands. I just have to figure out the matrix math, which is not my strong suit. I have a nice rigid body object that has all of the vectors and matrices ready. I have even gotten quaternions working directly in DBPro now.

I have some improvements in the plug-in that should be able to decide the best method to use. I think I've found a way to determine if there is a Wiimote connected now. Unfortunately, BlueSoleil will open the HID device despite that fact that there is no Wiimote to talk to. The program then will fail on read...and hang while waiting. That is what originally happened to RiiDii, I think. I now have a timer for that. Also, that BSOD happens on Write, I think. In Brian Peek's code, he tries to get the calibration data for the accelerometer first, and if that fails, he uses the get/set report functionality to talk to the Wiimote, which apparently, the later versions of BlueSoleil like better than Read/WriteFile.

The code that I have posted has the ability to use get/set report, but no automatic facility for choosing which to use, and also...no events or timeouts. (i.e. You just have to try both, unfortunately.)

The code I have now is far better, but I need to be able to test for no Wiimote, and fail the device open in that case. The only thing I have noticed about BlueSoleil is that, if you attempt to get the manufacturer string, product string or serial number string from BS...it will return "UnKnown" [sic] for connected Wiimotes, and the function will fail if no Wiimote is connected. That is actually encouraging. HID has a concept of a Virtual Connection, but BlueSoleil does not use it. That leaves the string test as the only reliable way to prevent a lockup in the case where no Wiimote is present.

Anyway, thanks for the thorough testing and results. That is really encouraging, and no real surprises either. I will post up an updated DLL and perhaps another sample application in the next few days. While I am generally uncertain still about BlueSoleil 6.0...I am somewhat confident, at least that I can work with versions prior to 6.0 without needing the BS SDK.

Login to post a reply

Server time is: 2024-11-23 05:38:13
Your offset time is: 2024-11-23 05:38:13