[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Wii Remote support -- first patch



great work, I'm already looking forward to creating games for wii-controllers - I will definitly check out this wiimote package some time in the next weeks. Does it work under linux? from the last email it doesn't seem so but the code looks like it does??

greetings
 simon

On 4/25/07, Luke Paireepinart <rabidpoobear@xxxxxxxxx> wrote:
René Dudfield wrote:
> Hi,
>
> good links.
>
> It looks like someone is making a ctypes based library for windows
> based on that first code.
>
> Luke, are you reading this?  Did you get anywhere with your ctypes
> wiimote code?
Yep, I can read buttons and set LEDs and rumble right now.
I actually just started working on this again a few days ago.
There's been lots of school recently, but it's finals time so I have
long breaks between study sessions right now where I can code.
I'm writing it in such a way that the HID communication is abstracted
away from the actual wiimote library.
The HID stuff is all windows-dependent right now (calling windows DLLs
directly).
Currently it just uses kernel32.WriteFile for communication, which
doesn't work on all bluetooth stacks (you
use hid.hidD_SetOutputReport on the ones where WriteFile doesn't work)
but I don't have a stack
that doesn't work for WriteFile, so when I eventually write the
compatibility code that tries writefile and if
it fails, tries SetOutputReport, I'll ask the list if anyone wants to
give it a try.
I'm not actually using ctypes to interface with a compiled version of
cwiimote, I'm rewriting it in Python,
so that I can have more control over the structure of everything (or so
I'm telling myself... plus it's fun :D)

It was working perfectly last night but I'm refactoring the code and I
broke everything.
svn://commons.game-host.org/PyWiimote is the URL for SVN, but I didn't
commit when it was working (>_<)
so there's only the broken version right now.  I have a CS assignment
due at 5 pm tonight (binary search tree sorting cities by zipcode) but
after that I should have the rest of the week to work on the library, so
hopefully I'll get more done.
Eventually I'll write a cross-platform HID library, and we'll all be
happy :D
Unless someone else wants to do it?  All you have to do is find out what
the path is on your os for all the HID devices,
then open each one, make sure it's a wii remote, and then send output
reports to it whenever the write() method is called.
All the code it fairly simple, I've just been learning ctypes while I
did it, so it's taken a while.

Also, I'm using overlapped I/O for the reads/writes, but right after I
call the read and it returns control to me,
I call the kernel32.GetOverlappedResult to get the result, which is
blocking.
So  my question was:  Is it cool to run the wii remote's update method
in a thread, or should I recode it to where it doesn't
block and just returns nothing if it doesn't get a read within a few
milliseconds or something?
-Luke
>
> Cheers,
>
>
>
> On 4/25/07, Dave LeCompte (really) < dave@xxxxxxxxxxxx> wrote:
>> If people are interested in adding Windows support for this, they might
>> like to look at either
>>
>> http://simulatedcomicproduct.com/2006/12/cwiimote-02.php
>>
>> or
>>
>> http://digitalretrograde.com/projects/wiim/
>>
>> Both of them have source code that could be a useful starting point
>> for a
>> Windows/PyGame module. I was able to put a SWIG wrapper around CWiiMote
>> and read accelerometer and button inputs and set LED outputs with little
>> difficulty.
>>
>>
>> > Very cool.  Are you still working on this?
>> >
>> > On 12/18/06, robomancer <robomancer@xxxxxxxxx > wrote:
>> >> Hi all,
>> >>
>> >> I've created a first step toward Wii Remote support in Pygame.  Patch
>> >> is against 0.7.1 because the current SVN doesn't build for me.  I
>> >> expect that future patches will be against SVN head, or 0.8 when that
>> >> is released.  Let me know what you think.  You can download the
>> >> current sample code here:
>> >>
>> >> http://gs3080.sp.cs.cmu.edu/wiimote/
>> >>
>> >> Here's the README file:
>> >>
>> >> Preliminary Wii Remote support for Pygame.  This is definitely
>> >> proof-of-concept code, and is only likely to work in Linux.  The only
>> >> supported features are: discovering Wiimotes via Bluetooth, polling
>> >> the buttons and 3-axis force vector, and setting the LEDs.  The
>> >> wiimote.py module has useful docstrings for all public functions, so
>> >> "pydoc pygame.wiimote " should give you some helpful documentation
>> once
>> >> it's installed.  You can also just look at the LiiPong sample code.
>> >>
>> >> Files in this package:
>> >>
>> >> liipong-0.1.py
>> >>
>> >> Pong for Linux with the Wii Remote.  See the top of liipong-0.1.py
>> for
>> >> some setup instructions.  You can play 1-player or 2-player!  To play
>> >> 2-player, just sync 2 Wii Remotes when the game prompts you to.
>> >>
>> >> pygame-0.7.1-wiimote1.patch
>> >>
>> >> Patch to Pygame 0.7.1 that enables preliminary Wii Remote support.
>> >> I'll generate a new patch against Pygame 0.8 when that comes out (for
>> >> now, the SVN isn't building for me; I seem to need a new version of
>> >> SDL, which I'm too lazy to compile from scratch at the moment).
>> >>
>> >> __init__.py, locals.py, wiimote.py
>> >>
>> >> Full versions of the Pygame 0.7.1 files I changed to enable Wiimote
>> >> support.  If you don't want to use the patch program, you can just
>> >> drop these in to the lib/ directory of the Pygame-0.7.1 source
>> >> distribution.
>> >>
>> >> robomancer
>> >>
>> >
>>
>>
>