0

I'm using the code here https://stackoverflow.com/a/13734766/709507 to get joystick or keyboard pressed buttons.

But the info I get is just the name of the button, for example, Button1 or Button2 etc.

There are two problems. First, for the keyboard, I need to get the exact name of pressed keys like 'B', 'C', 'F1' not Button1, Button49 etc. Second I need to get each button Scan code as well.

Is there any way doing these thing via SharpDX?

Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

1

So I had a look through on my own code to check (i'm using Sharpdx too!) just to check what to use.

I assume you are grabbing the keyboard state as thus:

KeyboardState m_gameKeyboardState;

m_gameKeyboard = new Keyboard(m_directInput);
m_gameKeyboardState = new KeyboardState();

m_gameKeyboard.Acquire();
m_gameKeyboard.GetCurrentState(ref m_gameKeyboardState);

then testing that with the following

if (m_gameKeyboardState.PressedKeys.Contains(Key.X))
{
//
}

Just a heads up though, I wrote this a while ago, if you want the entire class I am using this in, happy to share. Just drop me a PM and I will look into it for you.

ErnieDingo
  • 444
  • 5
  • 11