Touchscreen & Python/pygame


barnesy

Member
Joined
Sep 5, 2003
Messages
488
Website
Visit site
Hi all,

I'm having a play with some pygame stuff. I've modified this game: http://www.pygame.org/project-Lights+Out-1413-2534.html to make it fit the Pandora screen resolution. Those changes are working nicely, but the touchscreen seems to be behaving oddly.

While each click is registered properly on my desktop machine, the Pandora seems to register another click in the last click location each time I click somewhere else. If I keep clicking in one place, each click works properly. But when I click somewhere else, I get a click in the previous location, then the next click works in the new location. Which is quite a problem for this game!

Is this a bug or something I need to work around somehow? I'd expected the same code to behave the same way on the Pandora as on my desktop.

Cheers.
 
I don't have a pandora but I'm guessing it's doing a mousedown, then a drag, then a mouseup and mousedown at the new location? See if you can catch mousemotion events and print them to the console and see if a bunch show up. It might be doing that behind the scenes to help with some programs that don't work with absolute positioniong. I would hope it wouldn't do that but if it does there should be a way to turn it off anyway. Let me know though once you figure it out.

Also, do you happen to know how to get pressure readings for the touchscreen in Python? I'm writing a drawing app and I'd like to add support for the pressure sensitivity.
 
Thanks for the reply. Yeah, that sounds likely. The code currently only looks for a mousedown event, but I'll have a fiddle to see what other events it generates. Will post back here once I know more.

And no, I've no idea on the pressure sensitivity stuff. Google doesn't seem to be bursting with answers on that one either!

edit - Yeah, good call on the mousemotion events. A click seems to generate a mousemotion event then a mouse down event, then more mousemotion events until I lift the stylus. But if I click in one corner then the other corner, I get a mousemotion event with the coords of the previous click, a mousedown also with those coords, then a load of mousemotions with the right coords for the current stylus position. And I don't seem to get mousebuttonup events.
I've got my test program to treat mousedowns properly by using the mousemotion events to track the stylus position, and the mousedown to just trigger a click.
 
This sounds kind of familiar to a problem with the Touch Book. The touchscreen driver needs to be started with each touch, and experiences a lot of noise in the process, resulting in some erroneous points. This has been fixed in later versions of the OS, though I'm not sure how they did it.

If this is what's happening here, then the problem is at a low level, not in SDL or Pygame. Try using a painting app of some sort and see if you get the same effect as described in that bug report I linked.
 
Back
Top