Affichage des wiimotes réellement disponibles.
[minwii.git] / src / pywiiuse / pygame_wiimouse.py
index 2c5911c..5e764ce 100755 (executable)
@@ -55,12 +55,6 @@ class wiimote_thread(Thread):
             except :
                 pass
                 
             except :
                 pass
                 
-            #try:
-            #    wiiuse.poll(self.wiimotes, self.nmotes)
-            #except:
-            #    pass
-
-            # allow executing functions in this thread
             while True:
                 try:
                     func, args = self.queue.get_nowait()
             while True:
                 try:
                     func, args = self.queue.get_nowait()
@@ -82,7 +76,26 @@ class wiimote_thread(Thread):
     def event_cb(self, wmp):
         '''Called when the library has some data for the user.'''
         wm = wmp[0]
     def event_cb(self, wmp):
         '''Called when the library has some data for the user.'''
         wm = wmp[0]
-        pygame.mouse.set_pos((wm.ir.x, wm.ir.y))
+        pos = (wm.ir.x, wm.ir.y)
+        pygame.mouse.set_pos(pos)
+        
+        eventType = None
+
+        if wm.btns and \
+            wiiuse.is_just_pressed(wm, wiiuse.button['B']) :
+                event = pygame.event.Event(pygame.MOUSEBUTTONDOWN,
+                                           pos = pos,
+                                           button = 1)
+                pygame.event.post(event)
+
+        if wm.btns_released and \
+            wiiuse.is_released(wm, wiiuse.button['B']):
+                event = pygame.event.Event(pygame.MOUSEBUTTONUP,
+                                           pos = pos,
+                                           button = 1)
+                pygame.event.post(event)
+                    
+                    
 
     def control_cb(self, wmp, attachment, speaker, ir, led, battery):
         '''Could check the battery level and such here'''
 
     def control_cb(self, wmp, attachment, speaker, ir, led, battery):
         '''Could check the battery level and such here'''