Skip to content

Commit

Permalink
Add time to python mesg_callback to match C usage
Browse files Browse the repository at this point in the history
git-svn-id: http://abstrakraft.org/cwiid/svn/trunk@184 918edb2d-ff29-0410-9de2-eb38e7f22bc7
  • Loading branch information
abstrakraft committed Sep 29, 2009
1 parent c5dd7d4 commit f795f95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions python/Wiimote.c
Expand Up @@ -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;

Expand All @@ -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();
}

Expand Down
5 changes: 3 additions & 2 deletions wmdemo/wmdemo.py
Expand Up @@ -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=' % \
Expand All @@ -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'],
Expand Down

0 comments on commit f795f95

Please sign in to comment.