Managed Directinput direction buttons problem

Started by
4 comments, last by Evil Steve 16 years, 4 months ago
I'm using GetCurrentKeyboardState from a Keyboard device. It detects multiple keys down ex State(key.a) State(key.b) State(key.c) could return 3 true's if I had them all pressed, but for the direction keys (up, down, left, right) it only detects the first 2 pressed. Is there a setting at initialization to change this?

    Private Sub InitializeKeyboard()
        I_Keyboard = New Device(SystemGuid.Keyboard)
        I_Keyboard.SetDataFormat(DeviceDataFormat.Keyboard)
        I_Keyboard.SetCooperativeLevel(W_Target, Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Foreground _
            Or Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Exclusive)
        Try

            I_Keyboard.Acquire()
            I_KeyboardAcquired = True
        Catch e As Exception
            I_KeyboardAcquired = False
        End Try
    End Sub
Advertisement
I've heard some "cheaper" keyboards are only able to handle a limited number keys down at one time, so it's possible it could be a hardware limitation. If I remeber correctly you can identify this by the way the computer beeps at you when you try to hit too many keys at once.

I'd have to go back and check the documentation but I'm pretty sure there is no setting that has an effect on the number of keys that can be 'pressed' at any one time. The only setting I remeber from the older SDKs was switching between real time keyboard state and cached keyboard state.
-------------------------------------------------------- What''s the difference between engineers and architects? Engineers build weapons; architects build targets. --------------------------------------------------------
I don't think it's the keyboard because I can press multiple buttons on any other than the direction buttons, but thanks for the suggestion, I have a usb keyboard I'll try out.
Quote:Original post by Stukey
I don't think it's the keyboard because I can press multiple buttons on any other than the direction buttons, but thanks for the suggestion, I have a usb keyboard I'll try out.


It is very likely to be the keyboard. Do a search here for keyboard and multiple keys. You'll get quite a bit of information. The most common issue with keyboards is the very one you are seeing - no more than two direction keys at one time.

It has to do with the way keyboards are wired and the problem isn't always limited to "cheap" keyboards.
So... would the way around this be to just use unmanaged directinput, or windows to detect keys or is it literally hardware to the point where there is no way around this?

*edit* So yeah, I hooked up my other keyboard and it has certain 3 button combinations that work (up,down,right) and (left,right,down) but those are the only 3 button combos that work.
Mandatory link: Reasons not to use DirectInput for Keyboard Input

Seriously. Don't do it.

This topic is closed to new replies.

Advertisement