Changeset 128
- Timestamp:
- 06/18/07 19:28:49 (2 years ago)
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/python/Wiimote.c (modified) (19 diffs)
- trunk/wminput/conf.c (modified) (7 diffs)
- trunk/wminput/main.c (modified) (6 diffs)
- trunk/wminput/py_plugin.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r127 r128 1 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 2 wminput 3 * revised error messages 4 5 python 6 * revised error messages and doc strings 7 1 8 2007-06-14 L. Donnie Smith <cwiid@abstrakraft.org> 2 9 libcwiid trunk/python/Wiimote.c
r125 r128 20 20 * 21 21 * ChangeLog: 22 * 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 23 * * revised error messages and doc strings 24 * 22 25 * 2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 23 26 * * removed Wiimote_FromC function … … 97 100 { 98 101 {"close", (PyCFunction)Wiimote_close, METH_NOARGS, 99 "close wiimote connection"},102 "close()\n\nClose the Wiimote connection"}, 100 103 {"enable", (PyCFunction)Wiimote_enable, METH_VARARGS | METH_KEYWORDS, 101 "enable flags on wiimote"},104 "enable(flags)\n\nenable Wiimote connection flags"}, 102 105 {"disable", (PyCFunction)Wiimote_disable, METH_VARARGS | METH_KEYWORDS, 103 "disable flags on wiimote"},106 "disable(flags)\n\ndisable Wiimote connection flags"}, 104 107 {"get_mesg", (PyCFunction)Wiimote_get_mesg, METH_NOARGS, 105 " blocking call to get messages"},108 "get_mesg() -> message list\n\nretrieve message list from queue"}, 106 109 {"get_acc_cal", (PyCFunction)Wiimote_get_acc_cal, 107 METH_VARARGS | METH_KEYWORDS, "get accelerometer calibration"}, 110 METH_VARARGS | METH_KEYWORDS, 111 "get_acc_cal(extension) -> calibration tuple\n\n" 112 "retrieve calibration information"}, 108 113 {"request_status", (PyCFunction)Wiimote_request_status, METH_NOARGS, 109 "request status message"},114 "request_status()\n\nrequest status message"}, 110 115 {"read", (PyCFunction)Wiimote_read, METH_VARARGS | METH_KEYWORDS, 111 "read from wiimote"},116 "read(flags,offset,len) -> buffer\n\nread data from Wiimote"}, 112 117 {"write", (PyCFunction)Wiimote_write, METH_VARARGS | METH_KEYWORDS, 113 "write to wiimote"},118 "write(flags,offset,buffer)\n\nwrite data to Wiimote"}, 114 119 {NULL, NULL, 0, NULL} 115 120 }; … … 148 153 0, /* tp_as_buffer */ 149 154 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 150 " cwiid c-python interface", /* tp_doc */155 "CWiid Wiimote connection object", /* tp_doc */ 151 156 0, /* tp_traverse */ 152 157 0, /* tp_clear */ … … 194 199 } 195 200 196 static int cwiid_start(Wiimote *self, int flags)197 {198 cwiid_wiimote_t *wiimote;199 200 /* Set up wiimote */201 202 /* keep pyobject with wiimote */203 cwiid_set_data(wiimote,self);204 /* keep wiimote with pyobject */205 self->wiimote = wiimote;206 return 0;207 }208 209 201 static int Wiimote_init(Wiimote* self, PyObject* args, PyObject *kwds) 210 202 { … … 234 226 if (str_bdaddr) { 235 227 if (str2ba(str_bdaddr, &bdaddr)) { 236 PyErr_SetString(PyExc_ IOError, "bad bdaddr");228 PyErr_SetString(PyExc_ValueError, "bad bdaddr"); 237 229 return -1; 238 230 } … … 243 235 244 236 if (!(wiimote = cwiid_open(&bdaddr, flags))) { 245 PyErr_SetString(PyExc_IOError, "Could not open wiimote"); 237 PyErr_SetString(PyExc_RuntimeError, 238 "Error opening wiimote connection"); 246 239 return -1; 247 240 } … … 259 252 { 260 253 if (cwiid_close(self->wiimote)) { 261 PyErr_SetString(PyExc_IOError, "Wiimote close error"); 254 PyErr_SetString(PyExc_RuntimeError, 255 "Error closing wiimote connection"); 262 256 self->wiimote = NULL; 263 257 return NULL; … … 279 273 280 274 if (cwiid_enable(self->wiimote, flags)) { 281 PyErr_SetString(PyExc_ IOError, "cwiid_enable error");275 PyErr_SetString(PyExc_RuntimeError, "Error enabling wiimote flags"); 282 276 return NULL; 283 277 } … … 297 291 298 292 if (cwiid_disable(self->wiimote, flags)) { 299 PyErr_SetString(PyExc_ IOError, "cwiid_disable error");293 PyErr_SetString(PyExc_RuntimeError, "Error disabling wiimote flags"); 300 294 return NULL; 301 295 } … … 317 311 if ((OldCallback == Py_None) && (NewCallback != Py_None)) { 318 312 if (cwiid_set_mesg_callback(self->wiimote, CallbackBridge)) { 319 PyErr_SetString(PyExc_IOError, "set callback error"); 313 PyErr_SetString(PyExc_AttributeError, 314 "Error setting wiimote callback"); 320 315 return -1; 321 316 } … … 323 318 else if ((OldCallback != Py_None) && (NewCallback == Py_None)) { 324 319 if (cwiid_set_mesg_callback(self->wiimote, NULL)) { 325 PyErr_SetString(PyExc_IOError, "set callback error"); 320 PyErr_SetString(PyExc_AttributeError, 321 "Error clearing wiimote callback"); 326 322 return -1; 327 323 } … … 347 343 } 348 344 else { 349 PyErr_SetString(PyExc_IOError, "get_mesg error"); 345 PyErr_SetString(PyExc_RuntimeError, 346 "Error getting wiimote message list"); 350 347 return NULL; 351 348 } … … 541 538 542 539 if (cwiid_get_acc_cal(self->wiimote, ext_type, &acc_cal)) { 543 PyErr_SetString(PyExc_IOError, "Wiimote get acc cal error"); 540 PyErr_SetString(PyExc_RuntimeError, 541 "Error getting wiimote acc calibration"); 544 542 return NULL; 545 543 } … … 558 556 { 559 557 if (cwiid_request_status(self->wiimote)) { 560 PyErr_SetString(PyExc_ IOError, "Wiimote request status error");558 PyErr_SetString(PyExc_RuntimeError, "Error requesting wiimote status"); 561 559 return NULL; 562 560 } … … 574 572 575 573 if (cwiid_set_led(self->wiimote, (uint8_t)led)) { 576 PyErr_SetString(PyExc_IOError, "Wiimote set led error"); 574 PyErr_SetString(PyExc_AttributeError, 575 "Error setting wiimote led state"); 577 576 return -1; 578 577 } … … 591 590 592 591 if (cwiid_set_rumble(self->wiimote, (uint8_t)rumble)) { 593 PyErr_SetString(PyExc_IOError, "Wiimote set rumble error"); 592 PyErr_SetString(PyExc_AttributeError, 593 "Error setting wiimote rumble state"); 594 594 return -1; 595 595 } … … 608 608 609 609 if (cwiid_set_rpt_mode(self->wiimote, (uint8_t)rpt_mode)) { 610 PyErr_SetString(PyExc_IOError, "Wiimote set rpt_mode error"); 610 PyErr_SetString(PyExc_AttributeError, 611 "Error setting wiimote report mode"); 611 612 return -1; 612 613 } … … 653 654 } 654 655 if (cwiid_read(self->wiimote,flags,offset,len,buf)) { 655 PyErr_SetString(PyExc_ IOError, "Wiimote read error");656 PyErr_SetString(PyExc_RuntimeError, "Error reading wiimote data"); 656 657 Py_DECREF(pyRetBuf); 657 658 return NULL; … … 675 676 676 677 if (cwiid_write(self->wiimote, flags, offset, len, buf)) { 677 PyErr_SetString(PyExc_ IOError, "Wiimote write error");678 PyErr_SetString(PyExc_RuntimeError, "Error writing wiimote data"); 678 679 return NULL; 679 680 } trunk/wminput/conf.c
r125 r128 16 16 * 17 17 * ChangeLog: 18 * 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * revised error messages 20 * 18 21 * 2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * refactored to isolate plugin logic … … 71 74 if (yyparse()) { 72 75 if (fclose(yyin)) { 73 wminput_err(" error closing configuration file");76 wminput_err("Error closing configuration file"); 74 77 } 75 78 conf_unload(cur_conf); … … 488 491 489 492 if (conf->stack_index+1 >= CONF_MAX_INCLUDE_DEPTH) { 490 wminput_err(" maximum include depth exceeded: %s", filename);493 wminput_err("Maximum include depth exceeded: %s", filename); 491 494 return NULL; 492 495 } … … 512 515 513 516 if (!file) { 514 wminput_err(" file not found: %s", filename);517 wminput_err("File not found: %s", filename); 515 518 return NULL; 516 519 } … … 519 522 if ((conf->config_filename_stack[conf->stack_index] = 520 523 malloc(strlen(stackname) + 1)) == NULL) { 521 wminput_err(" out of memory");524 wminput_err("Error allocating pathname"); 522 525 conf->stack_index--; 523 526 return NULL; … … 581 584 582 585 if (i == CONF_MAX_PLUGINS) { 583 wminput_err(" maximum number of plugins exceeded");586 wminput_err("Maximum number of plugins exceeded"); 584 587 return NULL; 585 588 } … … 600 603 601 604 if (!plugin_found) { 602 wminput_err(" plugin not found: %s", name);605 wminput_err("Plugin not found: %s", name); 603 606 free(plugin->name); 604 607 plugin->name = NULL; trunk/wminput/main.c
r125 r128 16 16 * 17 17 * ChangeLog: 18 * 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * revised error messages 20 * 18 21 * 2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * refactored to isolate plugin logic … … 165 168 /* Setup search directory arrays */ 166 169 if ((tmp = getenv("HOME")) == NULL) { 167 wminput_err(" unable to find home directory");170 wminput_err("Unable to find home directory"); 168 171 config_search_dirs[0] = WMINPUT_CONFIG_DIR; 169 172 plugin_search_dirs[0] = CWIID_PLUGINS_DIR; … … 294 297 295 298 if (pthread_cancel(uinput_listen_thread)) { 296 wminput_err(" error canceling uinput listen thread");299 wminput_err("Error canceling uinput listen thread"); 297 300 ret = -1; 298 301 } 299 302 else if (pthread_join(uinput_listen_thread, NULL)) { 300 wminput_err(" error joing uinput listen thread");303 wminput_err("Error joining uinput listen thread"); 301 304 ret = -1; 302 305 } … … 304 307 /* disconnect */ 305 308 if (cwiid_close(wiimote)) { 306 wminput_err(" error ondisconnect");309 wminput_err("Error on wiimote disconnect"); 307 310 ret = -1; 308 311 } … … 329 332 330 333 if (cwiid_set_rpt_mode(wiimote, rpt_mode_flags)) { 331 wminput_err(" error setting report mode");334 wminput_err("Error setting report mode"); 332 335 return -1; 333 336 } … … 365 368 case CWIID_MESG_ERROR: 366 369 if (kill(getpid(),SIGINT)) { 367 wminput_err(" error sending SIGINT");370 wminput_err("Error sending SIGINT"); 368 371 } 369 372 break; trunk/wminput/py_plugin.c
r125 r128 16 16 * 17 17 * ChangeLog: 18 * 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * revised error messages 20 * 18 21 * 2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * relocated all python plugin logic here … … 75 78 { 76 79 {"set_rpt_mode", (PyCFunction)set_rpt_mode, METH_VARARGS | METH_KEYWORDS, 77 "set plugin report mode"},80 "set_rpt_mode(id, rpt_mode)\n\nset the plugin report mode"}, 78 81 {NULL, NULL, 0, NULL} 79 82 }; … … 111 114 /* note: PyWmPluginModule is a borrowed reference - do not decref */ 112 115 if (!(PyWmPluginModule = Py_InitModule3("wmplugin", Module_Methods, 113 "plugin interface for wminput"))) {116 "wminput plugin interface"))) { 114 117 PyErr_Print(); 115 118 goto ERR_HND; … … 124 127 } 125 128 } 126 127 PyRun_SimpleString("import sys; sys.path.append('.')");128 129 129 130 return 0; … … 227 228 228 229 if (!(plugin->p = malloc(sizeof(struct py_plugin)))) { 229 wminput_err(" malloc error");230 wminput_err("Error allocating py_plugin"); 230 231 return -1; 231 232 } … … 238 239 239 240 if (!(plugin->info = malloc(sizeof *plugin->info))) { 240 wminput_err(" malloc error");241 wminput_err("Error allocating plugin info"); 241 242 goto ERR_HND; 242 243 } 243 244 if (!(plugin->data = malloc(sizeof *plugin->data))) { 244 wminput_err(" malloc error");245 wminput_err("Error allocating plugin data"); 245 246 goto ERR_HND; 246 247 } … … 273 274 } 274 275 if (py_plugin_info(plugin, info)) { 275 wminput_err(" python_info error");276 wminput_err("Error on python_info"); 276 277 Py_DECREF((PyObject *)info); 277 278 goto ERR_HND; … … 334 335 if (!(PySequence_Check(PyButtonInfo) && PySequence_Check(PyAxisInfo) && 335 336 PySequence_Check(PyParamInfo))) { 336 wminput_err(" info not sequences");337 wminput_err("Type error in wminput_info: info not sequences"); 337 338 goto ERR_HND; 338 339 } … … 463 464 464 465 if (!(PySequence_Check(PyButtonData) && PySequence_Check(PyAxisData))) { 465 wminput_err(" exec not sequences");466 wminput_err("Type error on wminput_exec: exec not sequences"); 466 467 Py_DECREF(PyData); 467 468 return -1; … … 469 470 470 471 if (PySequence_Size(PyButtonData) != plugin->info->button_count) { 471 wminput_err(" execbad button sequence");472 wminput_err("Type error on wminput_exec: bad button sequence"); 472 473 Py_DECREF(PyData); 473 474 return -1; … … 485 486 } 486 487 else if (PyObj != Py_False) { 487 wminput_err(" execbad button value");488 wminput_err("Type error on wminput_exec: bad button value"); 488 489 Py_DECREF(PyObj); 489 490 Py_DECREF(PyData); … … 495 496 496 497 if (PySequence_Size(PyAxisData) != plugin->info->axis_count) { 497 wminput_err(" execbad axis sequence");498 wminput_err("Error on wminput_exec: bad axis sequence"); 498 499 Py_DECREF(PyData); 499 500 return -1; … … 510 511 } 511 512 else if (!PyInt_Check(PyObj)) { 512 wminput_err(" execbad axis value");513 wminput_err("Type error on wminput_exec: bad axis value"); 513 514 Py_DECREF(PyObj); 514 515 Py_DECREF(PyData);
