WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wiimote Python Wrapper for Windows
Goto page 1, 2  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> General Windows Wiimote
View previous topic :: View next topic  
Author Message
ShortyTwoMeters



Joined: 21 Feb 2007
Posts: 3

Digg It
PostPosted: Wed Feb 21, 2007 8:33 am    Post subject: Wiimote Python Wrapper for Windows

I've developed this for use in a game I'm making in Python. It's based on the cWiiMote library v. 0.2 by Kevin Forbes (http://simulatedcomicproduct.com/2006/12/cwiimote-02.php).
This is in the Windows section because the HID access routines depend on certain Windows drivers.

The changes I've made to the library are at most superficial, made only to get the classes to wrap properly, and in some cases make certain data easier to access from Python. Wrapping was done with SWIG and dist-utils (included with modern Python installations). Files can be found at:

http://www.box.net/public/guj79a1pga

Installation:
Binary - unzip to lib/site-packages under your Python directory. This binary has been compiled for the Windows version of Python 2.5. To install under other versions of Python, see Source installation...

Source - unzip, and run "python setup.py install" to compile and install the module for your Python version. This should work if you've managed to get dist-utils working on your system. You will also need the library files "libhid.a" and "libsetupapi.a" somewhere in your library path for linking to succeed. Also you'll need SWIG since that's what does the actual wrapping!

Usage: Once installed, a simple test could be something like:

import pyWiimote
wiimote = pyWiimote.pyWiiMote()
wiimote.ConnectToDevice()
wiimote.SetLEDs(1, 0, 1, 0)

( note the case on pyWiimote.pyWiiMote() )

Function names are identical to those in cWiiMote - for now you'll have to look at the source to figure out what everything does, but I'll be putting up some documentation eventually. In Python, you could also do a dir(wiimote) to see what functions are available.
Back to top
View user's profile Send private message
France



Joined: 05 Mar 2007
Posts: 2

Digg It
PostPosted: Mon Mar 05, 2007 7:18 am    Post subject:

I haven't tried it yet, but awesome work. I was thinking about writing some science project in python to use with the wiimote.
Back to top
View user's profile Send private message
France



Joined: 05 Mar 2007
Posts: 2

Digg It
PostPosted: Tue Apr 17, 2007 6:18 am    Post subject:

Hi,

I got around to playing with this. I got the connection to work fine. Do you have any sample code i can look at to access the accel information??

Thanks!
Back to top
View user's profile Send private message
ZeNiTRaM



Joined: 22 Apr 2007
Posts: 1

Digg It
PostPosted: Sun Apr 22, 2007 7:53 pm    Post subject:

Hi, I'm trying to get some acceleration information using this module, but I get this:
Code:

>>> wiimote = pyWiimote.pyWiiMote()
>>> wiimote.ConnectToDevice()
False
>>> wiimote.ConnectToDevice()
True
>>> wiimote.GetCalibratedAcceleration(0, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Python25\lib\site-packages\pyWiimote.py", line 306, in GetCalibratedAcceleration
    def GetCalibratedAcceleration(*args): return _pyWiimote.pyWiiMote_GetCalibratedAcceleration(*args)
TypeError: in method 'pyWiiMote_GetCalibratedAcceleration', argument 2 of type 'float &'


What argument does the function expect? I tried with floats and ints, with no result. The lines on the C++ code are:
Code:
//Querying functions and structures:
void GetCalibratedAcceleration(float & x, float & y, float &z) const;


Could it be because of the space between the & and the x?
Back to top
View user's profile Send private message
tsunami01



Joined: 28 Apr 2007
Posts: 1

Digg It
PostPosted: Sat Apr 28, 2007 2:14 pm    Post subject: Request for binary release for use with python 2.4

Hello,

I've been trying to compile the source code with mingw32 to use the wiimote with Panda3d, an opensource game engine that is based on python 2.4. I haven't been able to accomplish this. It would be awesome if you could upload a version that is compiled for use with python2.4. Thanks a lot!
Back to top
View user's profile Send private message
grid



Joined: 21 Dec 2007
Posts: 6

Digg It
PostPosted: Sun Dec 23, 2007 11:03 am    Post subject:

ZeNiTRaM wrote:
Hi, I'm trying to get some acceleration information using this module, but I get this:
Code:

>>> wiimote = pyWiimote.pyWiiMote()
>>> wiimote.ConnectToDevice()
False
>>> wiimote.ConnectToDevice()
True
>>> wiimote.GetCalibratedAcceleration(0, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Python25\lib\site-packages\pyWiimote.py", line 306, in GetCalibratedAcceleration
    def GetCalibratedAcceleration(*args): return _pyWiimote.pyWiiMote_GetCalibratedAcceleration(*args)
TypeError: in method 'pyWiiMote_GetCalibratedAcceleration', argument 2 of type 'float &'


What argument does the function expect? I tried with floats and ints, with no result. The lines on the C++ code are:
Code:
//Querying functions and structures:
void GetCalibratedAcceleration(float & x, float & y, float &z) const;


Could it be because of the space between the & and the x?


same Problem!
Any resolutions?
Back to top
View user's profile Send private message
mhourahine



Joined: 16 Feb 2008
Posts: 1

Digg It
PostPosted: Sat Feb 16, 2008 4:12 pm    Post subject:

I've installed the binary version (I'm running Python 2.5) and I'm able to import the pyWiiMote library. However, running:

wiimote = pyWiimote.pyWiiMote()
wiimote.ConnectToDevice()

Always returns false (1st line runs without fail). I'm able to connect by Wiimote using test application that comes with the Managed Library from Ninendo's Wiimote (see MSDN Coding 4 fun blog) so I know my hardware is compatible.

Is there a higher level of error reporting or debugging I can use to see where it's failing?

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> General Windows Wiimote All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group