Skip to content

Commit

Permalink
fix #2 - Nunchuck Rev2 & Classic Controller Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Kali committed Nov 23, 2022
1 parent bcaf987 commit d833473
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions wii_anal_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool evWiiEC (const eventMsg_t* const msg, state_t* const state)
case WIIEC_RELEASE: s = "Release"; break ;
case WIIEC_ANALOG: s = "Analog"; break ;
case WIIEC_ACCEL: s = "Accel"; break ;
default: s = "Bug"; break ;
default: s = "Bug"; break ;
}
INFO("WIIP : %s '%c' = %d", s, (isprint((int)msg->wiiEc.in) ? msg->wiiEc.in : '_'), msg->wiiEc.val);
if ((msg->wiiEc.type == WIIEC_CONN) || (msg->wiiEc.type == WIIEC_DISCONN))
Expand All @@ -38,6 +38,17 @@ bool evWiiEC (const eventMsg_t* const msg, state_t* const state)
state->calib = CAL_TRACK;
sceneSet(state, ecId[msg->wiiEc.val].scene);
redraw = true ;

#if 1 // Workaround for Classic Controller Pro, which shows 00's for Factory Calibration Data!?
if (state->ec.pidx == PID_CLASSIC_PRO) {
// Simulate a Long-OK keypress, to start Software Calibration mode
eventMsg_t msg = {
input.type = InputTypeLong,
input.key = InputKeyOk
};
key_calib(&msg, state);
}
#endif
break;

case WIIEC_DISCONN:
Expand All @@ -59,7 +70,7 @@ bool evWiiEC (const eventMsg_t* const msg, state_t* const state)
}

#if 1 //! factory calibration method not known for classic triggers - this will set the digital switch point
if (state->ec.pidx == PID_CLASSIC) {
if ((state->ec.pidx == PID_CLASSIC) || (state->ec.pidx == PID_CLASSIC_PRO)) {
if (msg->wiiEc.in == 'l') state->ec.calS.classic[2].trgZL = msg->wiiEc.val ;
if (msg->wiiEc.in == 'r') state->ec.calS.classic[2].trgZR = msg->wiiEc.val ;
}
Expand Down
6 changes: 6 additions & 0 deletions wii_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ const ecId_t ecId[PID_CNT] = {
[PID_NUNCHUCK ] = { {0x00, 0x00, 0xA4, 0x20, 0x00, 0x00}, "Nunchuck", SCENE_NUNCHUCK,
NULL, nunchuck_decode, nunchuck_msg, nunchuck_calib, nunchuck_show, nunchuck_key },

[PID_NUNCHUCK_R2] = { {0xFF, 0x00, 0xA4, 0x20, 0x00, 0x00}, "Nunchuck (rev2)", SCENE_NUNCHUCK,
NULL, nunchuck_decode, nunchuck_msg, nunchuck_calib, nunchuck_show, nunchuck_key },

[PID_CLASSIC ] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x01}, "Classic Controller", SCENE_CLASSIC,
NULL, classic_decode, classic_msg, classic_calib, classic_show, classic_key },

[PID_CLASSIC_PRO] = { {0x01, 0x00, 0xA4, 0x20, 0x01, 0x01}, "Classic Controller Pro", SCENE_CLASSIC,
NULL, classic_decode, classic_msg, classic_calib, classic_show, classic_key },

[PID_BALANCE ] = { {0x00, 0x00, 0xA4, 0x20, 0x04, 0x02}, "Balance Board", SCENE_DUMP,
NULL, NULL, NULL, NULL, NULL, NULL },

Expand Down
2 changes: 2 additions & 0 deletions wii_ec.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ typedef
PID_NUNCHUCK = PID_FIRST,

// If you're wise, ONLY edit this section
PID_NUNCHUCK_R2,
PID_CLASSIC,
PID_CLASSIC_PRO,
PID_BALANCE,
PID_GH_GUITAR,
PID_GH_DRUMS,
Expand Down

0 comments on commit d833473

Please sign in to comment.