Wiiuse: Nunchuck:Standarise the nunchuck code to be more like the one present in libogc
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4321 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
d2f4183a6b
commit
5a7fbd63c2
|
@ -138,8 +138,7 @@ void classic_ctrl_disconnected(struct classic_ctrl_t* cc) {
|
||||||
* @param msg The message specified in the event packet.
|
* @param msg The message specified in the event packet.
|
||||||
*/
|
*/
|
||||||
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) {
|
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) {
|
||||||
int i, lx, ly, rx, ry;
|
int i;
|
||||||
byte l, r;
|
|
||||||
|
|
||||||
/* decrypt data */
|
/* decrypt data */
|
||||||
for (i = 0; i < 6; ++i)
|
for (i = 0; i < 6; ++i)
|
||||||
|
@ -148,24 +147,25 @@ void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) {
|
||||||
classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4)));
|
classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4)));
|
||||||
|
|
||||||
/* left/right buttons */
|
/* left/right buttons */
|
||||||
l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
|
cc->ls_raw = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
|
||||||
r = (msg[3] & 0x1F);
|
cc->rs_raw = (msg[3] & 0x1F);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO - LR range hardcoded from 0x00 to 0x1F.
|
* TODO - LR range hardcoded from 0x00 to 0x1F.
|
||||||
* This is probably in the calibration somewhere.
|
* This is probably in the calibration somewhere.
|
||||||
*/
|
*/
|
||||||
cc->r_shoulder = ((float)r / 0x1F);
|
cc->r_shoulder = ((float)cc->rs_raw / 0x1F);
|
||||||
cc->l_shoulder = ((float)l / 0x1F);
|
cc->l_shoulder = ((float)cc->ls_raw / 0x1F);
|
||||||
|
|
||||||
/* calculate joystick orientation */
|
/* calculate joystick orientation */
|
||||||
lx = (msg[0] & 0x3F);
|
|
||||||
ly = (msg[1] & 0x3F);
|
cc->ljs.pos.x = (msg[0] & 0x3F);
|
||||||
rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
|
cc->ljs.pos.y = (msg[1] & 0x3F);
|
||||||
ry = (msg[2] & 0x1F);
|
cc->rjs.pos.x = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
|
||||||
|
cc->rjs.pos.y = (msg[2] & 0x1F);
|
||||||
|
|
||||||
calc_joystick_state(&cc->ljs, lx, ly);
|
calc_joystick_state(&cc->ljs, cc->ljs.pos.x, cc->ljs.pos.y);
|
||||||
calc_joystick_state(&cc->rjs, rx, ry);
|
calc_joystick_state(&cc->rjs, cc->rjs.pos.x, cc->rjs.pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,9 @@ typedef struct classic_ctrl_t {
|
||||||
short btns_held; /**< what buttons are being held down */
|
short btns_held; /**< what buttons are being held down */
|
||||||
short btns_released; /**< what buttons were just released this */
|
short btns_released; /**< what buttons were just released this */
|
||||||
|
|
||||||
|
byte rs_raw;
|
||||||
|
byte ls_raw;
|
||||||
|
|
||||||
float r_shoulder; /**< right shoulder button (range 0-1) */
|
float r_shoulder; /**< right shoulder button (range 0-1) */
|
||||||
float l_shoulder; /**< left shoulder button (range 0-1) */
|
float l_shoulder; /**< left shoulder button (range 0-1) */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue