-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInputManager.cs
723 lines (587 loc) · 27 KB
/
InputManager.cs
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
using System;
using System.Drawing;
using OpenTK.Input;
using System.Collections.Generic;
namespace GameFramework {
class InputManager {
public class ControllerMapping {
public JoystickButton[] Buttons = new JoystickButton[] {
JoystickButton.Button1,
JoystickButton.Button2,
JoystickButton.Button3,
JoystickButton.Button4,
JoystickButton.Button5,
JoystickButton.Button6,
JoystickButton.Button7,
JoystickButton.Button8,
JoystickButton.Button9,
JoystickButton.Button10,
JoystickButton.Button11,
JoystickButton.Button12,
JoystickButton.Button13,
JoystickButton.Button14
};
public JoystickAxis[] Axis = new JoystickAxis[] {
JoystickAxis.Axis0,
JoystickAxis.Axis1,
JoystickAxis.Axis2,
JoystickAxis.Axis3
};
public bool[] HasButtons = new bool[15];
public bool[] HasAxis = new bool[4];
public JoystickButton A { get { return Buttons[0]; } set { Buttons[0] = value; HasButtons[0] = true; } }
public JoystickButton B { get { return Buttons[1]; } set { Buttons[1] = value; HasButtons[1] = true; } }
public JoystickButton X { get { return Buttons[2]; } set { Buttons[2] = value; HasButtons[2] = true; } }
public JoystickButton Y { get { return Buttons[3]; } set { Buttons[3] = value; HasButtons[3] = true; } }
public JoystickButton Start { get { return Buttons[4]; } set { Buttons[4] = value; HasButtons[4] = true; } }
public JoystickButton Select { get { return Buttons[5]; } set { Buttons[5] = value; HasButtons[5] = true; } }
public JoystickButton Up { get { return Buttons[6]; } set { Buttons[6] = value; HasButtons[6] = true; } }
public JoystickButton Down { get { return Buttons[7]; } set { Buttons[7] = value; HasButtons[7] = true; } }
public JoystickButton Left { get { return Buttons[8]; } set { Buttons[8] = value; HasButtons[8] = true; } }
public JoystickButton Right { get { return Buttons[9]; } set { Buttons[9] = value; HasButtons[9] = true; } }
public JoystickButton Home { get { return Buttons[10]; } set { Buttons[10] = value; HasButtons[10] = true; } }
public JoystickButton L1 { get { return Buttons[11]; } set { Buttons[11] = value; HasButtons[11] = true; } }
public JoystickButton L2 { get { return Buttons[12]; } set { Buttons[12] = value; HasButtons[12] = true; } }
public JoystickButton R1 { get { return Buttons[13]; } set { Buttons[13] = value; HasButtons[13] = true; } }
public JoystickButton R2 { get { return Buttons[14]; } set { Buttons[14] = value; HasButtons[14] = true; } }
public JoystickAxis LeftAxisX { get { return Axis[0]; } set { Axis[0] = value; HasAxis[0] = true; } }
public JoystickAxis LeftAxisY { get { return Axis[1]; } set { Axis[1] = value; HasAxis[1] = true; } }
public JoystickAxis RightAxisX { get { return Axis[2]; } set { Axis[2] = value; HasAxis[2] = true; } }
public JoystickAxis RightAxisY { get { return Axis[3]; } set { Axis[3] = value; HasAxis[3] = true; } }
public bool HasA { get { return HasButtons[0]; } set { HasButtons[0] = value; } }
public bool HasB { get { return HasButtons[1]; } set { HasButtons[1] = value; } }
public bool HasX { get { return HasButtons[2]; } set { HasButtons[2] = value; } }
public bool HasY { get { return HasButtons[3]; } set { HasButtons[3] = value; } }
public bool HasStart { get { return HasButtons[4]; } set { HasButtons[4] = value; } }
public bool HasSelect { get { return HasButtons[5]; } set { HasButtons[5] = value; } }
public bool HasUp { get { return HasButtons[6]; } set { HasButtons[6] = value; } }
public bool HasDown { get { return HasButtons[7]; } set { HasButtons[7] = value; } }
public bool HasLeft { get { return HasButtons[8]; } set { HasButtons[8] = value; } }
public bool HasRight { get { return HasButtons[9]; } set { HasButtons[9] = value; } }
public bool HasHome { get { return HasButtons[10]; } set { HasButtons[10] = value; } }
public bool HasL1 { get { return HasButtons[11]; } set { HasButtons[11] = value; } }
public bool HasL2 { get { return HasButtons[12]; } set { HasButtons[12] = value; } }
public bool HasR1 { get { return HasButtons[13]; } set { HasButtons[13] = value; } }
public bool HasR2 { get { return HasButtons[14]; } set { HasButtons[14] = value; } }
public bool HasLeftAxisX { get { return HasAxis[0]; } set { HasAxis[0] = value; } }
public bool HasLeftAxisY { get { return HasAxis[1]; } set { HasAxis[1] = value; } }
public bool HasRightAxisX { get { return HasAxis[2]; } set { HasAxis[2] = value; } }
public bool HasRightAxisY { get { return HasAxis[3]; } set { HasAxis[3] = value; } }
}
public class ControllerState {
public bool[] Buttons = new bool[15];
public bool A { get { return Buttons[0]; } set { Buttons[0] = value; } }
public bool B { get { return Buttons[1]; } set { Buttons[1] = value; } }
public bool X { get { return Buttons[2]; } set { Buttons[2] = value; } }
public bool Y { get { return Buttons[3]; } set { Buttons[3] = value; } }
public bool Start { get { return Buttons[4]; } set { Buttons[4] = value; } }
public bool Select { get { return Buttons[5]; } set { Buttons[5] = value; } }
public bool Up { get { return Buttons[6]; } set { Buttons[6] = value; } }
public bool Down { get { return Buttons[7]; } set { Buttons[7] = value; } }
public bool Left { get { return Buttons[8]; } set { Buttons[8] = value; } }
public bool Right { get { return Buttons[9]; } set { Buttons[9] = value; } }
public bool Home { get { return Buttons[10]; } set { Buttons[10] = value; } }
public bool L1 { get { return Buttons[11]; } set { Buttons[11] = value; } }
public bool L2 { get { return Buttons[12]; } set { Buttons[12] = value; } }
public bool R1 { get { return Buttons[13]; } set { Buttons[13] = value; } }
public bool R2 { get { return Buttons[14]; } set { Buttons[14] = value; } }
public PointF LeftAxis = new PointF(0, 0);
public PointF RightAxis = new PointF(0, 0);
}
private static InputManager instance = null;
public static InputManager Instance {
get {
if (instance == null) {
instance = new InputManager();
}
return instance;
}
}
private OpenTK.GameWindow game = null;
private bool isInitialized = false;
private bool[] prevKeysDown = null;
private bool[] curKeysDown = null;
private bool[] prevMouseDown = null;
private bool[] curMouseDown = null;
private Point mousePosition = new Point(0, 0);
private PointF mouseDeltaPos = new PointF(0, 0);
private int numJoysticks = 0;
private ControllerMapping[] joyMapping = null;
private ControllerState[] prevJoyDown = null;
private ControllerState[] curJoyDown = null;
private float[] joyDeadZone = null;
private InputManager() {
}
public void Initialize(OpenTK.GameWindow window) {
game = window;
int numKeys = (int)OpenTK.Input.Key.LastKey;
int numMouseButtons = (int)OpenTK.Input.MouseButton.LastButton;
prevKeysDown = new bool[numKeys];
curKeysDown = new bool[numKeys];
for (int i = 0; i < numKeys; ++i) {
prevKeysDown[i] = curKeysDown[i] = false;
}
prevMouseDown = new bool[numMouseButtons];
curMouseDown = new bool[numMouseButtons];
for (int i = 0; i < numMouseButtons; ++i) {
prevMouseDown[i] = curMouseDown[i] = false;
}
numJoysticks = game.Joysticks.Count;
joyMapping = new ControllerMapping[numJoysticks];
prevJoyDown = new ControllerState[numJoysticks];
curJoyDown = new ControllerState[numJoysticks];
joyDeadZone = new float[numJoysticks];
for (int i = 0; i < numJoysticks; ++i) {
joyMapping[i] = new ControllerMapping();
prevJoyDown[i] = new ControllerState();
curJoyDown[i] = new ControllerState();
joyDeadZone[i] = 0.25f;
}
isInitialized = true;
}
public void Shutdown() {
prevKeysDown = null;
curKeysDown = null;
prevMouseDown = null;
curMouseDown = null;
joyMapping = null;
prevJoyDown = null;
curJoyDown = null;
joyDeadZone = null;
isInitialized = false;
}
public void Update() {
for (int i = 0; i < curKeysDown.Length; ++i) {
prevKeysDown[i] = curKeysDown[i];
curKeysDown[i] = game.Keyboard[(Key)i];
}
for (int i = 0; i < curMouseDown.Length; ++i) {
prevMouseDown[i] = curMouseDown[i];
curMouseDown[i] = game.Mouse[(MouseButton)i];
}
mousePosition.X = game.Mouse.X;
mousePosition.Y = game.Mouse.Y;
mouseDeltaPos.X = ((float)game.Mouse.XDelta) / ((float)game.ClientSize.Width);
mouseDeltaPos.Y = ((float)game.Mouse.YDelta) / ((float)game.ClientSize.Height);
for (int i = 0; i < numJoysticks; ++i) {
if (IsConnected(i)) {
JoystickState state = Joystick.GetState(i);
for (int j = 0; j < curJoyDown[i].Buttons.Length; ++j) {
prevJoyDown[i].Buttons[j] = curJoyDown[i].Buttons[j];
curJoyDown[i].Buttons[j] = joyMapping[i].HasButtons[j] ? state.GetButton(joyMapping[i].Buttons[j]) == ButtonState.Pressed : false;
}
prevJoyDown[i].LeftAxis.X = curJoyDown[i].LeftAxis.X;
prevJoyDown[i].LeftAxis.Y = curJoyDown[i].LeftAxis.Y;
prevJoyDown[i].RightAxis.X = curJoyDown[i].RightAxis.X;
prevJoyDown[i].RightAxis.Y = curJoyDown[i].RightAxis.Y;
curJoyDown[i].LeftAxis.X = joyMapping[i].HasLeftAxisX ? state.GetAxis(joyMapping[i].LeftAxisX) : 0.0f;
curJoyDown[i].LeftAxis.Y = joyMapping[i].HasLeftAxisY ? state.GetAxis(joyMapping[i].LeftAxisY) : 0.0f;
curJoyDown[i].RightAxis.X = joyMapping[i].HasRightAxisX ? state.GetAxis(joyMapping[i].RightAxisX) : 0.0f;
curJoyDown[i].RightAxis.Y = joyMapping[i].HasRightAxisY ? state.GetAxis(joyMapping[i].RightAxisY) : 0.0f;
if (curJoyDown[i].LeftAxis.X > 0.0f && curJoyDown[i].LeftAxis.X < joyDeadZone[i]) {
curJoyDown[i].LeftAxis.X = 0.0f;
}
else if (curJoyDown[i].LeftAxis.X < 0.0f && curJoyDown[i].LeftAxis.X > -joyDeadZone[i]) {
curJoyDown[i].LeftAxis.X = 0.0f;
}
if (curJoyDown[i].LeftAxis.Y > 0.0f && curJoyDown[i].LeftAxis.Y < joyDeadZone[i]) {
curJoyDown[i].LeftAxis.Y = 0.0f;
}
else if (curJoyDown[i].LeftAxis.Y < 0.0f && curJoyDown[i].LeftAxis.Y > -joyDeadZone[i]) {
curJoyDown[i].LeftAxis.Y = 0.0f;
}
if (curJoyDown[i].RightAxis.X > 0.0f && curJoyDown[i].RightAxis.X < joyDeadZone[i]) {
curJoyDown[i].RightAxis.X = 0.0f;
}
else if (curJoyDown[i].RightAxis.X < 0.0f && curJoyDown[i].RightAxis.X > -joyDeadZone[i]) {
curJoyDown[i].RightAxis.X = 0.0f;
}
if (curJoyDown[i].RightAxis.Y > 0.0f && curJoyDown[i].RightAxis.Y < joyDeadZone[i]) {
curJoyDown[i].RightAxis.Y = 0.0f;
}
else if (curJoyDown[i].RightAxis.Y < 0.0f && curJoyDown[i].RightAxis.Y > -joyDeadZone[i]) {
curJoyDown[i].RightAxis.Y = 0.0f;
}
}
}
}
public bool KeyDown(OpenTK.Input.Key key) {
return curKeysDown[(int)key];
}
public bool KeyUp(OpenTK.Input.Key key) {
return !curKeysDown[(int)key];
}
public bool KeyPressed(OpenTK.Input.Key key) {
return (!prevKeysDown[(int)key]) && curKeysDown[(int)key];
}
public bool KeyReleased(OpenTK.Input.Key key) {
return prevKeysDown[(int)key] && (!curKeysDown[(int)key]);
}
public OpenTK.Input.Key[] GetAllKeysDown() {
System.Collections.Generic.List<Key> collection = new List<Key>();
for (int i = 0; i < curKeysDown.Length; ++i) {
if (curKeysDown[i]) {
collection.Add((Key)i);
}
}
return collection.ToArray();
}
public bool MouseDown(OpenTK.Input.MouseButton button) {
return curMouseDown[(int)button];
}
public bool MouseUp(OpenTK.Input.MouseButton button) {
return !curMouseDown[(int)button];
}
public bool MousePressed(OpenTK.Input.MouseButton button) {
return (!prevMouseDown[(int)button]) && curMouseDown[(int)button];
}
public bool MouseReleased(OpenTK.Input.MouseButton button) {
return prevMouseDown[(int)button] && (!curMouseDown[(int)button]);
}
public int MouseX {
get {
return mousePosition.X;
}
}
public int MouseY {
get {
return mousePosition.Y;
}
}
public Point MousePosition {
get {
return mousePosition;
}
}
public float MouseDeltaX {
get {
return mouseDeltaPos.X;
}
}
public float MouseDeltaY {
get {
return mouseDeltaPos.Y;
}
}
public PointF MouseDelta {
get {
return mouseDeltaPos;
}
}
public void SetMousePosition(Point newPos) {
OpenTK.Input.Mouse.SetPosition(newPos.X, newPos.Y);
}
public void CenterMouse() {
double x = game.X + game.Width / 2;
double y = game.Y + game.Height / 2;
OpenTK.Input.Mouse.SetPosition(x, y);
}
public Dictionary<int, string> Gamepads {
get {
Dictionary<int, string> result = new Dictionary<int, string>();
for (int i = 0; i < numJoysticks; i++) {
JoystickCapabilities caps = Joystick.GetCapabilities(i);
if (caps.IsConnected) {
result.Add(i, game.Joysticks[i].DeviceType + ": " + game.Joysticks[i].Description);
}
}
return result;
}
}
public int NumGamepads {
get {
int count = 0;
for (int i = 0; i < numJoysticks; i++) {
JoystickCapabilities caps = Joystick.GetCapabilities(i);
if (caps.IsConnected) {
count += 1;
/*Console.WriteLine("Joystick: " + i);
Console.WriteLine("\tDescription: " + game.Joysticks[i].Description);
Console.WriteLine("\tType: " + game.Joysticks[i].DeviceType);
Console.WriteLine("\tString: " + game.Joysticks[i].ToString());*/
}
}
return count;
}
}
public bool IsConnected(int padNum) {
JoystickCapabilities caps = Joystick.GetCapabilities(padNum);
return caps.IsConnected;
}
public float GetDeadzone(int controllerNum) {
return joyDeadZone[controllerNum];
}
public void SetDeadzone(int controller, float value) {
joyDeadZone[controller] = value;
}
public ControllerMapping GetMapping(int joyNum) {
return joyMapping[joyNum];
}
public bool GetButton(int joystick, ref JoystickButton button, params JoystickButton[] excludeButtons) {
for (int i = 0; i < numJoysticks; ++i) {
if (IsConnected(i)) {
JoystickState state = Joystick.GetState(i);
foreach (JoystickButton enumVal in Enum.GetValues(typeof(JoystickButton))) {
if (state.GetButton(enumVal) == ButtonState.Pressed) {
bool cont = false;
foreach (JoystickButton exclude in excludeButtons) {
if (exclude == enumVal) {
cont = true;
break;
}
}
if (cont) {
continue;
}
button = enumVal;
return true;
}
}
}
}
return false;
}
public bool GetAxis(int joystick, ref JoystickAxis axis, params JoystickAxis[] excludeAxis) {
for (int i = 0; i < numJoysticks; ++i) {
if (IsConnected(i)) {
JoystickState state = Joystick.GetState(i);
foreach (JoystickAxis enumVal in Enum.GetValues(typeof(JoystickAxis))) {
bool greaterThan0 = Math.Abs(state.GetAxis(enumVal)) > GetDeadzone(joystick);
bool lessThan1 = 1.0 - Math.Abs(state.GetAxis(enumVal)) > GetDeadzone(joystick);
if (greaterThan0 && lessThan1) {
bool cont = false;
foreach (JoystickAxis exclude in excludeAxis) {
if (exclude == enumVal) {
cont = true;
break;
}
}
if (cont) {
continue;
}
axis = enumVal;
return true;
}
}
}
}
return false;
}
public bool HasAButton(int padNum) {
return joyMapping[padNum].HasA;
}
public bool HasBButton(int padNum) {
return joyMapping[padNum].HasB;
}
public bool HasXButton(int padNum) {
return joyMapping[padNum].HasX;
}
public bool HasYButton(int padNum) {
return joyMapping[padNum].HasY;
}
public bool HasSelectButton(int padNum) {
return joyMapping[padNum].HasSelect;
}
public bool HasStartButton(int padNum) {
return joyMapping[padNum].HasStart;
}
public bool HasHomeButton(int padNum) {
return joyMapping[padNum].HasHome;
}
public bool HasDPad(int padNum) {
return joyMapping[padNum].HasUp && joyMapping[padNum].HasDown && joyMapping[padNum].HasLeft && joyMapping[padNum].HasRight;
}
public bool HasL1(int padNum) {
return joyMapping[padNum].HasL1;
}
public bool HasL2(int padNum) {
return joyMapping[padNum].HasL2;
}
public bool HasR1(int padNum) {
return joyMapping[padNum].HasR1;
}
public bool HasR2(int padNum) {
return joyMapping[padNum].HasR2;
}
public bool HasLeftStick(int padNum) {
return joyMapping[padNum].HasLeftAxisX && joyMapping[padNum].HasLeftAxisY;
}
public bool HasRightStick(int padNum) {
return joyMapping[padNum].HasRightAxisX && joyMapping[padNum].HasRightAxisY;
}
public bool ADown(int padNum) {
return curJoyDown[padNum].A;
}
public bool AUp(int padNum) {
return !curJoyDown[padNum].A;
}
public bool APressed(int padNum) {
return (!prevJoyDown[padNum].A) && curJoyDown[padNum].A;
}
public bool AReleased(int padNum) {
return prevJoyDown[padNum].A && (!curJoyDown[padNum].A);
}
public bool BDown(int padNum) {
return curJoyDown[padNum].B;
}
public bool BUp(int padNum) {
return !curJoyDown[padNum].B;
}
public bool BPressed(int padNum) {
return (!prevJoyDown[padNum].B) && curJoyDown[padNum].B;
}
public bool BReleased(int padNum) {
return prevJoyDown[padNum].B && (!curJoyDown[padNum].B);
}
public bool XDown(int padNum) {
return curJoyDown[padNum].X;
}
public bool XUp(int padNum) {
return !curJoyDown[padNum].X;
}
public bool XPressed(int padNum) {
return (!prevJoyDown[padNum].X) && curJoyDown[padNum].X;
}
public bool XReleased(int padNum) {
return prevJoyDown[padNum].X && (!curJoyDown[padNum].X);
}
public bool YDown(int padNum) {
return curJoyDown[padNum].Y;
}
public bool YUp(int padNum) {
return !curJoyDown[padNum].Y;
}
public bool YPressed(int padNum) {
return (!prevJoyDown[padNum].Y) && curJoyDown[padNum].Y;
}
public bool YReleased(int padNum) {
return prevJoyDown[padNum].Y && !curJoyDown[padNum].Y;
}
public bool SelectDown(int padNum) {
return curJoyDown[padNum].Select;
}
public bool SelectUp(int padNum) {
return !curJoyDown[padNum].Select;
}
public bool SelectPressed(int padNum) {
return (!prevJoyDown[padNum].Select) && curJoyDown[padNum].Select;
}
public bool SelectReleased(int padNum) {
return prevJoyDown[padNum].Select && (!curJoyDown[padNum].Select);
}
public bool StartDown(int padNum) {
return curJoyDown[padNum].Start;
}
public bool StartUp(int padNum) {
return !curJoyDown[padNum].Start;
}
public bool StartPressed(int padNum) {
return (!prevJoyDown[padNum].Start) && curJoyDown[padNum].Start;
}
public bool StartReleased(int padNum) {
return prevJoyDown[padNum].Start && (!curJoyDown[padNum].Start);
}
public bool L1Down(int padNum) {
return curJoyDown[padNum].L1;
}
public bool L1Up(int padNum) {
return !curJoyDown[padNum].L1;
}
public bool L1Pressed(int padNum) {
return (!prevJoyDown[padNum].L1) && curJoyDown[padNum].L1;
}
public bool L1Released(int padNum) {
return prevJoyDown[padNum].L1 && (!curJoyDown[padNum].L1);
}
public bool L2Down(int padNum) {
return curJoyDown[padNum].L2;
}
public bool L2Up(int padNum) {
return !curJoyDown[padNum].L2;
}
public bool L2Pressed(int padNum) {
return (!prevJoyDown[padNum].L2) && curJoyDown[padNum].L2;
}
public bool L2Released(int padNum) {
return prevJoyDown[padNum].L2 && (!curJoyDown[padNum].L2);
}
public bool R1Down(int padNum) {
return curJoyDown[padNum].R1;
}
public bool R1Up(int padNum) {
return !curJoyDown[padNum].R1;
}
public bool R1Pressed(int padNum) {
return (!prevJoyDown[padNum].R1) && curJoyDown[padNum].R1;
}
public bool R1Released(int padNum) {
return prevJoyDown[padNum].R1 && (!curJoyDown[padNum].R1);
}
public bool UpDown(int padNum) {
return curJoyDown[padNum].Up;
}
public bool UpUp(int padNum) {
return !curJoyDown[padNum].Up;
}
public bool UpPressed(int padNum) {
return (!prevJoyDown[padNum].Up) && curJoyDown[padNum].Up;
}
public bool UpReleased(int padNum) {
return prevJoyDown[padNum].Up && (!curJoyDown[padNum].Up);
}
public bool DownDown(int padNum) {
return curJoyDown[padNum].Down;
}
public bool DownUp(int padNum) {
return !curJoyDown[padNum].Down;
}
public bool DownPressed(int padNum) {
return (!prevJoyDown[padNum].Down) && curJoyDown[padNum].Down;
}
public bool DownReleased(int padNum) {
return prevJoyDown[padNum].Down && (!curJoyDown[padNum].Down);
}
public bool LeftDown(int padNum) {
return curJoyDown[padNum].Left;
}
public bool LeftUp(int padNum) {
return !curJoyDown[padNum].Left;
}
public bool LeftPressed(int padNum) {
return (!prevJoyDown[padNum].Left) && curJoyDown[padNum].Left;
}
public bool LeftReleased(int padNum) {
return prevJoyDown[padNum].Left && (!curJoyDown[padNum].Left);
}
public bool RightDown(int padNum) {
return curJoyDown[padNum].Right;
}
public bool RightUp(int padNum) {
return !curJoyDown[padNum].Right;
}
public bool RightPressed(int padNum) {
return (!prevJoyDown[padNum].Right) && curJoyDown[padNum].Right;
}
public bool RightReleased(int padNum) {
return prevJoyDown[padNum].Right && (!curJoyDown[padNum].Right);
}
public float LeftStickX(int padNum) {
return curJoyDown[padNum].LeftAxis.X;
}
public float LeftStickY(int padNum) {
return curJoyDown[padNum].LeftAxis.Y;
}
public PointF LeftStick(int padNum) {
return curJoyDown[padNum].LeftAxis;
}
public float RightStickX(int padNum) {
return curJoyDown[padNum].RightAxis.X;
}
public float RightStickY(int padNum) {
return curJoyDown[padNum].RightAxis.Y;
}
public PointF RightStick(int padNum) {
return curJoyDown[padNum].RightAxis;
}
}
}