mjf008
Posts: 1
Joined: Tue Dec 27, 2016 5:49 pm

Pygame cursor off position on touchscreen

Tue Dec 27, 2016 6:19 pm

Ive made a pygame program which displays some buttons to click which then switches some outputs on the gpio via the touchscreen. When I run the program from the raspberry gui it works perfectly no problems. However when I run the python program straight from the command line the cursor is way off.
I created a small test pygame gui with no buttons with the cursor displayed. Just to see where the cursor appears on the screen. When i touch the display its way off from where my finger touches the screen. Its like the screen isnt calibrated however from the raspberry gui it works fine. Could anyone help what might be wrong?

Cheers

Verifine
Posts: 2
Joined: Wed Dec 28, 2016 3:34 am

Re: Pygame cursor off position on touchscreen

Wed Dec 28, 2016 3:41 am

I'm a Python newbie - and I'm just starting to play with pygame. It's a Pi3 running Jessie with the official 7" touchscreen. Python 3.5.2 is installed. The touchscreen calibration is dead on when the Desktop displays, but when I run my simple test script the scaling appears to be way off, and the cursor acts as though it's set up for relative rather than absolute motion.

My test program draws three round buttons and determines whether the cursor is in a button when the MOUSEBUTTONUP event is detected. I can drag the cursor around and successfully 'hit' a button, but the cursor is never where my finger is.

Second test: If I do a multitouch, holding one finger still and moving the other, the cursor follows the moving finger well.

Verifine
Posts: 2
Joined: Wed Dec 28, 2016 3:34 am

Re: Pygame cursor off position on touchscreen

Wed Dec 28, 2016 4:15 pm

If I run the script as root, the cursor behaves badly. If I run it as the pi user, it seems OK.

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pygame cursor off position on touchscreen

Wed Dec 28, 2016 5:19 pm

Verifine wrote:If I run the script as root, the cursor behaves badly. If I run it as the pi user, it seems OK.
Then you have your solution, stop running as root. Why would you think you need to run as root anyway?
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Official Foundation Display”