Ticket #89: 0001-added-low_speed-data-from-motionplus.patch

File 0001-added-low_speed-data-from-motionplus.patch, 3.5 KB (added by piglop, 4 years ago)

adds low_speed flags to motionplus mesg and state

  • libcwiid/cwiid.h

    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  
    263263struct cwiid_motionplus_mesg { 
    264264        enum cwiid_mesg_type type; 
    265265        uint16_t angle_rate[3]; 
     266        uint8_t low_speed[3]; 
    266267}; 
    267268 
    268269struct cwiid_error_mesg { 
     
    307308 
    308309struct motionplus_state { 
    309310        uint16_t angle_rate[3]; 
     311        uint8_t low_speed[3]; 
    310312}; 
    311313 
    312314union ext_state { 
  • libcwiid/process.c

    diff --git a/libcwiid/process.c b/libcwiid/process.c
    index 8d723b9..879e9dd 100644
    a b  
    249249                                                                    (uint16_t)data[1]; 
    250250                        motionplus_mesg->angle_rate[CWIID_PSI]   = ((uint16_t)data[3] & 0xFC)<<6 | 
    251251                                                                    (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; 
    252255                } 
    253256                break; 
    254257        } 
  • libcwiid/state.c

    diff --git a/libcwiid/state.c b/libcwiid/state.c
    index bf077fc..c9bec80 100644
    a b  
    8585                        memcpy(wiimote->state.ext.motionplus.angle_rate, 
    8686                               mesg->motionplus_mesg.angle_rate, 
    8787                               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); 
    8891                        break; 
    8992                case CWIID_MESG_ERROR: 
    9093                        wiimote->state.error = mesg->error_mesg.error; 
  • wmdemo/wmdemo.c

    diff --git a/wmdemo/wmdemo.c b/wmdemo/wmdemo.c
    index 70a25a1..015e8d7 100644
    a b  
    287287                       state->ext.balance.left_bottom); 
    288288                break; 
    289289        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", 
    291291                       state->ext.motionplus.angle_rate[0], 
    292292                       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]); 
    294297                break; 
    295298        } 
    296299} 
     
    390393                               mesg[i].balance_mesg.left_bottom); 
    391394                        break; 
    392395                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", 
    394397                               mesg[i].motionplus_mesg.angle_rate[0], 
    395398                               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]); 
    397403                        break; 
    398404                case CWIID_MESG_ERROR: 
    399405                        if (cwiid_close(wiimote)) {