summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a06a69f)
'''This runs in a separate thread'''
global wiiuse
import PyWiiUse as wiiuse # import here to avoid thread problems on windows
'''This runs in a separate thread'''
global wiiuse
import PyWiiUse as wiiuse # import here to avoid thread problems on windows
- self.wiimotes = wiiuse.init(self.nmotes, range(self.nmotes), self.event_cb,
- self.control_cb, self.disconnect_cb)
+ self.wiimotes = wiiuse.init(self.nmotes)
found = wiiuse.find(self.wiimotes, self.nmotes, self.timeout)
self.actual_nmotes = wiiuse.connect(self.wiimotes, self.nmotes)
found = wiiuse.find(self.wiimotes, self.nmotes, self.timeout)
self.actual_nmotes = wiiuse.connect(self.wiimotes, self.nmotes)
self.startup.put(self.go)
while self.go:
self.startup.put(self.go)
while self.go:
- try:
- wiiuse.poll(self.wiimotes, self.nmotes)
- except:
+ try :
+ if wiiuse.poll(self.wiimotes, self.nmotes) :
+ for i in range(self.nmotes):
+ m = self.wiimotes[i]
+ if m[0].event == wiiuse.EVENT:
+ self.event_cb(m)
+ except :
+
+ #try:
+ # wiiuse.poll(self.wiimotes, self.nmotes)
+ #except:
+ # pass
# allow executing functions in this thread
while True:
# allow executing functions in this thread
while True:
func, args = self.queue.get_nowait()
except Empty:
break
func, args = self.queue.get_nowait()
except Empty:
break
+ print 'do:', func.__name__, args
func(*args)
def do(self, func, *args):
func(*args)
def do(self, func, *args):
time=time.time(),
id=wm.unid))
time=time.time(),
id=wm.unid))
- if wiiuse.using_acc(wm):
pygame.event.post(pygame.event.Event(WIIMOTE_ACCEL,
orient=(wm.orient.roll, wm.orient.pitch,
wm.orient.yaw),
accel=(wm.gforce.x, wm.gforce.y, wm.gforce.z),
time=time.time(),
id=wm.unid))
pygame.event.post(pygame.event.Event(WIIMOTE_ACCEL,
orient=(wm.orient.roll, wm.orient.pitch,
wm.orient.yaw),
accel=(wm.gforce.x, wm.gforce.y, wm.gforce.z),
time=time.time(),
id=wm.unid))
- if wiiuse.using_ir(wm):
dots = [ (wm.ir.dot[i].visible, wm.ir.dot[i].x, wm.ir.dot[i].y) for i in range(4) ]
pygame.event.post(pygame.event.Event(WIIMOTE_IR,
dots=dots,
dots = [ (wm.ir.dot[i].visible, wm.ir.dot[i].x, wm.ir.dot[i].y) for i in range(4) ]
pygame.event.post(pygame.event.Event(WIIMOTE_IR,
dots=dots,
sys.exit(1)
wm = pygame_wiimote.Wiimote(0) # access the wiimote object
sys.exit(1)
wm = pygame_wiimote.Wiimote(0) # access the wiimote object
wm.enable_accels(1) # turn on acceleration reporting
w,h = size = (512,512)
wm.enable_accels(1) # turn on acceleration reporting
w,h = size = (512,512)