Welcome! Log In Create A New Profile

Advanced

WiiUse Issues

Posted by Malakhim 
WiiUse Issues
November 04, 2010 05:46PM
Greetings,

I'm using the Windows C WiiUse library version 0.12. Just started playing with it today and I'm having a ton of fun, currently making a very simple painting program to test out IR tracking. Problem is, I only seem to be able to receive IR data from a single Wii Remote at a time.

Also, after using wiiuse_disconnect() on a remote, for some reason the library will continue to read both IR and button data from it. Oddly enough, the wiiuse_disconnect() function doesn't throw the 'WIIUSE_DISCONNECT' event either.

Basically, the question is: Is this to be expected? And, if not, how would one go about fixing it?

(current code available upon request)

Thank you for any assistance,
Malakhim

*Edit* After some work I seem to have the IR tracking for both remotes working fine, however nothing seems to throw the WIIUSE_DISCONNECT or WIIUSE_CONNECT events, and data is still being read after a wiiuse_disconnect() function.

*Edit 2* Okay, after digging through the source code it seems that (for some reason) the only thing that will raise the WIIUSE_DISCONNECT event is the actual un-pairing of the remote with the computer. And, although it IS defined, nothing is actually set up to trigger the WIIUSE_CONNECT event. In order to fix this, I have changed io_win.c accordingly:

int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
	int connected = 0;
	int i = 0;

	for (; i < wiimotes; ++i) {
		if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED)) {
			++connected;
			wm->event = WIIUSE_CONNECT; //Added to trigger the WIIUSE_CONNECT event
		}
	}

	return connected;
}

void wiiuse_disconnect(struct wiimote_t* wm) {
	if (!wm || WIIMOTE_IS_CONNECTED(wm))
		return;

	CloseHandle(wm->dev_handle);
	wm->dev_handle = 0;

	ResetEvent(&wm->hid_overlap);

	wm->event = WIIUSE_DISCONNECT; //Changed from wm->event = WIIUSE_NONE

	WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
	WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
}

Initially when I tried to recompile from source I was getting several compilation errors from hidpi.h, specifically involving annotations. After uninstalling and reinstalling the Windows 7.10 SDK to a hard drive path WITHOUT SPACES (Instead of "C:\Program Files\Windows SDKs\7.0" I installed to "C:\WinSDK") these issues quickly disappeared.

I hope this will help someone out there, because boy did it drive me crazy.

*Edit 3*
Okay, this is what I get for programming on no sleep. Turns out I wasn't paying close enough attention and the wiiuse_poll() function actually clears the 'event' member, and looks to event_buf[0] for the next event. So, even after making modifications and spending HOURS trying to recompile from source I have gained nothing. You can, however, test to see if a wii remote is still connected (as in, hasn't dropped the connection and hasn't had wiiuse_disconnect() called) by simply using a bitwise AND on the 'state' member with 0x0008 (defined in wiiuse_internal.h as WIIMOTE_STATE_CONNECTED).



Edited 3 time(s). Last edit at 11/05/2010 06:58PM by Malakhim.
Sorry, only registered users may post in this forum.

Click here to login