This shows you the differences between two versions of the page.
— |
coding:wiimote [2009/06/07 23:58] (current) robm created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Wiimote ====== | ||
+ | I've wanted to use my Wiimote to control my PC for some time now, and finally got around to trying it all out. | ||
+ | Getting the wiimote connected to my PC was easy - just install '' | ||
+ | |||
+ | There' | ||
+ | |||
+ | ===== Doing it myself ===== | ||
+ | I wanted to play with it myself, so I installed '' | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | # Wiimote experiments. Hopefully this' | ||
+ | # wminput (or emulate it to the same affect) | ||
+ | |||
+ | import os | ||
+ | import sys | ||
+ | import time | ||
+ | import cwiid | ||
+ | |||
+ | wiimote = None | ||
+ | print "Press 1+2 on the Wiimote now..." | ||
+ | while not wiimote: | ||
+ | try: | ||
+ | wiimote = cwiid.Wiimote() | ||
+ | except e: | ||
+ | print e | ||
+ | print " | ||
+ | time.sleep(0.5) | ||
+ | |||
+ | wiimote.led = cwiid.LED1_ON | cwiid.LED2_ON | cwiid.LED3_ON | cwiid.LED4_ON | ||
+ | wiimote.rumble = True | ||
+ | time.sleep(0.4) | ||
+ | wiimote.rumble = False | ||
+ | wiimote.led = cwiid.LED1_ON | cwiid.LED4_ON | ||
+ | |||
+ | print wiimote.state | ||
+ | |||
+ | wiimote.enable(cwiid.FLAG_MESG_IFC) # | ||
+ | wiimote.rpt_mode = cwiid.RPT_BTN | ||
+ | while True: | ||
+ | messages = wiimote.get_mesg() | ||
+ | |||
+ | for mtype, m in messages: | ||
+ | if mtype == cwiid.MESG_BTN: | ||
+ | for x in dir(cwiid): | ||
+ | if not x.startswith(" | ||
+ | if eval(" | ||
+ | print x | ||
+ | break | ||
+ | if m == cwiid.BTN_A | cwiid.BTN_B: | ||
+ | print "A + B, exiting" | ||
+ | wiimote.disable(cwiid.FLAG_MESG_IFC) | ||
+ | wiimote.rpt_mode = 0 | ||
+ | wiimote.close() | ||
+ | exit # Causes a segfault.. (why?) | ||
+ | |||
+ | elif mtype == cwiid.MESG_ERROR: | ||
+ | for x in dir(cwiid): | ||
+ | if not x.startswith(" | ||
+ | if eval(" | ||
+ | print x | ||
+ | break | ||
+ | |||
+ | else: | ||
+ | for x in dir(cwiid): | ||
+ | if not x.startswith(" | ||
+ | if eval(" | ||
+ | print x | ||
+ | break | ||
+ | </ | ||
+ | |||
+ | Next I need to workout how to inject things into X11, probably via ''/ |