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-07-03 00:08:54 +02:00
|
|
|
public struct JoyConKeyboardLeft
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
|
|
|
public int StickUp;
|
|
|
|
public int StickDown;
|
|
|
|
public int StickLeft;
|
|
|
|
public int StickRight;
|
|
|
|
public int StickButton;
|
|
|
|
public int DPadUp;
|
|
|
|
public int DPadDown;
|
|
|
|
public int DPadLeft;
|
|
|
|
public int DPadRight;
|
|
|
|
public int ButtonMinus;
|
|
|
|
public int ButtonL;
|
|
|
|
public int ButtonZL;
|
|
|
|
}
|
|
|
|
|
2018-07-03 00:08:54 +02:00
|
|
|
public struct JoyConKeyboardRight
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
|
|
|
public int StickUp;
|
|
|
|
public int StickDown;
|
|
|
|
public int StickLeft;
|
|
|
|
public int StickRight;
|
|
|
|
public int StickButton;
|
|
|
|
public int ButtonA;
|
|
|
|
public int ButtonB;
|
|
|
|
public int ButtonX;
|
|
|
|
public int ButtonY;
|
|
|
|
public int ButtonPlus;
|
|
|
|
public int ButtonR;
|
|
|
|
public int ButtonZR;
|
|
|
|
}
|
|
|
|
|
2018-07-29 06:35:36 +02:00
|
|
|
public class JoyConKeyboard
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2018-07-29 06:35:36 +02:00
|
|
|
public JoyConKeyboardLeft Left;
|
2018-07-03 00:08:54 +02:00
|
|
|
public JoyConKeyboardRight Right;
|
2018-07-29 06:35:36 +02:00
|
|
|
|
|
|
|
public JoyConKeyboard(
|
|
|
|
JoyConKeyboardLeft Left,
|
|
|
|
JoyConKeyboardRight Right)
|
|
|
|
{
|
|
|
|
this.Left = Left;
|
|
|
|
this.Right = Right;
|
|
|
|
}
|
|
|
|
|
|
|
|
public HidControllerButtons GetButtons(KeyboardState Keyboard)
|
|
|
|
{
|
|
|
|
HidControllerButtons Buttons = 0;
|
|
|
|
|
|
|
|
if (Keyboard[(Key)Left.StickButton]) Buttons |= HidControllerButtons.KEY_LSTICK;
|
|
|
|
if (Keyboard[(Key)Left.DPadUp]) Buttons |= HidControllerButtons.KEY_DUP;
|
|
|
|
if (Keyboard[(Key)Left.DPadDown]) Buttons |= HidControllerButtons.KEY_DDOWN;
|
|
|
|
if (Keyboard[(Key)Left.DPadLeft]) Buttons |= HidControllerButtons.KEY_DLEFT;
|
|
|
|
if (Keyboard[(Key)Left.DPadRight]) Buttons |= HidControllerButtons.KEY_DRIGHT;
|
|
|
|
if (Keyboard[(Key)Left.ButtonMinus]) Buttons |= HidControllerButtons.KEY_MINUS;
|
|
|
|
if (Keyboard[(Key)Left.ButtonL]) Buttons |= HidControllerButtons.KEY_L;
|
|
|
|
if (Keyboard[(Key)Left.ButtonZL]) Buttons |= HidControllerButtons.KEY_ZL;
|
|
|
|
|
|
|
|
if (Keyboard[(Key)Right.StickButton]) Buttons |= HidControllerButtons.KEY_RSTICK;
|
|
|
|
if (Keyboard[(Key)Right.ButtonA]) Buttons |= HidControllerButtons.KEY_A;
|
|
|
|
if (Keyboard[(Key)Right.ButtonB]) Buttons |= HidControllerButtons.KEY_B;
|
|
|
|
if (Keyboard[(Key)Right.ButtonX]) Buttons |= HidControllerButtons.KEY_X;
|
|
|
|
if (Keyboard[(Key)Right.ButtonY]) Buttons |= HidControllerButtons.KEY_Y;
|
|
|
|
if (Keyboard[(Key)Right.ButtonPlus]) Buttons |= HidControllerButtons.KEY_PLUS;
|
|
|
|
if (Keyboard[(Key)Right.ButtonR]) Buttons |= HidControllerButtons.KEY_R;
|
|
|
|
if (Keyboard[(Key)Right.ButtonZR]) Buttons |= HidControllerButtons.KEY_ZR;
|
|
|
|
|
|
|
|
return Buttons;
|
|
|
|
}
|
|
|
|
|
|
|
|
public (short, short) GetLeftStick(KeyboardState Keyboard)
|
|
|
|
{
|
|
|
|
short DX = 0;
|
|
|
|
short DY = 0;
|
|
|
|
|
|
|
|
if (Keyboard[(Key)Left.StickUp]) DY = short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Left.StickDown]) DY = -short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Left.StickLeft]) DX = -short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Left.StickRight]) DX = short.MaxValue;
|
|
|
|
|
|
|
|
return (DX, DY);
|
|
|
|
}
|
|
|
|
|
|
|
|
public (short, short) GetRightStick(KeyboardState Keyboard)
|
|
|
|
{
|
|
|
|
short DX = 0;
|
|
|
|
short DY = 0;
|
|
|
|
|
|
|
|
if (Keyboard[(Key)Right.StickUp]) DY = short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Right.StickDown]) DY = -short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Right.StickLeft]) DX = -short.MaxValue;
|
|
|
|
if (Keyboard[(Key)Right.StickRight]) DX = short.MaxValue;
|
|
|
|
|
|
|
|
return (DX, DY);
|
|
|
|
}
|
2018-02-18 00:54:19 +01:00
|
|
|
}
|
|
|
|
}
|