blob: 1604da5bda4e97c174a4d6ffc3641163a86206a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
using OpenTK.Input;
using Ryujinx.HLE.Input;
namespace Ryujinx.UI.Input
{
public struct NpadKeyboardLeft
{
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;
}
public struct NpadKeyboardRight
{
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;
}
public class NpadKeyboard
{
/// <summary>
/// Left JoyCon Keyboard Bindings
/// </summary>
public NpadKeyboardLeft LeftJoycon { get; private set; }
/// <summary>
/// Right JoyCon Keyboard Bindings
/// </summary>
public NpadKeyboardRight RightJoycon { get; private set; }
public HidControllerButtons GetButtons(KeyboardState keyboard)
{
HidControllerButtons buttons = 0;
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;
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;
return buttons;
}
public (short, short) GetLeftStick(KeyboardState keyboard)
{
short dx = 0;
short dy = 0;
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;
return (dx, dy);
}
public (short, short) GetRightStick(KeyboardState keyboard)
{
short dx = 0;
short dy = 0;
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;
return (dx, dy);
}
}
}
|