[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Re: loss of rapidly repeated keypresses (from a barcode gun keyboard)
On Wed, Dec 02, 2009 at 03:07:30PM -0600, Luke Paireepinart wrote:
> 3) Reading the SDL Mailing list, I learned that event loss when the
> event queue is full is already a topic of discussion for SDL1.3
>
> I wouldn't think this is the issue you're running into, otherwise you'd
> lose other characters too. It sounds like there's some debouncing code in
> the SDL keyboard input handler, which probably shouldn't be there...
Yes, that is right. "1234567890" never drops a single event, but
"1111111111" almost always drops all but one or two events... although
this behavior is strangely inconsistent. In my stripped-down mimimal
test app, the events are lost almost 100% of the time. In my actual full
aplication, the events are only ever lost on the first scan. Weird.
> I'm sure you've already thought of this, but you could always just open
> /dev/keyboard or whatever and manually post keyboard events yourself, or
> just use the keyboard data directly...
I have no idea where to look for the usb keyboard device associated with
the barcode scanner... and even if I could find it, I am fairly certain
that my app would have to be running as root if I wanted to read
directly fom it, so that would be unacceptable :(
> And you could even roll this in to
> a module so other people could use it too. Might be hard to make it
> cross-platform though and it sucks to have to completely throw out SDL's
> keyboard event handling. Also I don't know how you'd keep SDL from
> posting repeated events, I guess you'd just create your custom events
> under a different event ID and just watch for that ID instead.
Re-implementing my application in pygtk or wxpython sounds like a hell
of a lot less work :)
> 4) I also discovered, while searching for a workaround, an SDL mailing
> list post from Sam Lantinga last January mentioning a "simple callback
> mechanism for SDL events that bypasses the event queue". Does anybody
> know if there is a pygame way to make event callbacks?
>
> I don't know, but I'd guess it would be possible with Pygame-Ctypes. But
> I think Alex is no longer maintaining that module in preference to his
> Pyglet module.
I did a quick test with Pyglet, and it suffers from the same problem. I
take that to mean that using sdl event callbacks does not work around
this problem.
---
James Paige