![]() |
HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
I've packaged python-cwiid today and uploaded it to Extras-Devel for Fremantle. This is a small HOW-TO on interfacing with the Wiimote (Wii Remote) via Python.
Now, fire up a Python shell ("python" in X Terminal) and enter the following code: Code:
import cwiid Let's play a bit with the LEDs: Code:
import time Code:
for i in range(16): Code:
wm.rpt_mode = cwiid.RPT_BTN Code:
wm.state Code:
{'led': 15, 'rpt_mode': 2, 'ext_type': 0, 'buttons': 2, 'rumble': 0, 'error': 0, 'battery': 147} Code:
wm.state['buttons'] Code:
dir(cwiid) Code:
bool(wm.state['buttons'] & cwiid.BTN_A) Code:
wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC Code:
{'acc': (126, 127, 152), 'led': 15, 'rpt_mode': 6, 'ext_type': 0, 'buttons': 0, 'rumble': 0, 'error': 0, 'battery': 147}
Here's the code, you can abort it with Ctrl+C: Code:
import cwiid |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
That's brilliant I use cwiid on my laptop all the time and now it is available on my n900.
BTW: How did you successfully get cwiid to cross-compile? (I tried it a few months ago but it wouldn't work for me). Thanks for this :) |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
Works great, thanks!
Is there also a possibility in the future to read out the camera of the wiimote? |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
Quote:
Quote:
Code:
{'led': 1, 'ir_src': [{'pos': (475, 281), 'size': 1}, {'pos': (560, 663), 'size': 1}, {'pos': (723, 134), 'size': 3}, None], 'rpt_mode': 8, 'ext_type': 0, 'rumble': 0, 'error': 0, 'battery': 99} |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
Two questions... :)
1) Is it possible to connect more than one wiimote? 2) is it possible to use the speaker on the wiimote in any way?? Thanks! :D |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
Hi, great post, how i enable nunchuck report state, because the nunchuck it's connect the wiimote, but when i press the buttons on it, i can't see the info it's pressed,
For example: when i press the button B on wiimote (code on python) if (buttons & cwiid.BTN_B): print 'Button B pressed' --> i see this time.sleep(0.2) but when i press the button C on nunchuck if (buttons & cwiid.NUNCHUCK_BTN_C): print 'Button C nunchuck pressed' --> i canīt see this time.sleep(0.2) |
Re: HOWTO: Python Wiimote fun (LEDs, rumble, accel, buttons)
Wow, nice work :eek:
|
All times are GMT. The time now is 03:35. |
vBulletin® Version 3.8.8