mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 07:56:48 +00:00
[Input][SDL] Fix JoystickHat bugs
On SDL, DPad inputs were not correctly translated from joystick hat inputs. Updated MappedGamePadDriver so that it will correctly recognize combined joystick hat directions e.g. DPadLeft should be true when DownLeft, Left, or UpLeft are returned from the joystick hat.
This commit is contained in:
parent
e5cd6a3b9e
commit
fe1d465b85
|
@ -122,7 +122,26 @@ namespace OpenTK.Platform
|
|||
{
|
||||
// JoystickHat -> Buttons/GamePadAxes mapping
|
||||
JoystickHat source_hat = map.Source.Hat;
|
||||
bool pressed = joy.GetHat(source_hat).Position == map.Source.HatPosition;
|
||||
|
||||
bool pressed = false;
|
||||
switch (map.Source.HatPosition)
|
||||
{
|
||||
case HatPosition.Down:
|
||||
pressed = joy.GetHat(source_hat).IsDown;
|
||||
break;
|
||||
|
||||
case HatPosition.Up:
|
||||
pressed = joy.GetHat(source_hat).IsUp;
|
||||
break;
|
||||
|
||||
case HatPosition.Left:
|
||||
pressed = joy.GetHat(source_hat).IsLeft;
|
||||
break;
|
||||
|
||||
case HatPosition.Right:
|
||||
pressed = joy.GetHat(source_hat).IsRight;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (map.Target.Type)
|
||||
{
|
||||
|
|
|
@ -753,8 +753,8 @@ namespace OpenTK.Platform.SDL2
|
|||
Centered = 0x00,
|
||||
Up = 0x01,
|
||||
Right = 0x02,
|
||||
Down = 0x03,
|
||||
Left = 0x04,
|
||||
Down = 0x04,
|
||||
Left = 0x08,
|
||||
RightUp = Right | Up,
|
||||
RightDown = Right | Down,
|
||||
LeftUp = Left | Up,
|
||||
|
|
|
@ -127,28 +127,28 @@ namespace OpenTK.Platform.SDL2
|
|||
|
||||
OpenTK.Input.HatPosition TranslateHat(HatPosition value)
|
||||
{
|
||||
if ((value & HatPosition.LeftUp) == value)
|
||||
if ((value & HatPosition.LeftUp) == HatPosition.LeftUp)
|
||||
return OpenTK.Input.HatPosition.UpLeft;
|
||||
|
||||
if ((value & HatPosition.RightUp) == value)
|
||||
if ((value & HatPosition.RightUp) == HatPosition.RightUp)
|
||||
return OpenTK.Input.HatPosition.UpRight;
|
||||
|
||||
if ((value & HatPosition.LeftDown) == value)
|
||||
if ((value & HatPosition.LeftDown) == HatPosition.LeftDown)
|
||||
return OpenTK.Input.HatPosition.DownLeft;
|
||||
|
||||
if ((value & HatPosition.RightDown) == value)
|
||||
if ((value & HatPosition.RightDown) == HatPosition.RightDown)
|
||||
return OpenTK.Input.HatPosition.DownRight;
|
||||
|
||||
if ((value & HatPosition.Up) == value)
|
||||
if ((value & HatPosition.Up) == HatPosition.Up)
|
||||
return OpenTK.Input.HatPosition.Up;
|
||||
|
||||
if ((value & HatPosition.Right) == value)
|
||||
if ((value & HatPosition.Right) == HatPosition.Right)
|
||||
return OpenTK.Input.HatPosition.Right;
|
||||
|
||||
if ((value & HatPosition.Down) == value)
|
||||
if ((value & HatPosition.Down) == HatPosition.Down)
|
||||
return OpenTK.Input.HatPosition.Down;
|
||||
|
||||
if ((value & HatPosition.Left) == value)
|
||||
if ((value & HatPosition.Left) == HatPosition.Left)
|
||||
return OpenTK.Input.HatPosition.Left;
|
||||
|
||||
return OpenTK.Input.HatPosition.Centered;
|
||||
|
|
Loading…
Reference in a new issue