Cleanup use of calib data.
This commit is contained in:
@@ -51,7 +51,6 @@ static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now);
|
|||||||
*/
|
*/
|
||||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
|
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
|
||||||
int i;
|
int i;
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
cc->btns = 0;
|
cc->btns = 0;
|
||||||
cc->btns_held = 0;
|
cc->btns_held = 0;
|
||||||
@@ -59,7 +58,7 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
|||||||
cc->r_shoulder = 0;
|
cc->r_shoulder = 0;
|
||||||
cc->l_shoulder = 0;
|
cc->l_shoulder = 0;
|
||||||
|
|
||||||
if (data[offset] == 0xFF) {
|
if (data[0] == 0xFF) {
|
||||||
/*
|
/*
|
||||||
* Sometimes the data returned here is not correct.
|
* Sometimes the data returned here is not correct.
|
||||||
* This might happen because the wiimote is lagging
|
* This might happen because the wiimote is lagging
|
||||||
@@ -70,7 +69,7 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
|||||||
* but since the next 16 bytes are the same, just use
|
* but since the next 16 bytes are the same, just use
|
||||||
* those.
|
* those.
|
||||||
*/
|
*/
|
||||||
if (data[offset + 16] == 0xFF) {
|
if (data[16] == 0xFF) {
|
||||||
/* get the calibration data */
|
/* get the calibration data */
|
||||||
byte* handshake_buf = (byte *)malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
byte* handshake_buf = (byte *)malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||||
|
|
||||||
@@ -79,24 +78,24 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
offset += 16;
|
data += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* joystick stuff */
|
/* joystick stuff */
|
||||||
cc->ljs.max.x = data[0 + offset] / 4;
|
cc->ljs.max.x = data[0] / 4;
|
||||||
cc->ljs.min.x = data[1 + offset] / 4;
|
cc->ljs.min.x = data[1] / 4;
|
||||||
cc->ljs.center.x = data[2 + offset] / 4;
|
cc->ljs.center.x = data[2] / 4;
|
||||||
cc->ljs.max.y = data[3 + offset] / 4;
|
cc->ljs.max.y = data[3] / 4;
|
||||||
cc->ljs.min.y = data[4 + offset] / 4;
|
cc->ljs.min.y = data[4] / 4;
|
||||||
cc->ljs.center.y = data[5 + offset] / 4;
|
cc->ljs.center.y = data[5] / 4;
|
||||||
|
|
||||||
cc->rjs.max.x = data[6 + offset] / 8;
|
cc->rjs.max.x = data[6] / 8;
|
||||||
cc->rjs.min.x = data[7 + offset] / 8;
|
cc->rjs.min.x = data[7] / 8;
|
||||||
cc->rjs.center.x = data[8 + offset] / 8;
|
cc->rjs.center.x = data[8] / 8;
|
||||||
cc->rjs.max.y = data[9 + offset] / 8;
|
cc->rjs.max.y = data[9] / 8;
|
||||||
cc->rjs.min.y = data[10 + offset] / 8;
|
cc->rjs.min.y = data[10] / 8;
|
||||||
cc->rjs.center.y = data[11 + offset] / 8;
|
cc->rjs.center.y = data[11] / 8;
|
||||||
|
|
||||||
/* handshake done */
|
/* handshake done */
|
||||||
wm->exp.type = EXP_CLASSIC;
|
wm->exp.type = EXP_CLASSIC;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ static void guitar_hero_3_pressed_buttons(struct guitar_hero_3_t* gh3, short now
|
|||||||
*/
|
*/
|
||||||
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
|
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
|
||||||
int i;
|
int i;
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The good fellows that made the Guitar Hero 3 controller
|
* The good fellows that made the Guitar Hero 3 controller
|
||||||
@@ -65,7 +64,11 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
|||||||
gh3->btns_released = 0;
|
gh3->btns_released = 0;
|
||||||
gh3->whammy_bar = 0.0f;
|
gh3->whammy_bar = 0.0f;
|
||||||
|
|
||||||
if (data[offset] == 0xFF) {
|
/*
|
||||||
|
TODO: If we're not using anything from calibration data, why are we
|
||||||
|
even bothering here?
|
||||||
|
*/
|
||||||
|
if (data[0] == 0xFF) {
|
||||||
/*
|
/*
|
||||||
* Sometimes the data returned here is not correct.
|
* Sometimes the data returned here is not correct.
|
||||||
* This might happen because the wiimote is lagging
|
* This might happen because the wiimote is lagging
|
||||||
@@ -76,7 +79,7 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
|||||||
* but since the next 16 bytes are the same, just use
|
* but since the next 16 bytes are the same, just use
|
||||||
* those.
|
* those.
|
||||||
*/
|
*/
|
||||||
if (data[offset + 16] == 0xFF) {
|
if (data[16] == 0xFF) {
|
||||||
/* get the calibration data */
|
/* get the calibration data */
|
||||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
offset += 16;
|
data += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* joystick stuff */
|
/* joystick stuff */
|
||||||
|
|||||||
Reference in New Issue
Block a user