summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
255d3c7)
-from ctypes import c_char_p, c_int, c_byte, c_uint, c_uint16, c_float, c_short, c_void_p, c_char
+from ctypes import c_char_p, c_int, c_byte, c_uint, c_uint16, c_float, c_short, c_void_p, c_char, c_ubyte, c_ushort
from ctypes import CFUNCTYPE, Structure, POINTER, Union, byref, cdll
from ctypes.util import find_library
import sys
from ctypes import CFUNCTYPE, Structure, POINTER, Union, byref, cdll
from ctypes.util import find_library
import sys
+class vec3w(_Structure):
+ _fields_ = [('x', c_ushort),
+ ('y', c_ushort),
+ ('z', c_ushort),
+ ]
+
class vec3f(_Structure):
_fields_ = [('x', c_float),
('y', c_float),
class vec3f(_Structure):
_fields_ = [('x', c_float),
('y', c_float),
self.roll, self.pitch, self.yaw, self.a_roll, self.a_pitch)
class accel(_Structure):
self.roll, self.pitch, self.yaw, self.a_roll, self.a_pitch)
class accel(_Structure):
- _fields_ = [('cal_zero', vec3b),
- ('cal_g', vec3b),
+ _fields_ = [('cal_zero', vec3w),
+ ('cal_g', vec3w),
('st_roll', c_float),
('st_pitch', c_float),
('st_alpha', c_float),
('st_roll', c_float),
('st_pitch', c_float),
('st_alpha', c_float),
('js', joystick),
('flags', POINTER(c_int)),
('btns', c_byte),
('js', joystick),
('flags', POINTER(c_int)),
('btns', c_byte),
('btns_held', c_byte),
('btns_released', c_byte),
('orient_threshold', c_float),
('btns_held', c_byte),
('btns_released', c_byte),
('orient_threshold', c_float),
- ('accel_threshold', c_int),
- ('accel', vec3b),
+ ('accel_threshold', c_float),
+ ('accel', vec3w),
('orient', orient),
('gforce', vec3f),
]
class classic_ctrl(_Structure):
_fields_ = [('btns', c_short),
('orient', orient),
('gforce', vec3f),
]
class classic_ctrl(_Structure):
_fields_ = [('btns', c_short),
+ ('btns_last', c_short),
('btns_held', c_short),
('btns_released', c_short),
('r_shoulder', c_float),
('btns_held', c_short),
('btns_released', c_short),
('r_shoulder', c_float),
class guitar_hero_3(_Structure):
_fields_ = [('btns', c_short),
class guitar_hero_3(_Structure):
_fields_ = [('btns', c_short),
+ ('btns_last', c_short),
('btns_held', c_short),
('btns_released', c_short),
('whammy_bar', c_float),
('js', joystick),
]
('btns_held', c_short),
('btns_released', c_short),
('whammy_bar', c_float),
('js', joystick),
]
+class motion_plus(_Structure):
+ _fields_ = [('rx', c_short),
+ ('ry', c_short),
+ ('rz', c_short),
+ ('status', c_ubyte),
+ ('ext', c_ubyte)
+ ]
+
class expansion_union(Union):
_fields_ = [('nunchuk', nunchuk),
('classic', classic_ctrl),
('gh3', guitar_hero_3),
class expansion_union(Union):
_fields_ = [('nunchuk', nunchuk),
('classic', classic_ctrl),
('gh3', guitar_hero_3),
]
class expansion(_Structure):
]
class expansion(_Structure):
('exp_rjs_ang', c_float),
('exp_ljs_mag', c_float),
('exp_rjs_mag', c_float),
('exp_rjs_ang', c_float),
('exp_ljs_mag', c_float),
('exp_rjs_mag', c_float),
- ('exp_btns', c_uint16),
+ ('exp_btns', c_ushort),
('exp_r_shoulder', c_float),
('exp_l_shoulder', c_float),
('exp_r_shoulder', c_float),
('exp_l_shoulder', c_float),
+ ('drx', c_short),
+ ('dry', c_short),
+ ('drz', c_short),
('ir_ax', c_int),
('ir_ay', c_int),
('ir_distance', c_float),
('orient', orient),
('ir_ax', c_int),
('ir_ay', c_int),
('ir_distance', c_float),
('orient', orient),
('normal_timeout', c_byte),
('exp_timeout', c_byte),
]
('normal_timeout', c_byte),
('exp_timeout', c_byte),
]
+
+elif sys.platform == 'darwin' :
+ JunkSkip = [('device', c_void_p),
+ ('bdaddr_str', c_char*18)
+ ]
+
else:
JunkSkip = [('bdaddr', c_void_p),
('bdaddr_str', c_char*18),
else:
JunkSkip = [('bdaddr', c_void_p),
('bdaddr_str', c_char*18),
('state', c_int),
('leds', c_byte),
('battery_level', c_float),
('state', c_int),
('leds', c_byte),
('battery_level', c_float),
('handshake_state', c_byte),
('handshake_state', c_byte),
+ ('expansion_state', c_ubyte),
+ ('data_req', c_void_p),
+
+ ('cmd_head', c_void_p),
+ ('cmd_tail', c_void_p),
('accel_calib', accel),
('exp', expansion),
('accel_calib', accel),
('exp', expansion),
('orient', orient),
('gforce', vec3f),
('orient', orient),
('gforce', vec3f),
- ('btns', c_uint16),
- ('btns_held', c_uint16),
- ('btns_released', c_uint16),
+
+ ('btns', c_ushort),
+ ('btns_last', c_ushort),
+ ('btns_held', c_ushort),
+ ('btns_released', c_ushort),
('orient_threshold', c_float),
('accel_threshold', c_int),
('orient_threshold', c_float),
('accel_threshold', c_int),
('lstate', wiimote_state),
('lstate', wiimote_state),
('event', c_int),
('event_buf', c_byte*32),
('event', c_int),
('event_buf', c_byte*32),
+ ('motion_plus_id', c_ubyte*6)
]
wiimote_p = POINTER(wiimote)
]
wiimote_p = POINTER(wiimote)
-def handle_event(wm):
- print '--- EVENT [wiimote id %i] ---' % wm.unid, wm.btns, wm.btns_held, wm.btns_released
+def handle_event(wmp):
+ wm = wmp[0]
+ print '--- EVENT [wiimote id %i] ---' % wm.unid
if wm.btns:
for name,b in wiiuse.button.items():
if wiiuse.is_pressed(wm, b):
if wm.btns:
for name,b in wiiuse.button.items():
if wiiuse.is_pressed(wm, b):
for i in range(nmotes):
wiiuse.set_leds(wiimotes[i], wiiuse.LED[i])
for i in range(nmotes):
wiiuse.set_leds(wiimotes[i], wiiuse.LED[i])
+ print 'adr:', wiimotes[i][0].bdaddr_str
#wiiuse.rumble(wiimotes[i], 1)
# for i in range(nmotes):
#wiiuse.rumble(wiimotes[i], 1)
# for i in range(nmotes):
wiiuse.motion_sensing(wiimotes[0], 1)
wiiuse.motion_sensing(wiimotes[0], 1)
-fp = file('mydata.txt', 'w')
-t0 = time.time()
try:
while True:
if wiiuse.poll(wiimotes, nmotes):
for i in range(nmotes):
m = wiimotes[i][0]
if wiimotes[i][0].event == wiiuse.EVENT:
try:
while True:
if wiiuse.poll(wiimotes, nmotes):
for i in range(nmotes):
m = wiimotes[i][0]
if wiimotes[i][0].event == wiiuse.EVENT:
- #handle_event(wiimotes[i][0])
- wm = wiimotes[i][0]
- t = time.time() - t0
- print >>fp, i, t, wm.gforce.x, wm.gforce.y, wm.gforce.z
+ handle_event(wiimotes[i])
except KeyboardInterrupt:
for i in range(nmotes):
wiiuse.set_leds(wiimotes[i], 0)
#wiiuse.disconnect(wiimotes[i])
except KeyboardInterrupt:
for i in range(nmotes):
wiiuse.set_leds(wiimotes[i], 0)
#wiiuse.disconnect(wiimotes[i])