Changeset 09bfa38f5e75d239ff955f3201095e75f13df68b
- Timestamp:
- 04/05/07 04:13:01 (6 years ago)
- Children:
- 9ef2b8aa3699c1c8aac4ba5a95d932f0b2a74fc1
- Parents:
- 04e0f0ee34ed6e6299d325e7f38f99e66aa7ea29
- git-author:
- L. Donnie Smith <donnie.smith@…> (04/05/07 04:13:01)
- git-committer:
- dsmith <dsmith@…> (04/05/07 04:13:01)
- Files:
-
- 11 modified
-
ChangeLog (modified) (1 diff)
-
wiimote/connect.c (modified) (6 diffs)
-
wiimote/event.c (modified) (21 diffs)
-
wiimote/queue.c (modified) (3 diffs)
-
wiimote/queue.h (modified) (2 diffs)
-
wiimote/rw.c (modified) (10 diffs)
-
wiimote/wiimote.h (modified) (5 diffs)
-
wiimote/wiimote_internal.h (modified) (3 diffs)
-
wmdemo/wmdemo.c (modified) (3 diffs)
-
wmgui/main.c (modified) (2 diffs)
-
wminput/main.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r04e0f0e r09bfa38 3 3 * removed --noyywrap from lex 4 4 5 wiimote 6 * added queue_flush 7 * reimplemented queue_queue with queue_flush 8 * added wiimote_mesg_error message type 9 * moved RW error state to separate wiimote member 10 * updated wiimote_read and wiimote_write to trigger and detect rw_error 11 * cancel rw operations from wiimote_disconnect 12 * implemented process_error to handle socket read errors 13 * added rw_status triggers to read and write handlers 14 15 wmdemo 16 * made wiimote handle global 17 * disconnect and exit on wiimote_mesg_error 18 19 wmgui 20 * disconnect on wiimote_mesg_error 21 22 wminput 23 * exit on wiimote_mesg_error 24 25 2007-04-03 L. Donnie Smith <cwiid@abstrakraft.org> 5 26 wiimote 6 27 * fixed wiimote_find_wiimote seg fault -
wiimote/connect.c
ra8b4be2 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * cancel rw operations from wiimote_disconnect 20 * 18 21 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * wiimote_connect now takes a pointer to bdaddr_t … … 84 87 if (bacmp(bdaddr, BDADDR_ANY) == 0) { 85 88 if (wiimote_find_wiimote(bdaddr, 2)) { 86 /* TODO: wiimote functions should print their own errors */87 wiimote_err(wiimote, "Unable to find wiimote");88 89 goto ERR_HND; 89 90 } … … 144 145 /* Set rw_status before interrupt thread */ 145 146 wiimote->rw_status = RW_NONE; 147 wiimote->rw_error = 0; 146 148 147 149 /* Launch interrupt channel listener and dispatch threads */ … … 197 199 /* Cancel and join int_thread */ 198 200 if (pthread_cancel(wiimote->int_listen_thread)) { 199 wiimote_err(wiimote, "Error canceling int_listen_thread"); 201 /* int could exit on it's own, so we don't care */ 202 /* wiimote_err(wiimote, "Error canceling int_listen_thread"); */ 200 203 } 201 204 else { … … 208 211 } 209 212 } 210 /* TODO: cancel RW operations if they are in progress */ 213 214 /* Cancel any RW operations in progress */ 215 wiimote->rw_error = 1; 216 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 217 wiimote_err(wiimote, "Error locking rw_cond_mutex: deadlock warning"); 218 } 219 else { 220 if (pthread_cond_signal(&wiimote->rw_cond)) { 221 wiimote_err(wiimote, "Error signaling rw_cond: deadlock warning"); 222 } 223 if (pthread_mutex_unlock( 224 &wiimote->rw_cond_mutex)) { 225 wiimote_err(wiimote, "Error unlocking rw_cond_mutex"); 226 } 227 } 228 211 229 /* Cancel and detach dispatch_thread */ 212 230 /* We detach to decouple dispatch (which runs the callback) from wiimote … … 227 245 } 228 246 247 /* TODO: We have no way of telling if all in flight rw operations 248 * have exited yet, so for now, user must verify that all have returned 249 * before calling disconnect */ 250 229 251 /* Destroy sync variables */ 230 252 if (pthread_mutex_destroy(&wiimote->wiimote_mutex)) { -
wiimote/event.c
r00aa494 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * implemented process_error to handle socket read errors 20 * * added rw_status triggers to read and write handlers 21 * 18 22 * 03/14/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 23 * * audit error checking … … 102 106 * placed at the end of mesg_array. */ 103 107 108 static int process_error(struct wiimote *, size_t); 104 109 static int process_status(struct wiimote *, const unsigned char *, 105 110 struct mesg_array *); … … 131 136 do { 132 137 /* Read packet */ 133 if ((len = read(wiimote->int_socket, buf, READ_BUF_LEN)) == -1) { 134 wiimote_err(wiimote, "Interrupt channel read error"); 135 /* TODO: return ? */ 138 len = read(wiimote->int_socket, buf, READ_BUF_LEN); 139 if ((len == -1) || (len == 0)) { 140 process_error(wiimote, len); 141 /* Quit! */ 142 break; 136 143 } 137 144 else { … … 162 169 case RPT_STATUS: 163 170 if (process_status(wiimote, &buf[2], mesg_array)) { 164 err = -1;171 err = 1; 165 172 } 166 173 break; 167 174 case RPT_BTN: 168 175 if (process_btn(wiimote, &buf[2], mesg_array)) { 169 err = -1;176 err = 1; 170 177 } 171 178 break; … … 173 180 if (process_btn(wiimote, &buf[2], mesg_array) || 174 181 process_acc(wiimote, &buf[4], mesg_array)) { 175 err = -1;182 err = 1; 176 183 } 177 184 break; … … 179 186 if (process_btn(wiimote, &buf[2], mesg_array) || 180 187 process_ext(wiimote, &buf[4], 8, mesg_array)) { 181 err = -1;188 err = 1; 182 189 } 183 190 break; … … 186 193 process_acc(wiimote, &buf[4], mesg_array) || 187 194 process_ir12(wiimote, &buf[7], mesg_array)) { 188 err = -1;195 err = 1; 189 196 } 190 197 break; … … 192 199 if (process_btn(wiimote, &buf[2], mesg_array) || 193 200 process_ext(wiimote, &buf[4], 19, mesg_array)) { 194 err = -1;201 err = 1; 195 202 } 196 203 break; … … 199 206 process_acc(wiimote, &buf[4], mesg_array) || 200 207 process_ext(wiimote, &buf[7], 16, mesg_array)) { 201 err = -1;208 err = 1; 202 209 } 203 210 break; … … 206 213 process_ir10(wiimote, &buf[4], mesg_array) || 207 214 process_ext(wiimote, &buf[14], 9, mesg_array)) { 208 err = -1;215 err = 1; 209 216 } 210 217 break; … … 214 221 process_ir10(wiimote, &buf[7], mesg_array) || 215 222 process_ext(wiimote, &buf[17], 6, mesg_array)) { 216 err = -1;223 err = 1; 217 224 } 218 225 break; 219 226 case RPT_EXT21: 220 227 if (process_ext(wiimote, &buf[2], 21, mesg_array)) { 221 err = -1;228 err = 1; 222 229 } 223 230 break; … … 230 237 if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 231 238 free_mesg_array(mesg_array); 232 wiimote_err(wiimote, 233 "error dispatching mesg array"); 239 wiimote_err(wiimote, "error dispatching mesg array"); 234 240 } 235 241 } … … 254 260 } while (-1); 255 261 256 /* This should never execute */257 262 return NULL; 263 } 264 265 static int process_error(struct wiimote *wiimote, size_t len) 266 { 267 struct mesg_array *mesg_array; 268 struct wiimote_error_mesg *error_mesg; 269 int ret = 0; 270 271 /* Error message */ 272 if (len == 0) { 273 wiimote_err(wiimote, "Disconnect"); 274 } 275 else { 276 wiimote_err(wiimote, "Interrupt channel read error"); 277 } 278 279 if ((mesg_array = malloc(sizeof *mesg_array)) == NULL) { 280 wiimote_err(wiimote, "Error allocating mesg array"); 281 ret = -1; 282 goto SKIP_QUEUE_MESG; 283 } 284 mesg_array->count = 1; 285 if ((error_mesg = malloc(sizeof *error_mesg)) == NULL) { 286 wiimote_err(wiimote, "Error allocating error message"); 287 ret = -1; 288 goto SKIP_QUEUE_MESG; 289 } 290 error_mesg->type = WIIMOTE_MESG_ERROR; 291 if (len == 0) { 292 error_mesg->error = WIIMOTE_ERROR_DISCONNECT; 293 } 294 else { 295 error_mesg->error = WIIMOTE_ERROR_COMM; 296 } 297 mesg_array->mesg[0] = error_mesg; 298 if (queue_flush(wiimote->dispatch_queue, (free_func_t *)free_mesg_array)) { 299 wiimote_err(wiimote, "error flushing dispatch queue"); 300 ret = -1; 301 } 302 if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 303 free_mesg_array(mesg_array); 304 wiimote_err(wiimote, "error dispatching mesg array"); 305 ret = -1; 306 } 307 308 SKIP_QUEUE_MESG: 309 310 /* Cancel any RW operations in progress */ 311 wiimote->rw_error = 1; 312 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 313 wiimote_err(wiimote, "Error locking rw_cond_mutex: deadlock warning"); 314 ret = -1; 315 } 316 else { 317 if (pthread_cond_signal(&wiimote->rw_cond)) { 318 wiimote_err(wiimote, "Error signaling rw_cond: deadlock warning"); 319 ret = -1; 320 } 321 if (pthread_mutex_unlock( 322 &wiimote->rw_cond_mutex)) { 323 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: " 324 "deadlock warning"); 325 ret = -1; 326 } 327 } 328 329 return ret; 258 330 } 259 331 … … 497 569 error) { 498 570 wiimote_err(wiimote, "Error in read data"); 499 wiimote->rw_status = RW_ERROR; 571 wiimote->rw_error = 1; 572 wiimote->rw_status = RW_NONE; 500 573 ret = -1; 501 574 } … … 510 583 } 511 584 } 512 if (wiimote->rw_ status != RW_PENDING) {585 if (wiimote->rw_error || (wiimote->rw_status != RW_PENDING)) { 513 586 /* Lock rw_cond_mutex, signal rw_cond, unlock 514 587 * rw_cond_mutex */ 515 588 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 516 wiimote_err(wiimote, "Error locking rw_cond_mutex"); 589 wiimote_err(wiimote, "Error locking rw_cond_mutex: " 590 "deadlock warning"); 591 wiimote->rw_error = 1; 517 592 ret = -1; 518 593 } … … 521 596 wiimote_err(wiimote, "Error signaling rw_cond: " 522 597 "deadlock warning"); 598 wiimote->rw_error = 1; 523 599 ret = -1; 524 600 } … … 527 603 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: " 528 604 "deadlock warning"); 605 wiimote->rw_error = 1; 529 606 ret = -1; 530 607 } … … 534 611 else { 535 612 wiimote_err(wiimote, "Extraneous read data received"); 536 ret = 1;613 ret = -1; 537 614 } 538 615 … … 549 626 * write_cond_mutex */ 550 627 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 551 wiimote_err(wiimote, "Error locking rw_cond_mutex"); 628 wiimote_err(wiimote, "Error locking rw_cond_mutex: " 629 "deadlock warning"); 630 wiimote->rw_error = 1; 552 631 ret = -1; 553 632 } … … 556 635 wiimote_err(wiimote, "Error signaling rw_cond: " 557 636 "deadlock warning"); 637 wiimote->rw_error = 1; 558 638 ret = -1; 559 639 } … … 561 641 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: " 562 642 "deadlock warning"); 643 wiimote->rw_error = 1; 563 644 ret = -1; 564 645 } -
wiimote/queue.c
r00aa494 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * Added queue_flush 20 * * Reimplemented queue_free using queue_flush 21 * 18 22 * 03/14/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 23 * * audited error checking (coda and error handler sections) … … 58 62 { 59 63 int ret = 0; 64 65 if (queue_flush(queue, free_func)) { 66 ret = -1; 67 } 68 if (pthread_mutex_destroy(&queue->mutex)) { 69 ret = -1; 70 } 71 if (pthread_cond_destroy(&queue->cond)) { 72 ret = -1; 73 } 74 if (pthread_mutex_destroy(&queue->cond_mutex)) { 75 ret = -1; 76 } 77 78 free(queue); 79 80 return ret; 81 } 82 83 int queue_flush(struct queue *queue, free_func_t free_func) 84 { 60 85 struct queue_node *cursor, *tmp; 61 62 if (pthread_mutex_destroy(&queue->mutex)) { 63 ret = -1; 64 } 65 if (pthread_cond_destroy(&queue->cond)) { 66 ret = -1; 67 } 68 if (pthread_mutex_destroy(&queue->cond_mutex)) { 69 ret = -1; 86 int ret = 0; 87 int canceltype; 88 89 if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &canceltype)) { 90 return -1; 91 } 92 93 if (pthread_mutex_lock(&queue->mutex)) { 94 ret = -1; 95 goto CODA; 70 96 } 71 97 … … 79 105 cursor = tmp; 80 106 } 81 82 free(queue); 107 queue->head = NULL; 108 queue->p_tail = &queue->head; 109 110 if (pthread_mutex_unlock(&queue->mutex)) { 111 ret = -1; 112 goto CODA; 113 } 114 115 CODA: 116 if (pthread_setcanceltype(canceltype, &canceltype)) { 117 return -1; 118 } 83 119 84 120 return ret; -
wiimote/queue.h
rc033b7a r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith >cwiid@abstrakraft.org> 19 * * Added queue_flush prototype 20 * 18 21 * 03/03/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * Initial ChangeLog … … 41 44 42 45 struct queue *queue_new(); 46 int queue_flush(struct queue *queue, free_func_t free_func); 43 47 int queue_free(struct queue *queue, free_func_t free_func); 44 48 int queue_queue(struct queue *queue, void *data); -
wiimote/rw.c
r00aa494 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated wiimote_read and wiimote_write to trigger and detect rw_error 20 * 18 21 * 03/14/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * wiimote_read - changed to obey decode flag only for register read … … 57 60 int ret = 0; 58 61 int i; 59 uint8_t address_flags; 60 61 /* Lock wiimote rw access */ 62 if (pthread_mutex_lock(&wiimote->rw_mutex)) { 63 wiimote_err(wiimote, "Error locking rw_mutex"); 62 63 /* TODO: once this code has been tested, check for rw_error before printing 64 * error messages */ 65 66 /* Exit immediately if rw_error */ 67 if (wiimote->rw_error) { 64 68 return -1; 65 69 } 66 70 67 address_flags = flags & (WIIMOTE_RW_EEPROM | WIIMOTE_RW_REG);68 69 71 /* Compose read request packet */ 70 buf[0]= address_flags;72 buf[0]=flags & (WIIMOTE_RW_EEPROM | WIIMOTE_RW_REG); 71 73 buf[1]=(unsigned char)((offset>>16) & 0xFF); 72 74 buf[2]=(unsigned char)((offset>>8) & 0xFF); … … 75 77 buf[5]=(unsigned char)(len & 0xFF); 76 78 79 80 /* Lock wiimote rw access */ 81 if (pthread_mutex_lock(&wiimote->rw_mutex)) { 82 wiimote_err(wiimote, "Error locking rw_mutex"); 83 return -1; 84 } 85 86 /* Check for rw_error after mutex wait */ 87 if (wiimote->rw_error) { 88 ret = -1; 89 goto CODA; 90 } 91 77 92 /* Setup read info */ 78 93 wiimote->rw_status = RW_PENDING; … … 85 100 wiimote_err(wiimote, "Error sending read request"); 86 101 ret = -1; 87 } 102 goto CODA; 103 } 104 88 105 /* Lock rw_cond_mutex */ 89 elseif (pthread_mutex_lock(&wiimote->rw_cond_mutex)) {106 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 90 107 wiimote_err(wiimote, "Error locking rw_cond_mutex"); 91 108 ret = -1; 92 } 93 else { 94 /* Wait on condition, signalled by wiimote_int_listen */ 95 while ((!ret) && (wiimote->rw_status == RW_PENDING)) { 96 if (pthread_cond_wait(&wiimote->rw_cond, 97 &wiimote->rw_cond_mutex)) { 98 wiimote_err(wiimote, "Error waiting on rw_cond"); 99 ret = -1; 100 } 101 } 102 /* Unlock rw_cond_mutex */ 103 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 104 wiimote_err(wiimote, 105 "Error unlocking rw_cond_mutex: deadlock warning"); 106 } 107 108 /* Check status */ 109 if (wiimote->rw_status == RW_READY) { 110 ret = 0; 111 } 112 else { 109 goto CODA; 110 } 111 /* Wait on condition, signalled by int_listen */ 112 while (!wiimote->rw_error && !ret && (wiimote->rw_status == RW_PENDING)) { 113 if (pthread_cond_wait(&wiimote->rw_cond, 114 &wiimote->rw_cond_mutex)) { 115 wiimote_err(wiimote, "Error waiting on rw_cond"); 113 116 ret = -1; 114 } 115 } 116 117 /* can't goto CODA from here - unlock rw_cond_mutex first */ 118 } 119 } 120 /* Unlock rw_cond_mutex */ 121 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 122 wiimote_err(wiimote, "Error unlocking rw_cond_mutex"); 123 wiimote->rw_error = 1; 124 ret = -1; 125 goto CODA; 126 } 127 128 /* Check status */ 129 if (wiimote->rw_status != RW_READY) { 130 ret = -1; 131 } 132 133 CODA: 117 134 /* Clear rw_status */ 118 135 wiimote->rw_status = RW_NONE; … … 121 138 if (pthread_mutex_unlock(&wiimote->rw_mutex)) { 122 139 wiimote_err(wiimote, "Error unlocking rw_mutex: deadlock warning"); 123 } 124 125 /* Decode only for registers */ 126 if ((flags & WIIMOTE_RW_DECODE) && (flags & WIIMOTE_RW_REG)) { 140 wiimote->rw_error = 1; 141 } 142 143 /* Decode (only for register reads) */ 144 if ((ret == 0) && (flags & WIIMOTE_RW_DECODE) && 145 (flags & WIIMOTE_RW_REG)) { 127 146 for (i=0; i < len; i++) { 128 147 ((unsigned char *)data)[i] = DECODE(((unsigned char *)data)[i]); … … 141 160 int ret = 0; 142 161 162 /* TODO: once this code has been tested, check for rw_error before printing 163 * error messages */ 164 165 /* Exit immediately if rw_error */ 166 if (wiimote->rw_error) { 167 return -1; 168 } 169 170 /* Compose write packet header */ 171 buf[0]=flags; 172 143 173 /* Lock wiimote rw access */ 144 174 if (pthread_mutex_lock(&wiimote->rw_mutex)) { … … 147 177 } 148 178 149 /* Compose write packet header */150 buf[0]=flags;151 152 179 /* Send packets */ 153 while (!ret && (sent<len)) { 180 /* Check rw_error after mutex wait */ 181 while (!wiimote->rw_error && (sent<len)) { 182 wiimote->rw_status = RW_PENDING; 183 184 /* Compose write packet */ 154 185 buf[1]=(unsigned char)(((offset+sent)>>16) & 0xFF); 155 186 buf[2]=(unsigned char)(((offset+sent)>>8) & 0xFF); … … 162 193 } 163 194 memcpy(buf+5, data+sent, buf[4]); 164 wiimote->rw_status = RW_PENDING; 195 165 196 if (send_report(wiimote, 0, RPT_WRITE, RPT_WRITE_LEN, buf)) { 166 197 wiimote_err(wiimote, "Error sending write"); 167 198 ret = -1; 199 goto CODA; 168 200 } 169 201 /* Lock rw_cond_mutex */ … … 171 203 wiimote_err(wiimote, "Error locking rw_cond_mutex"); 172 204 ret = -1; 205 goto CODA; 173 206 } 174 207 else { 175 208 /* Wait on condition, signalled by wiimote_int_listen */ 176 while ((!ret) && (wiimote->rw_status == RW_PENDING)) { 209 while (!wiimote->rw_error && !ret && 210 (wiimote->rw_status == RW_PENDING)) { 177 211 if (pthread_cond_wait(&wiimote->rw_cond, 178 212 &wiimote->rw_cond_mutex)) { 179 213 wiimote_err(wiimote, "Error waiting on rw_cond"); 180 214 ret = -1; 215 /* can't goto CODA from here - 216 * unlock rw_cond_mutex first */ 181 217 } 182 218 } 183 219 /* Unlock rw_cond_mutex */ 184 220 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 185 wiimote_err(wiimote, 186 "Error unlocking rw_cond_mutex: deadlock warning"); 221 wiimote_err(wiimote, "Error unlocking rw_cond_mutex"); 222 wiimote->rw_error = 1; 223 ret = -1; 224 goto CODA; 187 225 } 188 226 227 /* Check for error from cond_wait */ 228 if (ret == -1) { 229 goto CODA; 230 } 231 189 232 /* Check status */ 190 if (wiimote->rw_status == RW_READY) { 191 ret = 0; 233 if (wiimote->rw_status != RW_READY) { 234 ret = -1; 235 goto CODA; 192 236 } 193 else {194 ret = -1;195 }196 237 } 197 238 sent+=buf[4]; 198 239 } 199 240 241 CODA: 200 242 /* Clear rw_status */ 201 243 wiimote->rw_status = RW_NONE; … … 204 246 if (pthread_mutex_unlock(&wiimote->rw_mutex)) { 205 247 wiimote_err(wiimote, "Error unlocking rw_mutex: deadlock warning"); 248 wiimote->rw_error = 1; 206 249 } 207 250 -
wiimote/wiimote.h
ra8b4be2 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * added wiimote_mesg_error message type 20 * 18 21 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * wiimote_connect now takes a pointer to bdaddr_t … … 125 128 WIIMOTE_MESG_NUNCHUK, 126 129 WIIMOTE_MESG_CLASSIC, 130 WIIMOTE_MESG_ERROR, 127 131 WIIMOTE_MESG_UNKNOWN 128 132 }; … … 133 137 WIIMOTE_EXT_CLASSIC, 134 138 WIIMOTE_EXT_UNKNOWN 139 }; 140 141 enum wiimote_error { 142 WIIMOTE_ERROR_DISCONNECT, 143 WIIMOTE_ERROR_COMM, 135 144 }; 136 145 … … 186 195 }; 187 196 197 struct wiimote_error_mesg { 198 enum wiimote_mesg_type type; 199 enum wiimote_error error; 200 }; 201 188 202 union wiimote_mesg { 189 203 enum wiimote_mesg_type type; … … 194 208 struct wiimote_nunchuk_mesg nunchuk_mesg; 195 209 struct wiimote_classic_mesg classic_mesg; 210 struct wiimote_error_mesg error_mesg; 196 211 }; 197 212 -
wiimote/wiimote_internal.h
rd2323a5 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * moved RW error state to separate member 20 * 18 21 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * removed WIIMOTE_CMP_LEN macro and wiimote_findfirst prototype … … 132 135 RW_NONE, 133 136 RW_PENDING, 134 RW_READY, 135 RW_ERROR 137 RW_READY 136 138 }; 137 139 … … 158 160 pthread_mutex_t rw_cond_mutex; 159 161 enum rw_status rw_status; 162 char rw_error; 160 163 void *read_buf; 161 164 uint16_t read_len; -
wmdemo/wmdemo.c
r2744ad3 r09bfa38 1 1 #include <stdarg.h> 2 2 #include <stdio.h> 3 #include <stdlib.h> 3 4 4 5 #include <wiimote.h> … … 36 37 } 37 38 39 /* wiimote handle */ 40 wiimote_t *wiimote; 41 38 42 int main(int argc, char *argv[]) 39 43 { 40 44 bdaddr_t bdaddr; /* bluetooth device address */ 41 wiimote_t *wiimote; /* wiimote handle */42 45 int wiimote_id; /* wiimote id: useful for handling multiple wiimotes 43 46 with a single callback */ … … 237 240 mesg[i]->classic_mesg.l, mesg[i]->classic_mesg.r); 238 241 break; 242 case WIIMOTE_MESG_ERROR: 243 if (wiimote_disconnect(wiimote)) { 244 fprintf(stderr, "Error on wiimote disconnect\n"); 245 exit(-1); 246 } 247 exit(0); 248 break; 239 249 default: 240 250 printf("Unknown Report"); -
wmgui/main.c
rcee0ded r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 04/04/2007 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * disconnect on wiimote_mesg_error 20 * 18 21 * 04/03/2007 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * commented custom wiimote_err (causing Xlib errors) … … 1059 1062 wiimote_classic(&mesg_array[i]->classic_mesg); 1060 1063 break; 1064 case WIIMOTE_MESG_ERROR: 1065 menuDisconnect_activate(); 1066 break; 1061 1067 default: 1062 1068 break; -
wminput/main.c
rb9d3519 r09bfa38 16 16 * 17 17 * ChangeLog: 18 * 03/03/2007 L. Donnie Smith <cwiid@abstrakraft.rg> 18 * 04/04/2007 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * exit on wiimote_error 20 * 21 * 03/03/2007 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * Initial ChangeLog 20 23 * * type audit (stdint, const, char booleans) … … 27 30 #include <pthread.h> 28 31 #include <signal.h> 32 #include <sys/types.h> 29 33 #include <unistd.h> 30 34 … … 266 270 process_classic_mesg((struct wiimote_classic_mesg *) mesg[i]); 267 271 break; 272 case WIIMOTE_MESG_ERROR: 273 if (kill(getpid(),SIGINT)) { 274 wminput_err("error sending SIGINT"); 275 } 276 break; 268 277 default: 269 278 break;
