Python with Wiimote using pywiiuse module

Posted by Anon on Stack Overflow See other posts from Stack Overflow or by Anon
Published on 2009-01-27T00:33:04Z Indexed on 2010/05/29 17:52 UTC
Read the original article Hit count: 422

Filed under:
|

After seeing the abilities and hackibility of wiimotes I really want to use it in my 'Intro to programming' final. Everyone must make a python program and present it to the class.

I want to make a game with pygame incorporating a wiimote. I found pywiiuse which is a very basic wrapper for the wiiuse library using c types.

I can NOT get anything beyond LEDs and vibrating to work. Buttons, IR, motion sensing, nothing. I've tried different versions of wiiuse, pywiiuse, even python. I can't even get the examples that came with it to run. Here's the code I made as a simple test. I copied some of the example C++ code.

from pywiiuse import *
from time     import sleep

#Init
wiimotes = wiiuse_init()

#Find and start the wiimote
found    = wiiuse_find(wiimotes,1,5)

#Make the variable wiimote to the first wiimote init() found
wiimote  = wiimotes.contents

#Set Leds
wiiuse_set_leds(wiimote,WIIMOTE_LED_1)

#Rumble for 1 second
wiiuse_rumble(wiimote,1)
sleep(1)
wiiuse_rumble(wiimote,0)

#Turn motion sensing on(supposedly)
wiiuse_motion_sensing(wiimote,1)

while 1:
    #Poll the wiimotes to get the status like pitch or roll
    if(wiiuse_poll(wiimote,1)):
        print 'EVENT'

And here's the output when I run it.

wiiuse version 0.9
wiiuse api version 8
[INFO] Found wiimote [assigned wiimote id 1].
EVENT
EVENT
Traceback (most recent call last):
  File "C:\Documents and Settings\Nick\Desktop\wiimotetext.py", line 26, in <mod
ule>
    if(wiiuse_poll(wiimote,1)):
WindowsError: exception: access violation reading 0x00000004

It seems each time I run it, it prints out EVENT 2-5 times until the trace back. I have no clue what to do at this point, I've been trying for the past two days to get it working.

Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about wii