From e243316e8e6dac62d22e33eaf680fedca2d474d0 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Tue, 29 Jul 2014 23:21:37 +0200 Subject: [PATCH] [Input] Cleaned up line endings and joystick hat mapping --- Source/OpenTK/Platform/MappedGamePadDriver.cs | 33 ++++++++++--------- .../Platform/SDL2/Sdl2JoystickDriver.cs | 16 ++++----- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Source/OpenTK/Platform/MappedGamePadDriver.cs b/Source/OpenTK/Platform/MappedGamePadDriver.cs index 2b8b313c..5d55b779 100644 --- a/Source/OpenTK/Platform/MappedGamePadDriver.cs +++ b/Source/OpenTK/Platform/MappedGamePadDriver.cs @@ -122,26 +122,27 @@ namespace OpenTK.Platform { // JoystickHat -> Buttons/GamePadAxes mapping JoystickHat source_hat = map.Source.Hat; + JoystickHatState state = joy.GetHat(source_hat); - bool pressed = false; - switch (map.Source.HatPosition) - { - case HatPosition.Down: - pressed = joy.GetHat(source_hat).IsDown; - break; + bool pressed = false; + switch (map.Source.HatPosition) + { + case HatPosition.Down: + pressed = state.IsDown; + break; - case HatPosition.Up: - pressed = joy.GetHat(source_hat).IsUp; - break; + case HatPosition.Up: + pressed = state.IsUp; + break; - case HatPosition.Left: - pressed = joy.GetHat(source_hat).IsLeft; - break; + case HatPosition.Left: + pressed = state.IsLeft; + break; - case HatPosition.Right: - pressed = joy.GetHat(source_hat).IsRight; - break; - } + case HatPosition.Right: + pressed = state.IsRight; + break; + } switch (map.Target.Type) { diff --git a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs index 32d8a59f..7623bf53 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs @@ -127,28 +127,28 @@ namespace OpenTK.Platform.SDL2 OpenTK.Input.HatPosition TranslateHat(HatPosition value) { - if ((value & HatPosition.LeftUp) == HatPosition.LeftUp) + if ((value & HatPosition.LeftUp) == HatPosition.LeftUp) return OpenTK.Input.HatPosition.UpLeft; - if ((value & HatPosition.RightUp) == HatPosition.RightUp) + if ((value & HatPosition.RightUp) == HatPosition.RightUp) return OpenTK.Input.HatPosition.UpRight; - if ((value & HatPosition.LeftDown) == HatPosition.LeftDown) + if ((value & HatPosition.LeftDown) == HatPosition.LeftDown) return OpenTK.Input.HatPosition.DownLeft; - if ((value & HatPosition.RightDown) == HatPosition.RightDown) + if ((value & HatPosition.RightDown) == HatPosition.RightDown) return OpenTK.Input.HatPosition.DownRight; - if ((value & HatPosition.Up) == HatPosition.Up) + if ((value & HatPosition.Up) == HatPosition.Up) return OpenTK.Input.HatPosition.Up; - if ((value & HatPosition.Right) == HatPosition.Right) + if ((value & HatPosition.Right) == HatPosition.Right) return OpenTK.Input.HatPosition.Right; - if ((value & HatPosition.Down) == HatPosition.Down) + if ((value & HatPosition.Down) == HatPosition.Down) return OpenTK.Input.HatPosition.Down; - if ((value & HatPosition.Left) == HatPosition.Left) + if ((value & HatPosition.Left) == HatPosition.Left) return OpenTK.Input.HatPosition.Left; return OpenTK.Input.HatPosition.Centered;