diff --git a/python/Wiimote.c b/python/Wiimote.c index 5a99ff1..6e8928d 100644 --- a/python/Wiimote.c +++ b/python/Wiimote.c @@ -691,7 +691,7 @@ static PyObject *Wiimote_write(Wiimote *self, PyObject *args, PyObject *kwds) static void CallbackBridge(cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], struct timespec *t) { - PyObject *ArgTuple; + PyObject *ArgTuple, *Time; PyObject *PySelf; PyGILState_STATE gstate; @@ -701,8 +701,9 @@ static void CallbackBridge(cwiid_wiimote_t *wiimote, int mesg_count, /* Put id and the list of messages as the arguments to the callback */ PySelf = (PyObject *) cwiid_get_data(wiimote); - if (!PyObject_CallFunction(((Wiimote *)PySelf)->callback, "(O)", - ArgTuple)) { + if (!PyObject_CallFunction(((Wiimote *)PySelf)->callback, "(O, d)", + ArgTuple, + t->tv_sec + ((double) t->tv_nsec) * 1e-9)) { PyErr_Print(); } diff --git a/wmdemo/wmdemo.py b/wmdemo/wmdemo.py index c7f8b6b..a747ff5 100755 --- a/wmdemo/wmdemo.py +++ b/wmdemo/wmdemo.py @@ -143,7 +143,8 @@ def print_state(state): state['classic']['l_stick'], state['classic']['r_stick'], state['classic']['l'], state['classic']['r']) -def callback(mesg_list): +def callback(mesg_list, time): + print 'time: %f' % time for mesg in mesg_list: if mesg[0] == cwiid.MESG_STATUS: print 'Status Report: battery=%d extension=' % \ @@ -167,7 +168,7 @@ def callback(mesg_list): elif mesg[0] == cwiid.MESG_IR: valid_src = False print 'IR Report: ', - for src in state['ir_src']: + for src in mesg[1]: if src: valid_src = True print src['pos'],