mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-23 17:25:48 +00:00
Emulate a circular zone for keyboard analog sticks (#1906)
This commit is contained in:
parent
4da6742861
commit
5e1a839eaa
1 changed files with 18 additions and 11 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using OpenTK;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
using Ryujinx.Configuration;
|
using Ryujinx.Configuration;
|
||||||
|
@ -69,12 +70,15 @@ namespace Ryujinx.Ui
|
||||||
short dx = 0;
|
short dx = 0;
|
||||||
short dy = 0;
|
short dy = 0;
|
||||||
|
|
||||||
if (keyboard[(Key)_config.LeftJoycon.StickUp]) dy = short.MaxValue;
|
if (keyboard[(Key)_config.LeftJoycon.StickUp]) dy += 1;
|
||||||
if (keyboard[(Key)_config.LeftJoycon.StickDown]) dy = -short.MaxValue;
|
if (keyboard[(Key)_config.LeftJoycon.StickDown]) dy += -1;
|
||||||
if (keyboard[(Key)_config.LeftJoycon.StickLeft]) dx = -short.MaxValue;
|
if (keyboard[(Key)_config.LeftJoycon.StickLeft]) dx += -1;
|
||||||
if (keyboard[(Key)_config.LeftJoycon.StickRight]) dx = short.MaxValue;
|
if (keyboard[(Key)_config.LeftJoycon.StickRight]) dx += 1;
|
||||||
|
|
||||||
return (dx, dy);
|
Vector2 stick = new Vector2(dx, dy);
|
||||||
|
stick.NormalizeFast();
|
||||||
|
|
||||||
|
return ((short)(stick.X * short.MaxValue), (short)(stick.Y * short.MaxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public (short, short) GetRightStick()
|
public (short, short) GetRightStick()
|
||||||
|
@ -84,12 +88,15 @@ namespace Ryujinx.Ui
|
||||||
short dx = 0;
|
short dx = 0;
|
||||||
short dy = 0;
|
short dy = 0;
|
||||||
|
|
||||||
if (keyboard[(Key)_config.RightJoycon.StickUp]) dy = short.MaxValue;
|
if (keyboard[(Key)_config.RightJoycon.StickUp]) dy += 1;
|
||||||
if (keyboard[(Key)_config.RightJoycon.StickDown]) dy = -short.MaxValue;
|
if (keyboard[(Key)_config.RightJoycon.StickDown]) dy += -1;
|
||||||
if (keyboard[(Key)_config.RightJoycon.StickLeft]) dx = -short.MaxValue;
|
if (keyboard[(Key)_config.RightJoycon.StickLeft]) dx += -1;
|
||||||
if (keyboard[(Key)_config.RightJoycon.StickRight]) dx = short.MaxValue;
|
if (keyboard[(Key)_config.RightJoycon.StickRight]) dx += 1;
|
||||||
|
|
||||||
return (dx, dy);
|
Vector2 stick = new Vector2(dx, dy);
|
||||||
|
stick.NormalizeFast();
|
||||||
|
|
||||||
|
return ((short)(stick.X * short.MaxValue), (short)(stick.Y * short.MaxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
public static HotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
||||||
|
|
Loading…
Reference in a new issue