diff -Naur cwiid-0.6.00/python/Wiimote.c cwiid-0.6.00.new/python/Wiimote.c
|
old
|
new
|
|
| 250 | 250 | |
| 251 | 251 | static PyObject *Wiimote_close(Wiimote *self) |
| 252 | 252 | { |
| | 253 | if (!self->wiimote) |
| | 254 | return NULL; |
| 253 | 255 | if (cwiid_close(self->wiimote)) { |
| 254 | 256 | PyErr_SetString(PyExc_RuntimeError, |
| 255 | 257 | "Error closing wiimote connection"); |
| … |
… |
|
| 266 | 268 | static char *kwlist[] = {"flags", NULL}; |
| 267 | 269 | int flags; |
| 268 | 270 | |
| | 271 | if (!self->wiimote) |
| | 272 | return NULL; |
| 269 | 273 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:cwiid.Wiimote.enable", |
| 270 | 274 | kwlist, &flags)) { |
| 271 | 275 | return NULL; |
| … |
… |
|
| 284 | 288 | static char *kwlist[] = {"flags", NULL}; |
| 285 | 289 | int flags; |
| 286 | 290 | |
| | 291 | if (!self->wiimote) |
| | 292 | return NULL; |
| 287 | 293 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:cwiid.Wiimote.disable", |
| 288 | 294 | kwlist, &flags)) { |
| 289 | 295 | return NULL; |
| … |
… |
|
| 303 | 309 | { |
| 304 | 310 | PyObject *OldCallback; |
| 305 | 311 | |
| | 312 | if (!self->wiimote) |
| | 313 | return NULL; |
| 306 | 314 | if (!PyCallable_Check(NewCallback)) { |
| 307 | 315 | PyErr_SetString(PyExc_TypeError, "callback must be callable!"); |
| 308 | 316 | } |
| … |
… |
|
| 337 | 345 | struct timespec t; |
| 338 | 346 | PyObject *PyMesg; |
| 339 | 347 | |
| | 348 | if (!self->wiimote) |
| | 349 | return NULL; |
| 340 | 350 | if (cwiid_get_mesg(self->wiimote, &mesg_count, &mesg, &t)) { |
| 341 | 351 | if (errno == EAGAIN) { |
| 342 | 352 | Py_RETURN_NONE; |
| … |
… |
|
| 360 | 370 | struct cwiid_state state; |
| 361 | 371 | PyObject *PyState; |
| 362 | 372 | |
| | 373 | if (!self->wiimote) |
| | 374 | return NULL; |
| 363 | 375 | if (cwiid_get_state(self->wiimote, &state)) { |
| 364 | 376 | PyErr_SetString(PyExc_IOError, "get state error"); |
| 365 | 377 | return NULL; |
| 366 | 378 | } |
| | 379 | if (!self->wiimote) |
| | 380 | return NULL; |
| 367 | 381 | |
| 368 | 382 | PyState = Py_BuildValue("{s:B,s:B,s:B,s:B,s:i,s:i}", |
| 369 | 383 | "rpt_mode", state.rpt_mode, |
| … |
… |
|
| 529 | 543 | int ext_type; |
| 530 | 544 | struct acc_cal acc_cal; |
| 531 | 545 | PyObject *PyAccCal; |
| 532 | | |
| | 546 | |
| | 547 | if (!self->wiimote) |
| | 548 | return NULL; |
| 533 | 549 | if (!PyArg_ParseTupleAndKeywords(args, kwds, |
| 534 | 550 | "i:cwiid.Wiimote.get_acc_cal", kwlist, |
| 535 | 551 | &ext_type)) { |
| … |
… |
|
| 566 | 582 | { |
| 567 | 583 | long led; |
| 568 | 584 | |
| | 585 | if (!self->wiimote) |
| | 586 | return NULL; |
| 569 | 587 | if (((led = PyInt_AsLong(PyLed)) == -1) && PyErr_Occurred()) { |
| 570 | 588 | return -1; |
| 571 | 589 | } |
| … |
… |
|
| 584 | 602 | { |
| 585 | 603 | long rumble; |
| 586 | 604 | |
| | 605 | if (!self->wiimote) |
| | 606 | return NULL; |
| 587 | 607 | if (((rumble = PyInt_AsLong(PyRumble)) == -1) && PyErr_Occurred()) { |
| 588 | 608 | return -1; |
| 589 | 609 | } |
| … |
… |
|
| 602 | 622 | { |
| 603 | 623 | long rpt_mode; |
| 604 | 624 | |
| | 625 | if (!self->wiimote) |
| | 626 | return NULL; |
| 605 | 627 | if (((rpt_mode = PyInt_AsLong(PyRptMode)) == -1) && PyErr_Occurred()) { |
| 606 | 628 | return -1; |
| 607 | 629 | } |
| … |
… |
|
| 640 | 662 | void *buf; |
| 641 | 663 | PyObject *pyRetBuf; |
| 642 | 664 | |
| | 665 | if (!self->wiimote) |
| | 666 | return NULL; |
| 643 | 667 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "BII:cwiid.Wiimote.read", |
| 644 | 668 | kwlist, &flags, &offset, &len)) { |
| 645 | 669 | return NULL; |
| … |
… |
|
| 669 | 693 | void *buf; |
| 670 | 694 | int len; |
| 671 | 695 | |
| | 696 | if (!self->wiimote) |
| | 697 | return NULL; |
| 672 | 698 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "BIt#:cwiid.Wiimote.write", |
| 673 | 699 | kwlist, &flags, &offset, &buf, &len)) { |
| 674 | 700 | return NULL; |
| … |
… |
|
| 690 | 716 | PyObject *PySelf; |
| 691 | 717 | PyGILState_STATE gstate; |
| 692 | 718 | |
| | 719 | if (!wiimote) |
| | 720 | return NULL; |
| 693 | 721 | gstate = PyGILState_Ensure(); |
| 694 | 722 | |
| 695 | 723 | ArgTuple = ConvertMesgArray(mesg_count, mesg); |