ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi folks,
I have an issue with a program I'm writing. I'm using SDL to capture keyboard events. When I press an arrow key (Left, Right, UP or Down), the program works just as it should. The problem arises when I press a second button. The first key pressed seems to remain in the queue and executes again and is immediately followed by the second command.
For example:
If I press the UP arrow, it moves an object up...then if I press the left arrow, it moves the object up and then to the left.
I did suspect that you were falling through the case statement yet this seems not to be the case(is this the actual code? ) and I am unsure of why this is happening; but I have to say I think you are handling key presses wrongly. Only detecting a key release is a strange method to use.
is this for a game?
which version of SDL are you using
which operating system?
How old is the keyboard you are using?
Yeah. This is for a game. It does the same thing under Fedora Core 6 and 7 using SDL-1.2.11-1.fc6 and SDL-1.2.12-1.fc7 respectively. My keyboard is a standard keyboard.
You mentioned that only using the key release is strange...but what is the standard method. I did this to try and resolve the double action issue, but it didn't resolve it.
Hmmm..... Actually it is inside another loop. I have a while inside a while. That was done to solve another issue with closing the program without error. I'll see what happens... Thanks. -Andrew
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.