Keyboard Buffer Issues

BlitzPlus Forums/BlitzPlus Programming/Keyboard Buffer Issues

Murilo(Posted 2003) [#1]
In my two player game, if both players use the same keyboard for their controls (5 keys each), I'm finding that my game "loses" or "misses" keypresses. It rendered the game unplayable, and it was very hit and miss as to when we were able to move in the direction we wanted to or actually "fire". It was my understanding that this was down to the keyboard itself and/or Windows, but other games and emulators (etc) run just fine on the same machine, so I assume it's something I'm doing.

I tried dropping a FlushKeys in to my main game loop, but holding a key down no longer worked - We needed to repeatidly press and release a key! This obviously isn't a problem when one or both players use a joystick, but I really want both players to be able to play on the same keyboard.

Am I missing something? Is this a common problem? Can it even be fixed?

Thanks.


semar(Posted 2003) [#2]
You can check the EnableDirectInput command, perhaps it helps. Not sure about the syntax though...

Basically it enable/disable the use of DirectInput for the keyboard.

Anyway, I did not experience such a problem, even with many keys pressed. Perhaps is something related to the code logic ?

If you have a combination of keys to be used, you can make some procedural If, and then test a variable result at the end:

;reset the test variable
key = 0

;use power of 2 to add values to the key variable:

if keydown(key_up) then
   key = key + 1 ;2^0
endif

if keydown(key_down) then
   key = key + 2 ;2^1
endif

if keydown(key_left) then
   key = key + 4 ;2^2
endif

if keydown(key_right) then
   key = key + 8 ;2^3
endif

;and so on...
.
.
.

select key
       case 1 ;up
       case 2 ;down
       case 3 ;up+down
       case 4 ;left
       case 5 ;up+left
       case 6 ;down+left
       case 7 ;up+down+left
;etc..
end select


Hope this helps,

Sergio.


Murilo(Posted 2003) [#3]
Thanks, I did another forum search (using EnableDirectInput as the keyword), and it returned a lot of interesting posts. Incidentally, I did a search before I initially creating this thread, but came up pretty empty... Weird...

Basically, it looks like it is a known problem and there's not much I can do about it :(

Thanks Sergio.


BlitzSupport(Posted 2003) [#4]
Can you try those 'other games' using exactly the same keys? I'm pretty sure you'll get the same result -- at least, that's what happened for me. I think it's something to do with an individual keyboard's controller/buffer.


Murilo(Posted 2003) [#5]
I'll give that a bash James, and let you know how I get on...