Skip to main content
GameDev.net gamedev.net
🔒 Locked

keyboard issue

Started by davj88 Jun 13, 2009 at 3:36 PM 4 replies 1k views
Original Post
davj88
davj88
hi guys! I'm coding a small shoot'em up game just for fun (visual studio 2008, c++, direct3d 2009 sdk, vista/xp). I have a quick question about receiving input from keyboard: what shall I use or what do you use? I've used directInput for a while but I've read it's not the correct/best way to handle input with keyboard (http://www.gamedev.net/community/forums/topic.asp?topic_id=459267) and I also have had some problems with usb keyboards using DI (if I press 2 buttons everything goes well, but if I press a third button the direction of my ship won't change. Quite strange, if I switch to a PS/2 keyboard the third button is recognized and processed and the ship changes direction as I expect. The whole bug affects both XP and Vista). On the other hand I've tried WM_INPUT (rawInput) and WM_KEYDOWN too, but they both share some "latency" problem which leads to some hard smoothness issue: http://www.gamedev.net/community/forums/topic.asp?topic_id=348728 "How can I achieve smooth, realtime keyboard input? I want input that is as sensitive as a gamepad and shooters like Quake. " I'm looking for a solution (make DI run on USB keyboards, obtain smooth movement with raw input, use a totally different API, make my own keyListener...) What would you use? What would you suggest? Where am I wrong? Thanks in advance! dav
Starfox
Starfox
*ANY* 3 buttons or a specific trio is giving you trouble? Keyboards have some HW limitations.
davj88
davj88
if I press, for example, up+right keys (arrow keys), the ship will move up & right, but if a press left the ship won't change its direction to "up left" as I want (and as a shoot them up user would expect, for example from the Touhou serie).
Sometimes I'll get just an "up" direction, as if right + left input results in no lateral movement, sometimes the ship will just keep going right+up as if I never pressed the 3rd arrow key...

I've also noticed is that... using NumPad 'arrows' works fine...
Pressing right+up and then right+up+left (on the NumPad) will change my direction to left+up in no time, as I want. I can't really get how keyboards work (both hardware and software aspects). I've tried 4 keyboards: 3 usb give me problems, 1 ps2 does not.

It'd be fine to fix the directInput issue, but finding some other solution would be good as well :)

Quote:
Original post by Starfox
Keyboards have some HW limitations.


What do you mean :)? Do you think that is the problem?

dav
davj88
davj88
mmm that was quite interesting :) still I can't understand why a 10 years old keyboard works "fine", and 3 "up-to-date" (3 o 4 years old) ones are giving me troubles. I'm a bit confused and I don't get if it's an hardware problem or if my code is wrong.

Any alternative idea?

dav
davj88
davj88
hi again, I've found something new.

I've googled around and noticed how keyboards have something called "rollover" (http://en.wikipedia.org/wiki/Rollover_(key)) to deal with. The problem with my keyboard/code sounds like:

"Modern keyboards detect ghosting and instead of registering a fourth key will ignore the third key, which is known as jamming. Which keys jam when pressed together differs between brands and models of keyboards."

So I have made some tests.

I've found out that:
3 out of 3 PS2 keyboards have no jamming problems at all (XP/VISTA).
3 out of 3 USB keyboards have no jamming problems with XP, but they ALL have problems with Vista.

I've also read some whining about FPS (counter strike, etc) having problem using multiple keys simultaneously, which makes me thinks this may be a "large" or well known issue.

does anyone know anything about? I'm clueless since I can play a game using XP and some keyboard, while I can't using Vista with the same keyboard...

hope someone can help me

dav

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.