From e895aa993e781fb03739eb982a034a4df66c3b2e Mon Sep 17 00:00:00 2001
From: piglop <mike@lepton.fr>
Date: Sat, 25 Jul 2009 22:14:01 +0200
Subject: [PATCH] added low_speed data from motionplus
---
libcwiid/cwiid.h | 2 ++
libcwiid/process.c | 3 +++
libcwiid/state.c | 3 +++
wmdemo/wmdemo.c | 14 ++++++++++----
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/libcwiid/cwiid.h b/libcwiid/cwiid.h
index e21a85f..2728991 100644
|
a
|
b
|
|
| 263 | 263 | struct cwiid_motionplus_mesg { |
| 264 | 264 | enum cwiid_mesg_type type; |
| 265 | 265 | uint16_t angle_rate[3]; |
| | 266 | uint8_t low_speed[3]; |
| 266 | 267 | }; |
| 267 | 268 | |
| 268 | 269 | struct cwiid_error_mesg { |
| … |
… |
|
| 307 | 308 | |
| 308 | 309 | struct motionplus_state { |
| 309 | 310 | uint16_t angle_rate[3]; |
| | 311 | uint8_t low_speed[3]; |
| 310 | 312 | }; |
| 311 | 313 | |
| 312 | 314 | union ext_state { |
diff --git a/libcwiid/process.c b/libcwiid/process.c
index 8d723b9..879e9dd 100644
|
a
|
b
|
|
| 249 | 249 | (uint16_t)data[1]; |
| 250 | 250 | motionplus_mesg->angle_rate[CWIID_PSI] = ((uint16_t)data[3] & 0xFC)<<6 | |
| 251 | 251 | (uint16_t)data[0]; |
| | 252 | motionplus_mesg->low_speed[CWIID_PHI] = ((uint8_t)data[3] & 0x01); |
| | 253 | motionplus_mesg->low_speed[CWIID_THETA] = ((uint8_t)data[4] & 0x02)>>1; |
| | 254 | motionplus_mesg->low_speed[CWIID_PSI] = ((uint8_t)data[3] & 0x02)>>1; |
| 252 | 255 | } |
| 253 | 256 | break; |
| 254 | 257 | } |
diff --git a/libcwiid/state.c b/libcwiid/state.c
index bf077fc..c9bec80 100644
|
a
|
b
|
|
| 85 | 85 | memcpy(wiimote->state.ext.motionplus.angle_rate, |
| 86 | 86 | mesg->motionplus_mesg.angle_rate, |
| 87 | 87 | sizeof wiimote->state.ext.motionplus.angle_rate); |
| | 88 | memcpy(wiimote->state.ext.motionplus.low_speed, |
| | 89 | mesg->motionplus_mesg.low_speed, |
| | 90 | sizeof wiimote->state.ext.motionplus.low_speed); |
| 88 | 91 | break; |
| 89 | 92 | case CWIID_MESG_ERROR: |
| 90 | 93 | wiimote->state.error = mesg->error_mesg.error; |
diff --git a/wmdemo/wmdemo.c b/wmdemo/wmdemo.c
index 70a25a1..015e8d7 100644
|
a
|
b
|
|
| 287 | 287 | state->ext.balance.left_bottom); |
| 288 | 288 | break; |
| 289 | 289 | case CWIID_EXT_MOTIONPLUS: |
| 290 | | printf("MotionPlus: angle_rate=(%d,%d,%d)\n", |
| | 290 | printf("MotionPlus: angle_rate=(%d,%d,%d) low_speed=(%d,%d,%d)\n", |
| 291 | 291 | state->ext.motionplus.angle_rate[0], |
| 292 | 292 | state->ext.motionplus.angle_rate[1], |
| 293 | | state->ext.motionplus.angle_rate[2]); |
| | 293 | state->ext.motionplus.angle_rate[2], |
| | 294 | state->ext.motionplus.low_speed[0], |
| | 295 | state->ext.motionplus.low_speed[1], |
| | 296 | state->ext.motionplus.low_speed[2]); |
| 294 | 297 | break; |
| 295 | 298 | } |
| 296 | 299 | } |
| … |
… |
|
| 390 | 393 | mesg[i].balance_mesg.left_bottom); |
| 391 | 394 | break; |
| 392 | 395 | case CWIID_MESG_MOTIONPLUS: |
| 393 | | printf("MotionPlus Report: angle_rate=(%d,%d,%d)\n", |
| | 396 | printf("MotionPlus Report: angle_rate=(%d,%d,%d) low_speed=(%d,%d,%d)\n", |
| 394 | 397 | mesg[i].motionplus_mesg.angle_rate[0], |
| 395 | 398 | mesg[i].motionplus_mesg.angle_rate[1], |
| 396 | | mesg[i].motionplus_mesg.angle_rate[2]); |
| | 399 | mesg[i].motionplus_mesg.angle_rate[2], |
| | 400 | mesg[i].motionplus_mesg.low_speed[0], |
| | 401 | mesg[i].motionplus_mesg.low_speed[1], |
| | 402 | mesg[i].motionplus_mesg.low_speed[2]); |
| 397 | 403 | break; |
| 398 | 404 | case CWIID_MESG_ERROR: |
| 399 | 405 | if (cwiid_close(wiimote)) { |