summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
00df52c)
app = Desktop()
synth = Synth()
app = Desktop()
synth = Synth()
- modeResolution = (1024,768)
+ screenResolution = (1024,768)
if wimoteSupport :
from pywiiuse import pygame_wiimouse
if wimoteSupport :
from pywiiuse import pygame_wiimouse
- from pywiiuse.PyWiiUse import IR_BELOW
- pygame_wiimouse.init(4, 5) # look for 4, wait 5 seconds
+ pygame_wiimouse.init(4, 5, screenResolution) # look for 4, wait 5 seconds
nwiimotes = pygame_wiimouse.get_count()
print '%d wiimotes' % nwiimotes
WT = pygame_wiimouse.WT
WT.pause()
nwiimotes = pygame_wiimouse.get_count()
print '%d wiimotes' % nwiimotes
WT = pygame_wiimouse.WT
WT.pause()
- wm = pygame_wiimouse.Wiimote(0) # access the wiimote object
- wm.enable_accels(0) # turn on acceleration reporting
- wm.enable_ir(1, vres = modeResolution, position=IR_BELOW)
else :
nwiimotes = 0
class _WTFacade :
else :
nwiimotes = 0
class _WTFacade :
def pause(self):
pass
def resume(self):
pass
def pause(self):
pass
def resume(self):
pass
+ def selectWiimote(self, i):
+ pass
- pygame.display.set_mode(modeResolution)
+ pygame.display.set_mode(screenResolution)
pygame.display.set_caption('MinWii')
while True :
pygame.display.set_caption('MinWii')
while True :
app.run(home)
app.close(home)
returnValue = home.returnValue
app.run(home)
app.close(home)
returnValue = home.returnValue
+ print 'home.selectedWiimoteIndex', home.selectedWiimoteIndex
if not returnValue :
break
if not returnValue :
break
- # sélection de l'instrument
+ WT.selectWiimote(home.selectedWiimoteIndex)
+
+ # sélection de l'instrument
selector = InstrumentSelector()
selector.run()
selector.stop()
selector = InstrumentSelector()
selector.run()
selector.stop()
self.tr()
self.td(Spacer(500,500))
self.tr()
self.td(Spacer(500,500))
+ @property
+ def selectedWiimoteIndex(self) :
+ return self.selectedWiimote.value
+
def _initLocalListeners(self) :
self.browseButton.connect(CLICK, self.open_file_browser)
self.quitButton.connect(CLICK, self._exitApp)
def _initLocalListeners(self) :
self.browseButton.connect(CLICK, self.open_file_browser)
self.quitButton.connect(CLICK, self._exitApp)
self.queue = Queue()
self.startup = Queue()
self.nmotes = nmotes
self.queue = Queue()
self.startup = Queue()
self.nmotes = nmotes
+ self.selectedWiimoteIndex = 0
self.timeout = timeout
self.setDaemon(1)
self._paused = False
self.timeout = timeout
self.setDaemon(1)
self._paused = False
if self._paused : continue
try :
if wiiuse.poll(self.wiimotes, self.nmotes) :
if self._paused : continue
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)
+ m = self.wiimotes[self.selectedWiimoteIndex]
+ if m[0].event == wiiuse.EVENT:
+ self.event_cb(m)
def resume(self) :
self._paused = False
def resume(self) :
self._paused = False
+
+ def selectWiimote(self, wiimoteIndex) :
+ self.selectedWiimoteIndex = wiimoteIndex
def do(self, func, *args):
'''Run the function in the thread handling the wiimote'''
def do(self, func, *args):
'''Run the function in the thread handling the wiimote'''
-def init(nmotes, timeout):
+def init(nmotes, timeout, screenResolution=(660, 370)):
'''Initialize the module.'''
global WT
if WT:
return
WT = wiimote_thread(nmotes, timeout)
'''Initialize the module.'''
global WT
if WT:
return
WT = wiimote_thread(nmotes, timeout)
+
+ nmotes = get_count()
+ for i in range(nmotes) :
+ wm = Wiimote(i) # access the wiimote object
+ wm.enable_accels(0) # turn off acceleration reporting
+ wm.enable_ir(1, vres = screenResolution, position=wiiuse.IR_BELOW)
+
def get_count():
'''How many Wiimotes were found?'''
def get_count():
'''How many Wiimotes were found?'''