Changeset 2aa9b55d44c652444a33d2d0afa5d04c13f4efe6

Show
Ignore:
Timestamp:
09/29/09 02:05:03 (3 years ago)
Author:
L. Donnie Smith <donnie.smith@…>
git-author:
L. Donnie Smith <donnie.smith@gatech.edu> / 2009-06-15T00:05:28Z+0000
Parents:
2174214bc2caca51aa49a47025ccb80b3f75e53f
Children:
8df4b195a65ed76283cd18f6d1e2373f01431cff
git-committer:
L. Donnie Smith <donnie.smith@gatech.edu> / 2009-09-28T22:05:03Z-0400
Message:

Alternate extension initialization, remove decoded reads (#79)

git-svn-id: http://abstrakraft.org/cwiid/svn/trunk@189 918edb2d-ff29-0410-9de2-eb38e7f22bc7

Files:
7 modified

Legend:

Unmodified
Added
Removed
  • libcwiid/command.c

    ra09a4ee r2aa9b55  
    130130        unsigned char *cursor; 
    131131        int ret = 0; 
    132         int i; 
    133132 
    134133        /* Compose read request packet */ 
     
    195194        if (pthread_mutex_unlock(&wiimote->rw_mutex)) { 
    196195                cwiid_err(wiimote, "Mutex unlock error (rw_mutex) - deadlock warning"); 
    197         } 
    198  
    199         /* Decode (only for register reads) */ 
    200         if ((ret == 0) && (flags & CWIID_RW_DECODE) && (flags & CWIID_RW_REG)) { 
    201                 for (i=0; i < len; i++) { 
    202                         ((unsigned char *)data)[i] = DECODE(((unsigned char *)data)[i]); 
    203                 } 
    204196        } 
    205197 
  • libcwiid/cwiid.h

    r2174214 r2aa9b55  
    120120#define CWIID_RW_EEPROM 0x00 
    121121#define CWIID_RW_REG    0x04 
    122 #define CWIID_RW_DECODE 0x01 
    123122 
    124123/* Maximum Data Read Length */ 
  • libcwiid/cwiid_internal.h

    r2174214 r2aa9b55  
    127127#define CLIFF_IR_BLOCK_2        "\x63\x03" 
    128128 
    129 /* Extension Decode */ 
    130 #define DECODE(a)       (((a ^ 0x17)+0x17)&0xFF) 
    131  
    132129/* Write Sequences */ 
    133130enum write_seq_type { 
  • libcwiid/interface.c

    r2174214 r2aa9b55  
    158158                break; 
    159159        case CWIID_EXT_NUNCHUK: 
    160                 flags = CWIID_RW_REG | CWIID_RW_DECODE; 
     160                flags = CWIID_RW_REG; 
    161161                offset = 0xA40020; 
    162162                err_str = "nunchuk "; 
  • libcwiid/process.c

    r2174214 r2aa9b55  
    196196                        nunchuk_mesg = &ma->array[ma->count++].nunchuk_mesg; 
    197197                        nunchuk_mesg->type = CWIID_MESG_NUNCHUK; 
    198                         nunchuk_mesg->stick[CWIID_X] = DECODE(data[0]); 
    199                         nunchuk_mesg->stick[CWIID_Y] = DECODE(data[1]); 
    200                         nunchuk_mesg->acc[CWIID_X] = DECODE(data[2]); 
    201                         nunchuk_mesg->acc[CWIID_Y] = DECODE(data[3]); 
    202                         nunchuk_mesg->acc[CWIID_Z] = DECODE(data[4]); 
    203                         nunchuk_mesg->buttons = ~DECODE(data[5]) & NUNCHUK_BTN_MASK; 
     198                        nunchuk_mesg->stick[CWIID_X] = data[0]; 
     199                        nunchuk_mesg->stick[CWIID_Y] = data[1]; 
     200                        nunchuk_mesg->acc[CWIID_X] = data[2]; 
     201                        nunchuk_mesg->acc[CWIID_Y] = data[3]; 
     202                        nunchuk_mesg->acc[CWIID_Z] = data[4]; 
     203                        nunchuk_mesg->buttons = ~data[5] & NUNCHUK_BTN_MASK; 
    204204                } 
    205205                break; 
     
    210210 
    211211                        for (i=0; i < 6; i++) { 
    212                                 data[i] = DECODE(data[i]); 
     212                                data[i] = data[i]; 
    213213                        } 
    214214 
  • libcwiid/thread.c

    r2174214 r2aa9b55  
    173173        struct mesg_array ma; 
    174174        struct cwiid_status_mesg *status_mesg; 
    175         unsigned char buf; 
     175        unsigned char buf[2]; 
    176176 
    177177        ma.count = 1; 
     
    193193                if (status_mesg->ext_type == CWIID_EXT_UNKNOWN) { 
    194194                        if (wiimote->state.ext_type == CWIID_EXT_NONE) { 
    195                                 buf = 0x00; 
     195                                buf[0] = 0x55; 
     196                                buf[1] = 0x00; 
    196197                                /* Initialize extension register space */ 
    197                                 if (cwiid_write(wiimote, CWIID_RW_REG, 0xA40040, 1, &buf)) { 
     198                                if (cwiid_write(wiimote, CWIID_RW_REG, 0xA400F0, 1, &buf[0])) { 
    198199                                        cwiid_err(wiimote, "Extension initialization error"); 
    199200                                        status_mesg->ext_type = CWIID_EXT_UNKNOWN; 
    200201                                } 
     202                                else if (cwiid_write(wiimote, CWIID_RW_REG, 0xA400FB, 1, &buf[1])) { 
     203                                                cwiid_err(wiimote, "Extension initialization error"); 
     204                                                status_mesg->ext_type = CWIID_EXT_UNKNOWN; 
     205                                } 
    201206                                /* Read extension ID */ 
    202                                 else if (cwiid_read(wiimote, CWIID_RW_REG | CWIID_RW_DECODE, 
    203                                                     0xA400FE, 1, &buf)) { 
     207                                else if (cwiid_read(wiimote, CWIID_RW_REG, 0xA400FE, 1, &buf[0])) { 
    204208                                        cwiid_err(wiimote, "Read error (extension error)"); 
    205209                                        status_mesg->ext_type = CWIID_EXT_UNKNOWN; 
    206210                                } 
    207211                                else { 
    208                                         switch (buf) { 
     212                                        switch (buf[0]) { 
    209213                                        case EXT_NONE: 
    210214                                        case EXT_PARTIAL: 
  • python/cwiidmodule.c

    r2174214 r2aa9b55  
    133133        CWIID_CONST_MACRO(RW_EEPROM), 
    134134        CWIID_CONST_MACRO(RW_REG), 
    135         CWIID_CONST_MACRO(RW_DECODE), 
    136135        CWIID_CONST_MACRO(MAX_READ_LEN), 
    137136        CWIID_CONST_MACRO(X),