[Input] Cleaned up line endings and joystick hat mapping

This commit is contained in:
thefiddler 2014-07-29 23:21:37 +02:00
parent fe1d465b85
commit e243316e8e
2 changed files with 25 additions and 24 deletions

View file

@ -122,26 +122,27 @@ namespace OpenTK.Platform
{ {
// JoystickHat -> Buttons/GamePadAxes mapping // JoystickHat -> Buttons/GamePadAxes mapping
JoystickHat source_hat = map.Source.Hat; JoystickHat source_hat = map.Source.Hat;
JoystickHatState state = joy.GetHat(source_hat);
bool pressed = false; bool pressed = false;
switch (map.Source.HatPosition) switch (map.Source.HatPosition)
{ {
case HatPosition.Down: case HatPosition.Down:
pressed = joy.GetHat(source_hat).IsDown; pressed = state.IsDown;
break; break;
case HatPosition.Up: case HatPosition.Up:
pressed = joy.GetHat(source_hat).IsUp; pressed = state.IsUp;
break; break;
case HatPosition.Left: case HatPosition.Left:
pressed = joy.GetHat(source_hat).IsLeft; pressed = state.IsLeft;
break; break;
case HatPosition.Right: case HatPosition.Right:
pressed = joy.GetHat(source_hat).IsRight; pressed = state.IsRight;
break; break;
} }
switch (map.Target.Type) switch (map.Target.Type)
{ {

View file

@ -127,28 +127,28 @@ namespace OpenTK.Platform.SDL2
OpenTK.Input.HatPosition TranslateHat(HatPosition value) OpenTK.Input.HatPosition TranslateHat(HatPosition value)
{ {
if ((value & HatPosition.LeftUp) == HatPosition.LeftUp) if ((value & HatPosition.LeftUp) == HatPosition.LeftUp)
return OpenTK.Input.HatPosition.UpLeft; return OpenTK.Input.HatPosition.UpLeft;
if ((value & HatPosition.RightUp) == HatPosition.RightUp) if ((value & HatPosition.RightUp) == HatPosition.RightUp)
return OpenTK.Input.HatPosition.UpRight; return OpenTK.Input.HatPosition.UpRight;
if ((value & HatPosition.LeftDown) == HatPosition.LeftDown) if ((value & HatPosition.LeftDown) == HatPosition.LeftDown)
return OpenTK.Input.HatPosition.DownLeft; return OpenTK.Input.HatPosition.DownLeft;
if ((value & HatPosition.RightDown) == HatPosition.RightDown) if ((value & HatPosition.RightDown) == HatPosition.RightDown)
return OpenTK.Input.HatPosition.DownRight; return OpenTK.Input.HatPosition.DownRight;
if ((value & HatPosition.Up) == HatPosition.Up) if ((value & HatPosition.Up) == HatPosition.Up)
return OpenTK.Input.HatPosition.Up; return OpenTK.Input.HatPosition.Up;
if ((value & HatPosition.Right) == HatPosition.Right) if ((value & HatPosition.Right) == HatPosition.Right)
return OpenTK.Input.HatPosition.Right; return OpenTK.Input.HatPosition.Right;
if ((value & HatPosition.Down) == HatPosition.Down) if ((value & HatPosition.Down) == HatPosition.Down)
return OpenTK.Input.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.Left;
return OpenTK.Input.HatPosition.Centered; return OpenTK.Input.HatPosition.Centered;