2018-07-29 06:35:36 +02:00
|
|
|
using OpenTK.Input;
|
|
|
|
using Ryujinx.HLE.Input;
|
|
|
|
|
2018-07-03 00:08:54 +02:00
|
|
|
namespace Ryujinx.UI.Input
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2018-11-20 01:01:36 +01:00
|
|
|
public struct NpadKeyboardLeft
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2019-02-11 13:00:32 +01:00
|
|
|
public Key StickUp;
|
|
|
|
public Key StickDown;
|
|
|
|
public Key StickLeft;
|
|
|
|
public Key StickRight;
|
|
|
|
public Key StickButton;
|
|
|
|
public Key DPadUp;
|
|
|
|
public Key DPadDown;
|
|
|
|
public Key DPadLeft;
|
|
|
|
public Key DPadRight;
|
|
|
|
public Key ButtonMinus;
|
|
|
|
public Key ButtonL;
|
|
|
|
public Key ButtonZl;
|
2018-02-18 00:54:19 +01:00
|
|
|
}
|
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
public struct NpadKeyboardRight
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2019-02-11 13:00:32 +01:00
|
|
|
public Key StickUp;
|
|
|
|
public Key StickDown;
|
|
|
|
public Key StickLeft;
|
|
|
|
public Key StickRight;
|
|
|
|
public Key StickButton;
|
|
|
|
public Key ButtonA;
|
|
|
|
public Key ButtonB;
|
|
|
|
public Key ButtonX;
|
|
|
|
public Key ButtonY;
|
|
|
|
public Key ButtonPlus;
|
|
|
|
public Key ButtonR;
|
|
|
|
public Key ButtonZr;
|
2018-02-18 00:54:19 +01:00
|
|
|
}
|
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
public class NpadKeyboard
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2019-02-11 13:00:32 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Left JoyCon Keyboard Bindings
|
|
|
|
/// </summary>
|
|
|
|
public NpadKeyboardLeft LeftJoycon { get; private set; }
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2019-02-11 13:00:32 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Right JoyCon Keyboard Bindings
|
|
|
|
/// </summary>
|
|
|
|
public NpadKeyboardRight RightJoycon { get; private set; }
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public HidControllerButtons GetButtons(KeyboardState keyboard)
|
2018-07-29 06:35:36 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
HidControllerButtons buttons = 0;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2019-02-11 13:00:32 +01:00
|
|
|
if (keyboard[(Key)LeftJoycon.StickButton]) buttons |= HidControllerButtons.StickLeft;
|
|
|
|
if (keyboard[(Key)LeftJoycon.DPadUp]) buttons |= HidControllerButtons.DpadUp;
|
|
|
|
if (keyboard[(Key)LeftJoycon.DPadDown]) buttons |= HidControllerButtons.DpadDown;
|
|
|
|
if (keyboard[(Key)LeftJoycon.DPadLeft]) buttons |= HidControllerButtons.DpadLeft;
|
|
|
|
if (keyboard[(Key)LeftJoycon.DPadRight]) buttons |= HidControllerButtons.DPadRight;
|
|
|
|
if (keyboard[(Key)LeftJoycon.ButtonMinus]) buttons |= HidControllerButtons.Minus;
|
|
|
|
if (keyboard[(Key)LeftJoycon.ButtonL]) buttons |= HidControllerButtons.L;
|
|
|
|
if (keyboard[(Key)LeftJoycon.ButtonZl]) buttons |= HidControllerButtons.Zl;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2019-02-11 13:00:32 +01:00
|
|
|
if (keyboard[(Key)RightJoycon.StickButton]) buttons |= HidControllerButtons.StickRight;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonA]) buttons |= HidControllerButtons.A;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonB]) buttons |= HidControllerButtons.B;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonX]) buttons |= HidControllerButtons.X;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonY]) buttons |= HidControllerButtons.Y;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonPlus]) buttons |= HidControllerButtons.Plus;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonR]) buttons |= HidControllerButtons.R;
|
|
|
|
if (keyboard[(Key)RightJoycon.ButtonZr]) buttons |= HidControllerButtons.Zr;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
return buttons;
|
2018-07-29 06:35:36 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public (short, short) GetLeftStick(KeyboardState keyboard)
|
2018-07-29 06:35:36 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
short dx = 0;
|
|
|
|
short dy = 0;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2019-02-11 13:00:32 +01:00
|
|
|
if (keyboard[(Key)LeftJoycon.StickUp]) dy = short.MaxValue;
|
|
|
|
if (keyboard[(Key)LeftJoycon.StickDown]) dy = -short.MaxValue;
|
|
|
|
if (keyboard[(Key)LeftJoycon.StickLeft]) dx = -short.MaxValue;
|
|
|
|
if (keyboard[(Key)LeftJoycon.StickRight]) dx = short.MaxValue;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
return (dx, dy);
|
2018-07-29 06:35:36 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public (short, short) GetRightStick(KeyboardState keyboard)
|
2018-07-29 06:35:36 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
short dx = 0;
|
|
|
|
short dy = 0;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2019-02-11 13:00:32 +01:00
|
|
|
if (keyboard[(Key)RightJoycon.StickUp]) dy = short.MaxValue;
|
|
|
|
if (keyboard[(Key)RightJoycon.StickDown]) dy = -short.MaxValue;
|
|
|
|
if (keyboard[(Key)RightJoycon.StickLeft]) dx = -short.MaxValue;
|
|
|
|
if (keyboard[(Key)RightJoycon.StickRight]) dx = short.MaxValue;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
return (dx, dy);
|
2018-07-29 06:35:36 +02:00
|
|
|
}
|
2018-02-18 00:54:19 +01:00
|
|
|
}
|
|
|
|
}
|