fix mac expansion handshake by propagating the event on receive
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
20
src/io_mac.m
20
src/io_mac.m
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user