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?

1
  • How did your solution go, were you able to determine the keys presses ? Commented May 24, 2018 at 1:26

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Can I your mail, please? :)
drop me a line through my facebook game dev page. Sorry, got home last night and forgot ><. facebook.com/InsaneSoftware.com.au

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.