I am using the procedure below to read if the mouse button has been clicked and released. It works on my desktop but it's buggy on my laptop
When I move my finger on the laptop's trackpad, evt.kind gives me a huge list of FingerMotion events mixed with some MouseMotion and after sometimes 8 to 10 seconds one FingerDown shows up with a MouseButtonDown
How do stop this flood of FingerMotion events?
while true:
discard ren.clear()
var mousedown : bool
var mouseup : bool
var evt = defaultEvent
if pollEvent(evt):
let mdown = evt.kind
if mdown == MouseButtonDown:
mousedown = true
elif mdown == MouseButtonUp:
mouseup = true
I now tried pressing a key
let e = evt.key()
if e.keysym.scancode == SDL_SCANCODE_ESCAPE:
break
and the same thing happened.on my laptop it takes 8 to 10 seconds for the key to take effect. I see this huge stream of finger events coming before the pressed key is computed
First of all, you should use pollEvent in while loop. Have you tried to read some documentation?
https://wiki.libsdl.org/SDL_PollEvent
http://lazyfoo.net/tutorials/SDL/03_event_driven_programming/index.php