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

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



Sounds all good.  I think I want to get a wii now :)  Just for the remotes.

For pygame integration posting events into the event queue would be a
good idea ( pygame.event.post ).  Maybe run in another thread, or
polled at the required frequency with pygame.time.set_timer ?

Cheers,

On 4/26/07, Luke Paireepinart <rabidpoobear@xxxxxxxxx> wrote:
Alex Holkner wrote:
> Luke Paireepinart wrote:
>
>>
>> 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?
>
>
> Polling (with optional timeout) is the PyGame/SDL way; any blocking or
> threaded API can then be layered on top if the application desires it.
The way the i/o works is that you pass an Overlapped structure to the
read method, then you call GetOverlappedResult with the
same overlapped structure to get the read result later.
So the way the built-in pygame.mouse and such work is that they keep
checking for input, and when they get it, they report it to
pygame.event, right?
I can just keep track of whether there's a read pending, and not start
another read until I get the result of the first read first.
I'd do this by calling GetOverlappedResult without blocking enabled [if
my readpending variable is set] so it will just return, and call that
every x milliseconds.
Then when I find out that something has given a result, I process the
input, start another read and repeat the cycle.  Is that what you mean
by polling?

should I let the user set the delay between reads, if there is no
result, or is there a recommended amount of time? (if there were a
result, I wouldn't delay, that way if there's a constant stream of input
it won't start lagging behind.)  The longer the delay, the less
processor is used by my library, and the more there is for games, but
the greater potential there is for input lag, right?
-Luke

>
> Alex.