0

I am trying to write a game on UWP platform. Problem is: I need to bind Gamepad B and Escape to two different actions. E.g. Escape should always close current whatever, but Gamepad B should only do that unless my game handles it for a different purpose.

However, in KeyDown on Xbox pressing Gamepad B is always visible as Escape.

LOST
  • 2,956
  • 3
  • 25
  • 40

2 Answers2

0

Another alternative I came up with is to handle KeyDown on particular controls, and check eventArgs.OriginalKey. Then in handler you can detect mapping (because OriginalKey won't match Key), and set eventArgs.Handled = true to avoid key processing.

LOST
  • 2,956
  • 3
  • 25
  • 40
0

I think KeyRoutedEventArgs and OriginalKey is what you're looking for. Here is a sample that work for me in my app:

    private void StackPanel_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
    {

        if (e.OriginalKey == VirtualKey.GamepadB)
        {

        }
    }
Nghia Nguyen
  • 2,585
  • 4
  • 25
  • 38