Advertisement

Old Keyboard State in Input Handler

Started by July 03, 2014 10:34 PM
15 comments, last by iceman76 10 years, 6 months ago

There's one strange thing so far: if I hold both the g and b keys and then press h, the h isn't registered. I have no idea why that is at this point.


This is a common problem with non-mechanical and/or cheap keyboards. Due to the way they're constructed, they can only register a certain number of key presses at once, and pressing certain keys prevents other keys from being registered. The only solution (short of getting a better keyboard) is to allow users to change their keyboard bindings to avoid these issues.

There's one strange thing so far: if I hold both the g and b keys and then press h, the h isn't registered. I have no idea why that is at this point.


This is a common problem with non-mechanical and/or cheap keyboards. Due to the way they're constructed, they can only register a certain number of key presses at once, and pressing certain keys prevents other keys from being registered. The only solution (short of getting a better keyboard) is to allow users to change their keyboard bindings to avoid these issues.

Yes, I thought it might be something like that. It seems strange that it happens for two very specific combinations (of the ones I've tried), but I guess that may be due to the way the keyboard is wired.

 

Advertisement


but I guess that may be due to the way the keyboard is wired.

You can test your keyboard for ghosting issues (and read more about the issue) here:

http://www.microsoft.com/appliedsciences/antighostingexplained.mspx

Hello to all my stalkers.

Haegarr, you're right- the problem was that I was accidentally calling SDL_PumpEvents. Right before I check for the input in main program, there's this little snippet to exit when the user presses X:


//Handle events on the queue
while( SDL_PollEvent( &e ) != 0 ){
	//User requests quit
	if( e.type == SDL_QUIT ){
		quit = true;
	}
}

I read online several times that SDL_PollEvent calls SDL_PumpEvents internally, but it completely slipped my mind! Serves me right for purposefully ignoring this from the FAQ:

When posting code (which you should do if the problem is at all code-related), post it verbatim without transcribing or omitted code you believe is relevant as you can easily hide the problem that way.

Anyways, commenting out the above lines worked, so I can detect keyPressed and keyReleased to my heart's content! Of course, that means that you can't quit my program without resorting to the Windows Task Manager, but that's a feature, right? =P I've also changed the delete to delete[]

Thanks to everybody for helping me figure this out!


you can't quit my program without resorting to the Windows Task Manager, but that's a feature, right? =P

One man's feature is another man's bug. That, IMHO, is a bad "feature." Maybe just me, but I would remove your app (or not download it to be begin with) the moment I discovered that was the only method to terminate it. angry.png

Also just my humble opinion, but if an app (particularly a game) isn't dedicated to user convenience as it's first priority, it's not ready for distribution.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


One man's feature is another man's bug. That, IMHO, is a bad "feature." Maybe just me, but I would remove your app (or not download it to be begin with) the moment I discovered that was the only method to terminate it.

Not only that, but letting the "feature" inside is just a time bomb. After a while the developer things of new features based on input … and suddenly keyboard input is again no longer running. Such things should be wiped out at the roots.

Advertisement

Oh, don't worry, I am most certainly going to fix that. I was just joking about the same thing Buckeye said, actually- calling it a feature when it is so obviously a bug. Sorry that I wasn't clear. Also, this isn't something I'm planning on distributing, this is just me learning how to use SDL2 in the first place.

This topic is closed to new replies.

Advertisement