2018-07-29 04:35:36 +00:00
|
|
|
using OpenTK.Input;
|
|
|
|
using Ryujinx.HLE.Input;
|
|
|
|
|
2018-07-02 22:08:54 +00:00
|
|
|
namespace Ryujinx.UI.Input
|
2018-02-17 23:54:19 +00:00
|
|
|
{
|
2018-07-02 22:08:54 +00:00
|
|
|
public struct JoyConKeyboardLeft
|
2018-02-17 23:54:19 +00: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;
|
2018-10-31 01:43:02 +00:00
|
|
|
public int ButtonZl;
|
2018-02-17 23:54:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 22:08:54 +00:00
|
|
|
public struct JoyConKeyboardRight
|
2018-02-17 23:54:19 +00: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;
|
2018-10-31 01:43:02 +00:00
|
|
|
public int ButtonZr;
|
2018-02-17 23:54:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-29 04:35:36 +00:00
|
|
|
public class JoyConKeyboard
|
2018-02-17 23:54:19 +00:00
|
|
|
{
|
2018-07-29 04:35:36 +00:00
|
|
|
public JoyConKeyboardLeft Left;
|
2018-07-02 22:08:54 +00:00
|
|
|
public JoyConKeyboardRight Right;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
|
|
|
public JoyConKeyboard(
|
2018-10-31 01:43:02 +00:00
|
|
|
JoyConKeyboardLeft left,
|
|
|
|
JoyConKeyboardRight right)
|
2018-07-29 04:35:36 +00:00
|
|
|
{
|
2018-10-31 01:43:02 +00:00
|
|
|
Left = left;
|
|
|
|
Right = right;
|
2018-07-29 04:35:36 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
public HidControllerButtons GetButtons(KeyboardState keyboard)
|
2018-07-29 04:35:36 +00:00
|
|
|
{
|
2018-10-31 01:43:02 +00:00
|
|
|
HidControllerButtons buttons = 0;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
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;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
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;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
return buttons;
|
2018-07-29 04:35:36 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
public (short, short) GetLeftStick(KeyboardState keyboard)
|
2018-07-29 04:35:36 +00:00
|
|
|
{
|
2018-10-31 01:43:02 +00:00
|
|
|
short dx = 0;
|
|
|
|
short dy = 0;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
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;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
return (dx, dy);
|
2018-07-29 04:35:36 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
public (short, short) GetRightStick(KeyboardState keyboard)
|
2018-07-29 04:35:36 +00:00
|
|
|
{
|
2018-10-31 01:43:02 +00:00
|
|
|
short dx = 0;
|
|
|
|
short dy = 0;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
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;
|
2018-07-29 04:35:36 +00:00
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
return (dx, dy);
|
2018-07-29 04:35:36 +00:00
|
|
|
}
|
2018-02-17 23:54:19 +00:00
|
|
|
}
|
|
|
|
}
|