PyGame and touchscreen

人走茶凉 提交于 2019-12-04 18:48:55

I think what's happening is you're doing a button up, button down methond.

I get my pygame GUI to work by going...

click = pygame.mouse.get_pressed()

if x+w > mouse_pos[0] > x and y+h > mouse_pos[1] > y:
    pygame.draw.rect(screen, ac,(x,y,w,h))
    if click[0] == 1 and action != None:
            action()

HOWEVER for me this creates other issues because I don't think that 1 tap on the touch screen is a SMOOTH single click. What happens for me is that my button will click, then it will for no apparent reason do a second 'click' (I think because of 'fuzz' in the click).

As a result, my 'on' buttons turn on (they work perfectly) and then they turn off. Not quite sure what to do about that yet, but hopefully it gets your project working.

Did you check that your /dev/input/touchscreen is "linked" to the right module? Check evtest /dev/input/touchscreen and check if it does anything when using the screen, or the keyboard, or the mouse!

If this is happening you should follow the install procedure again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!