Changeset 2aa9b55d44c652444a33d2d0afa5d04c13f4efe6
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
ra09a4ee
|
r2aa9b55
|
|
| 130 | 130 | unsigned char *cursor; |
| 131 | 131 | int ret = 0; |
| 132 | | int i; |
| 133 | 132 | |
| 134 | 133 | /* Compose read request packet */ |
| … |
… |
|
| 195 | 194 | if (pthread_mutex_unlock(&wiimote->rw_mutex)) { |
| 196 | 195 | 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 | | } |
| 204 | 196 | } |
| 205 | 197 | |
-
|
r2174214
|
r2aa9b55
|
|
| 120 | 120 | #define CWIID_RW_EEPROM 0x00 |
| 121 | 121 | #define CWIID_RW_REG 0x04 |
| 122 | | #define CWIID_RW_DECODE 0x01 |
| 123 | 122 | |
| 124 | 123 | /* Maximum Data Read Length */ |
-
|
r2174214
|
r2aa9b55
|
|
| 127 | 127 | #define CLIFF_IR_BLOCK_2 "\x63\x03" |
| 128 | 128 | |
| 129 | | /* Extension Decode */ |
| 130 | | #define DECODE(a) (((a ^ 0x17)+0x17)&0xFF) |
| 131 | | |
| 132 | 129 | /* Write Sequences */ |
| 133 | 130 | enum write_seq_type { |
-
|
r2174214
|
r2aa9b55
|
|
| 158 | 158 | break; |
| 159 | 159 | case CWIID_EXT_NUNCHUK: |
| 160 | | flags = CWIID_RW_REG | CWIID_RW_DECODE; |
| | 160 | flags = CWIID_RW_REG; |
| 161 | 161 | offset = 0xA40020; |
| 162 | 162 | err_str = "nunchuk "; |
-
|
r2174214
|
r2aa9b55
|
|
| 196 | 196 | nunchuk_mesg = &ma->array[ma->count++].nunchuk_mesg; |
| 197 | 197 | 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; |
| 204 | 204 | } |
| 205 | 205 | break; |
| … |
… |
|
| 210 | 210 | |
| 211 | 211 | for (i=0; i < 6; i++) { |
| 212 | | data[i] = DECODE(data[i]); |
| | 212 | data[i] = data[i]; |
| 213 | 213 | } |
| 214 | 214 | |
-
|
r2174214
|
r2aa9b55
|
|
| 173 | 173 | struct mesg_array ma; |
| 174 | 174 | struct cwiid_status_mesg *status_mesg; |
| 175 | | unsigned char buf; |
| | 175 | unsigned char buf[2]; |
| 176 | 176 | |
| 177 | 177 | ma.count = 1; |
| … |
… |
|
| 193 | 193 | if (status_mesg->ext_type == CWIID_EXT_UNKNOWN) { |
| 194 | 194 | if (wiimote->state.ext_type == CWIID_EXT_NONE) { |
| 195 | | buf = 0x00; |
| | 195 | buf[0] = 0x55; |
| | 196 | buf[1] = 0x00; |
| 196 | 197 | /* 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])) { |
| 198 | 199 | cwiid_err(wiimote, "Extension initialization error"); |
| 199 | 200 | status_mesg->ext_type = CWIID_EXT_UNKNOWN; |
| 200 | 201 | } |
| | 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 | } |
| 201 | 206 | /* 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])) { |
| 204 | 208 | cwiid_err(wiimote, "Read error (extension error)"); |
| 205 | 209 | status_mesg->ext_type = CWIID_EXT_UNKNOWN; |
| 206 | 210 | } |
| 207 | 211 | else { |
| 208 | | switch (buf) { |
| | 212 | switch (buf[0]) { |
| 209 | 213 | case EXT_NONE: |
| 210 | 214 | case EXT_PARTIAL: |
-
|
r2174214
|
r2aa9b55
|
|
| 133 | 133 | CWIID_CONST_MACRO(RW_EEPROM), |
| 134 | 134 | CWIID_CONST_MACRO(RW_REG), |
| 135 | | CWIID_CONST_MACRO(RW_DECODE), |
| 136 | 135 | CWIID_CONST_MACRO(MAX_READ_LEN), |
| 137 | 136 | CWIID_CONST_MACRO(X), |