| View previous topic :: View next topic |
| Author |
Message |
Kevin
Joined: 20 Dec 2006 Posts: 3
Digg It |
Posted: Wed Dec 20, 2006 6:17 am Post subject: Writing to the WiiMote |
|
|
I'm trying to write an HID report to the wiimote using WriteFile (using C++ under win32), but it keeps returning incorrect parameter. The weird thing is that I can read reports with no problems, and the GlovePIE Wii test works fine with my setup.
Does anyone have any suggestions? I'd love to get coding for this thing, but all of the examples that I can find are using Delphi or Python.
Here's the code that is failing:
(handle and HIDOverlapped are set up previously when I open the file)
| Code: |
BYTE buffer[64];
for (int i =0; i < 64;i++)
{
buffer[i] = 0;
}
PHIDP_PREPARSED_DATA HidParsedData;
HIDP_CAPS Capabilities;
HidD_GetPreparsedData(handle, &HidParsedData);
HidP_GetCaps( HidParsedData ,&Capabilities);
HidD_FreePreparsedData(HidParsedData);
buffer[0] = 0x52;
buffer[1] = 0x12;
buffer[2] = 0x00;
buffer[3] = 0x01;
DWORD numBytesReturned =0 ;
int bResult;
bResult = WriteFile( handle, &buffer[0], Capabilities.OutputReportByteLength, &numBytesReturned, (LPOVERLAPPED) &HIDOverlapped);
|
Capabilities.OutputReportByteLength is 22, and bResult returns as 0. |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Wed Dec 20, 2006 7:47 am Post subject: |
|
|
| I don't used overlapped writing. |
|
| Back to top |
|
 |
WDML
Joined: 15 Dec 2006 Posts: 6
Digg It |
Posted: Wed Dec 20, 2006 6:57 pm Post subject: |
|
|
What BT stack are you using? Some don't seem to support WriteFile (or if they do, they need some special setup of the file handle that I don't know about).
You can check the WDML source for reading/writing code:
sourceforge . net/projects/wdml/ |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Thu Dec 21, 2006 4:15 am Post subject: |
|
|
| As far as I know, the WDML still won't work on BlueSoleil, because HidD_SetOutputReport returns true on BlueSoleil even though it fails. |
|
| Back to top |
|
 |
WDML
Joined: 15 Dec 2006 Posts: 6
Digg It |
Posted: Fri Dec 22, 2006 6:00 am Post subject: |
|
|
| CarlKenner wrote: | | As far as I know, the WDML still won't work on BlueSoleil, because HidD_SetOutputReport returns true on BlueSoleil even though it fails. |
Yeah that is true. I won't have time to address this issue until the 28th or so, but I intend to address it so we can have a method of reading and writing that will work across all stacks without requiring user intervention. |
|
| Back to top |
|
 |
Dodger_
Joined: 21 Dec 2006 Posts: 15
Digg It |
Posted: Fri Dec 22, 2006 2:47 pm Post subject: |
|
|
| Carl, how exactly are you accessing the Wiimote under Windows? Sockets or the BlueTooth API? Are you or Kevin willing to post some basic code to enumerate the device and read data for Windows? I'd like to do some application development of my own in Visual Studio and MSDN isn't very helpful in getting started. |
|
| Back to top |
|
 |
chikin
Joined: 22 Dec 2006 Posts: 1
Digg It |
Posted: Fri Dec 22, 2006 4:41 pm Post subject: |
|
|
Kevin, it looks like you're writing the header byte (0x52) as part of the data that you send via WriteFile(). Try removing that and see if it works. I do not include the header byte and I am able to successfully change the state of the LEDs with my C++ code.
If that fails, call GetLastError() after the call to WriteFile() and see if you're getting a weird status despite the fact that the WriteFile() appears to be succeeding (by virtue of the fact that it's returning TRUE).
Finally, I noticed in my tests this morning that my HID device discovery loop using SetupDiEnumDeviceInterfaces() is returning TWO Wiimotes, even though I only had my one and only Wiimote associated with my machine at the time. Consequently, I had to use the handle that I got from the 'second' Wiimote device's CreateFile() to write successfully to the Wiimote. You might want to check if you're being afflicted with this same problem. (Incidentally, I do pass the DIGCF_PRESENT flag to SetupDiGetClassDevs(), so I would expect to see only devices that were currently present. I'm wondering if the fact that I moved my USB BT dongle to another USB port this morning had anything to do with this, as Windows has this stupid habit of thinking that a device with the same VID, PID and serial number as a previously connected USB device is brand new if installed in a different USB port.)
Hope this helps.
chikin |
|
| Back to top |
|
 |
|