Conflicts:

	src/events.c
	src/io.c
	src/wiiuse.c
	src/wiiuse.h
This commit is contained in:
Jan Ciger
2011-09-14 09:04:58 -05:00
committed by Ryan Pavlik
parent 9b5ef23276
commit 80e8fa37ac
4 changed files with 93 additions and 3 deletions

View File

@@ -657,6 +657,71 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
} }
#endif #endif
#if 0
switch(wm->expansion_state)
{
case 0: // regular expansion detection
{
if(attachment && wm->exp.type != EXP_NONE)
{
wm->expansion_dattempts = 0;
wm->expansion_state++;
}
else
{
// give it another chance still
if(wm->expansion_dattempts < 10)
{
wm->expansion_dattempts++;
wiiuse_status(wm);
return;
}
// likely no attachment, give up and try M+
else {
wm->expansion_dattempts = 0;
wiiuse_set_motion_plus(wm, WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP) ? 2 : 1);
wm->expansion_state++;
}
}
break;
}
case 1: // try to init Motion+
{
if(attachment && wm->exp.type != EXP_NONE)
{
wm->expansion_dattempts = 0;
wm->expansion_state++;
}
else
{
// give it another chance still
if(wm->expansion_dattempts < 10)
{
wm->expansion_dattempts++;
wiiuse_status(wm);
return;
}
else {
// give up and move on
wm->expansion_state++;
}
}
break;
}
default:
break;
}
#endif
/* /*
* From now on the remote will only send status packets. * From now on the remote will only send status packets.
* We need to send a WIIMOTE_CMD_REPORT_TYPE packet to * We need to send a WIIMOTE_CMD_REPORT_TYPE packet to
@@ -690,7 +755,9 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
wiiuse_send_next_pending_write_request(wm); wiiuse_send_next_pending_write_request(wm);
} else } else
{
wiiuse_set_report_type(wm); wiiuse_set_report_type(wm);
}
} }
@@ -714,6 +781,11 @@ static void handle_expansion(struct wiimote_t* wm, byte* msg) {
case EXP_WII_BOARD: case EXP_WII_BOARD:
wii_board_event(&wm->exp.wb, msg); wii_board_event(&wm->exp.wb, msg);
break; break;
case EXP_MOTION_PLUS:
case EXP_MOTION_PLUS_CLASSIC:
case EXP_MOTION_PLUS_NUNCHUK:
motion_plus_event(&wm->exp.mp, wm->exp.type, msg);
break;
default: default:
break; break;
} }
@@ -789,6 +861,15 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
wm->event = WIIUSE_WII_BOARD_CTRL_INSERTED; wm->event = WIIUSE_WII_BOARD_CTRL_INSERTED;
break; break;
} }
case EXP_ID_CODE_MOTION_PLUS:
case EXP_ID_CODE_MOTION_PLUS_CLASSIC:
case EXP_ID_CODE_MOTION_PLUS_NUNCHUK:
//wiiuse_motion_plus_handshake(wm, data, len);
wm->event = WIIUSE_MOTION_PLUS_ACTIVATED;
break;
default: default:
{ {
WIIUSE_WARNING("Unknown expansion type. Code: 0x%x", id); WIIUSE_WARNING("Unknown expansion type. Code: 0x%x", id);
@@ -833,6 +914,12 @@ void disable_expansion(struct wiimote_t* wm) {
wii_board_disconnected(&wm->exp.wb); wii_board_disconnected(&wm->exp.wb);
wm->event = WIIUSE_WII_BOARD_CTRL_REMOVED; wm->event = WIIUSE_WII_BOARD_CTRL_REMOVED;
break; break;
case EXP_MOTION_PLUS:
case EXP_MOTION_PLUS_CLASSIC:
case EXP_MOTION_PLUS_NUNCHUK:
motion_plus_disconnected(&wm->exp.mp);
wm->event = WIIUSE_MOTION_PLUS_REMOVED;
break;
default: default:
break; break;
} }

View File

@@ -91,7 +91,8 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
accel->cal_zero.x, accel->cal_zero.y, accel->cal_zero.z, accel->cal_zero.x, accel->cal_zero.y, accel->cal_zero.z,
accel->cal_g.x, accel->cal_g.y, accel->cal_g.z); accel->cal_g.x, accel->cal_g.y, accel->cal_g.z);
wiiuse_set_motion_plus(wm, 0); /*wiiuse_set_motion_plus(wm, 0);*/
wiiuse_status(wm);
/* request the status of the wiimote to check for any expansion */ /* request the status of the wiimote to check for any expansion */
wiiuse_status(wm); wiiuse_status(wm);
@@ -107,7 +108,6 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
} }
wm->event = WIIUSE_CONNECT; wm->event = WIIUSE_CONNECT;
wm->expansion_state = 0;
wiiuse_status(wm); wiiuse_status(wm);
break; break;

View File

@@ -147,6 +147,8 @@ struct wiimote_t** wiiuse_init(int wiimotes) {
wm[i]->event = WIIUSE_NONE; wm[i]->event = WIIUSE_NONE;
wm[i]->exp.type = EXP_NONE; wm[i]->exp.type = EXP_NONE;
wm[i]->expansion_state = 0;
wm[i]->expansion_dattempts = 0;
wiiuse_set_aspect_ratio(wm[i], WIIUSE_ASPECT_4_3); wiiuse_set_aspect_ratio(wm[i], WIIUSE_ASPECT_4_3);
wiiuse_set_ir_position(wm[i], WIIUSE_IR_ABOVE); wiiuse_set_ir_position(wm[i], WIIUSE_IR_ABOVE);

View File

@@ -714,7 +714,8 @@ typedef struct wiimote_t {
WCONST int flags; /**< options flag */ WCONST int flags; /**< options flag */
WCONST byte handshake_state; /**< the state of the connection handshake */ WCONST byte handshake_state; /**< the state of the connection handshake */
WCONST unsigned char expansion_state; /**< the state of the expansion handshake */ WCONST byte expansion_state; /**< the state of the expansion handshake */
WCONST byte expansion_dattempts; /**< how many times did we wait already */
WCONST struct data_req_t* data_req; /**< list of data read requests */ WCONST struct data_req_t* data_req; /**< list of data read requests */
WCONST struct read_req_t* read_req; /**< list of data read requests */ WCONST struct read_req_t* read_req; /**< list of data read requests */