Linux Keyboard Input
I found out this summer that Linux generates a false keyup for every key down when doing key repeating. Recently I found that when I am generating a lot of triangles my keyboard input causes lag unless I go into config options and set the delay to 0. Is there any way to change the keyboard handling just for my program without resorting to some kind of half-assed buffer scheme, as I have been doing?
"It's like naming him Asskicker Monstertrucktits O'Ninja" -Khaiy
Most important question: What API are you using?
Without an answer to that, nobody will be able to help you.
One complete shot in the dark: Are you processing all keyboard events immediately as soon as they arrive? I've seen people who only read one keyboard event per frame; that will obviously lead to keyboard lag when the framerate gets lower.
Without an answer to that, nobody will be able to help you.
One complete shot in the dark: Are you processing all keyboard events immediately as soon as they arrive? I've seen people who only read one keyboard event per frame; that will obviously lead to keyboard lag when the framerate gets lower.
Widelands - laid back, free software strategy
You can just pull all those messages off in one go using something like XCheckWindowEvent to find matching keycodes and culling them.
The other answer is yes, you can turn the repeat off. However, you have to do it on a displaywide basis so it's a bit frowned upon.
Prefect is right about making sure you pull all the pending events -- if you're selecting on the fd and then reading an event, the select (or epoll or whatever) will kick again, but really you should loop reading events before that. Annoyingly there's no easy way to ask for an event "if there are any" -- You'll need to use something like XCheckIfEvent() and pass it a suitable matching routine and then use XCheckWindowEvent() to read them.
The other answer is yes, you can turn the repeat off. However, you have to do it on a displaywide basis so it's a bit frowned upon.
Prefect is right about making sure you pull all the pending events -- if you're selecting on the fd and then reading an event, the select (or epoll or whatever) will kick again, but really you should loop reading events before that. Annoyingly there's no easy way to ask for an event "if there are any" -- You'll need to use something like XCheckIfEvent() and pass it a suitable matching routine and then use XCheckWindowEvent() to read them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement