fix mac expansion handshake by propagating the event on receive

This commit is contained in:
Lysann Schlegel
2012-11-10 00:52:05 +01:00
parent be1f23ff70
commit f7b4fd44a0
2 changed files with 20 additions and 5 deletions

View File

@@ -801,6 +801,7 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
WIIUSE_DEBUG("no handshake data received from expansion"); WIIUSE_DEBUG("no handshake data received from expansion");
return; return;
} }
wm->expansion_state = 0;
id = from_big_endian_uint32_t(data + 220); id = from_big_endian_uint32_t(data + 220);
switch(id) { switch(id) {
case EXP_ID_CODE_NUNCHUK: case EXP_ID_CODE_NUNCHUK:

View File

@@ -366,19 +366,33 @@
- (void) l2capChannelData:(IOBluetoothL2CAPChannel*) channel data:(byte *) data length:(NSUInteger) length - (void) l2capChannelData:(IOBluetoothL2CAPChannel*) channel data:(byte *) data length:(NSUInteger) length
{ {
// This is done in case the output channel woke up this handler // This is done in case the output channel woke up this handler
if(!data) { if(!data || ([channel PSM] == WM_OUTPUT_CHANNEL)) {
[self setReading:NO];
length = 0;
return; return;
} }
// log the received data
#ifdef WITH_WIIUSE_DEBUG
{
printf("[DEBUG] (id %i) RECV: (%x) ", _wm->unid, data[0]);
int x;
for (x = 1; x < length; ++x)
printf("%.2x ", data[x]);
printf("\n");
}
#endif
/* /*
* This is called if we are receiving data before completing * This is called if we are receiving data before completing
* the handshaking, hence before calling wiiuse_poll * the handshaking, hence before calling wiiuse_poll
*/ */
// wiimote handshake
if(WIIMOTE_IS_SET(_wm, WIIMOTE_STATE_HANDSHAKE)) if(WIIMOTE_IS_SET(_wm, WIIMOTE_STATE_HANDSHAKE))
propagate_event(_wm, data[1], data+2); propagate_event(_wm, data[1], data+2);
// expansion handshake
if(_wm->expansion_state != 0)
propagate_event(_wm, data[1], data+2);
receivedMsg = [[NSData dataWithBytes:data length:length] retain]; receivedMsg = [[NSData dataWithBytes:data length:length] retain];
msgLength = length; msgLength = length;