-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSGD_DirectInput.h
2310 lines (2099 loc) · 79.8 KB
/
CSGD_DirectInput.h
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////////////////////////////////////////////////////////////////
// File : "CSGD_DirectInput.h"
//
// Author : David Brown (DB)
// Based in part on:
// -Input code from the book: "OpenGL Game Programming" by Kevin Hawkins and Dave Astle.
// -The previous CSGD_DirectInput wrapper by Jensen Rivera.
//
// Creation Date : 5/25/2008
//
// Purpose : To wrap DirectInput functionality.
// Allows the use of Keyboard, Mouse,
// and Joysticks through DirectInput.
//
// Special thanks to: Ari Patrick for testing this wrapper and
// providing the product name for wireless Xbox360 controllers.
/////////////////////////////////////////////////////////////////
/*
Disclaimer:
This source code was developed for and is the property of
Full Sail University's Game Development Program (c) 2008-2009.
Full Sail students may not redistribute this code, but may
use it in any project used for educational purposes.
*/
#pragma once
// The version of DirectInput to use.
#ifndef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0X800
#endif
#include <dinput.h>
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
#include <vector>
using std::vector;
#include "SGD_Util.h" // for utility macros
// Forward declarations:
class CSGD_DIKeyboard;
class CSGD_DIMouse;
class CSGD_DIJoystick;
// Enumerations:
// Devices:
enum DeviceFlags { DI_KEYBOARD = 1, DI_MOUSE = 2, DI_JOYSTICKS = 4 };
// Directions
enum Directions { DIR_LEFT = 0, DIR_RIGHT = 1, DIR_UP = 2, DIR_DOWN = 3, DIR_MAX };
// Mouse buttons
enum MouseButtons { MOUSE_LEFT = 0, MOUSE_RIGHT = 1, MOUSE_MIDDLE = 2, MOUSE_MAX };
class CSGD_DirectInput
{
private:
LPDIRECTINPUT8 m_lpDIObject; // DirectInput COM Object
CSGD_DIKeyboard* m_pKeyboard; // Keyboard object
CSGD_DIMouse* m_pMouse; // Mouse object
vector<CSGD_DIJoystick*> m_vpJoysticks; // Joysticks attached to the system
// Utility struct for joystick setup:
struct tJoystickSetupInfo
{
HWND hWnd;
bool bIsExclusive;
};
static CSGD_DirectInput m_Instance; // The instance of this class.
// Trilogy of EVIL!
// Constructor
CSGD_DirectInput(void);
// Copy Constructor
CSGD_DirectInput(const CSGD_DirectInput&);
// Assignment Operator
CSGD_DirectInput& operator=(const CSGD_DirectInput&);
// Plus Destructor
~CSGD_DirectInput(void);
// Private utility functions:
///////////////////////////////////////////////////////////////////
// Function: "InitKeyboard"
//
// Last Modified: 5/25/2008
//
// Input : hWnd - The Main window handle.
// bIsExclusive - Whether or not you want exclusive control of the device.
//
// Return : true if it was able to initialize the Keyboard.
//
// Purpose : Initialize the Keyboard for DirectInput.
///////////////////////////////////////////////////////////////////
bool InitKeyboard(HWND hWnd, bool bIsExclusive = false);
///////////////////////////////////////////////////////////////////
// Function: "InitMouse"
//
// Last Modified: 5/25/2008
//
// Input : hWnd - The Main window handle.
// bIsExclusive - Whether or not you want exclusive control of the device.
//
// Return : true if it was able to initialize the Mouse.
//
// Purpose : Initialize the Mouse for DirectInput.
///////////////////////////////////////////////////////////////////
bool InitMouse(HWND hWnd, bool bIsExclusive = false);
///////////////////////////////////////////////////////////////////
// Function: "InitJoysticks"
//
// Last Modified: 5/26/2008
//
// Input : hWnd - The Main window handle.
// bIsExclusive - Whether or not you want exclusive control of the device.
//
// Return : true if it was able to initialize the joysticks.
//
// Purpose : Initialize the joysticks for DirectInput.
///////////////////////////////////////////////////////////////////
bool InitJoysticks(HWND hWnd, bool bIsExclusive = false);
///////////////////////////////////////////////////////////////////
// Function: "EnumJoysticksCallback"
//
// Last Modified: 5/26/2008
//
// Input : lpddi - Pointer to the DirectInput Device Instance of the joystick that was found.
// pVoid - Pointer to something you want to use for this function.
//
// Return : Returns after all of the joysticks connected to the computer have been found.
//
// Purpose : Checks to see if there are any Joysticks presently attached to the computer.
///////////////////////////////////////////////////////////////////
static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* lpdidi, VOID* pVoid);
public:
/////////////////////////////////////////////////////////////////////
// Function: "GetInstance"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : The instance of this class.
//
// Purpose : Gets the instance of this class.
////////////////////////////////////////////////////////////////////
static CSGD_DirectInput* GetInstance(void);
///////////////////////////////////////////////////////////////////
// Function: "InitDirectInput"
//
// Last Modified: 7/05/2008
//
// Input : hWnd - The Main window handle.
// hInstance - The Main application Instance.
// unInitDevices - A combination of flags representing which
// devices to initialize (i.e. DI_KEYBOARD | DI_MOUSE).
// unExclusiveDevices - A combination of flags representing which
// devices to make exclusive (i.e. DI_JOYSTICKS).
//
// Return : true if it initialized the DirectInput object and all
// of the requested devices.
//
// Purpose : To initialize the DirectInput Object and requested devices.
///////////////////////////////////////////////////////////////////
bool InitDirectInput(HWND hWnd, HINSTANCE hInstance, unsigned int unInitDevices, unsigned int unExclusiveDevices = 0);
///////////////////////////////////////////////////////////////////
// Function: "ShutdownDirectInput"
//
// Last Modified: 5/25/2008
//
// Input: void
//
// Return: void
//
// Purpose: Shuts down DirectInput and any initialized devices.
///////////////////////////////////////////////////////////////////
void ShutdownDirectInput(void);
///////////////////////////////////////////////////////////////////
// Function: "ReadDevices"
//
// Last Modified: 6/13/2008
//
// Input : void
//
// Return : void
//
// Purpose : Gets the state of all the initialized devices.
// Reads buffered data as well (for Ex functions).
///////////////////////////////////////////////////////////////////
void ReadDevices(void);
///////////////////////////////////////////////////////////////////
// Function: "AcquireAll"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : void
//
// Purpose : Acquires all the initialized direct input devices (i.e. keyboard, mouse, and joysticks).
// Ideally called when the application gains focus.
///////////////////////////////////////////////////////////////////
void AcquireAll(void);
///////////////////////////////////////////////////////////////////
// Function: "UnacquireAll"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : void
//
// Purpose : Unacquires all the initialized direct input devices (i.e. keyboard, mouse, and joysticks).
// Ideally called when the application loses focus.
///////////////////////////////////////////////////////////////////
void UnacquireAll(void);
/*********************** Device specific functions: ********************/
///////////////////////////////////////////////////////////////////
// KEYBOARD //
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Function: "KeyDown"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if the Key is currently down.
//
// Purpose : Gets the current (immediate) state of a Key.
///////////////////////////////////////////////////////////////////
bool KeyDown(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "KeyPressed"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if Key was pressed this frame.
//
// Purpose : To tell if a key was just pressed (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool KeyPressed(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "KeyPressedEx"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if the Key was pressed this frame.
//
// Purpose : To tell if a key was just pressed (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool KeyPressedEx(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "KeyUp"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if the Key is currently up.
//
// Purpose : Gets the current (immediate) state of a Key.
///////////////////////////////////////////////////////////////////
bool KeyUp(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "KeyReleased"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if the Key was released this frame.
//
// Purpose : To tell if a key was just released (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool KeyReleased(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "KeyReleasedEx"
//
// Last Modified: 5/25/2008
//
// Input : ucDIKey - The DirectInput Keyboard Constant to check, such as DIK_ESCAPE.
//
// Return : true if the Key was released this frame.
//
// Purpose : To tell if a key was just released (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool KeyReleasedEx(unsigned char ucDIKey);
///////////////////////////////////////////////////////////////////
// Function: "CheckKeys"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : 0 if nothing was pressed, otherwise the ascii character
// value of the key the user pressed.
//
// Purpose : To get the ascii character value of the key the user typed.
// So they can enter letters.
///////////////////////////////////////////////////////////////////
char CheckKeys(void);
///////////////////////////////////////////////////////////////////
// Function: "CheckBufferedKeysEx"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : 0 if nothing was pressed, otherwise the ascii character
// value of the key the user pressed.
//
// Purpose : To get the ascii character value of the key the user just typed.
// So they can enter letters (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
char CheckBufferedKeysEx(void);
///////////////////////////////////////////////////////////////////
// Function: "GetDIKCode"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : 0 if nothing was pressed, otherwise the DIK code
// of the key the user pressed.
//
// Purpose : To get the DIK code of the key the user is pressing.
// For key binding.
///////////////////////////////////////////////////////////////////
unsigned char GetDIKCode(void);
///////////////////////////////////////////////////////////////////
// Function: "GetBufferedDIKCodeEx"
//
// Last Modified: 5/25/2008
//
// Input : void
//
// Return : 0 if nothing was pressed, otherwise the DIK code
// of the key the user pressed.
//
// Purpose : To get the DIK code of the key the user just pressed.
// For key binding (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
unsigned char GetBufferedDIKCodeEx(void);
///////////////////////////////////////////////////////////////////
// MOUSE //
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonDown"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button is currently down.
//
// Purpose : Gets the current (immediate) state of a mouse button.
///////////////////////////////////////////////////////////////////
bool MouseButtonDown(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonPressed"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button was pressed this frame.
//
// Purpose : To tell if a mouse button was just pressed (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool MouseButtonPressed(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonPressedEx"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button was pressed this frame.
//
// Purpose : To tell if a mouse button was just pressed (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool MouseButtonPressedEx(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonUp"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button is currently up.
//
// Purpose : Gets the current (immediate) state of a mouse button.
///////////////////////////////////////////////////////////////////
bool MouseButtonUp(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonReleased"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button was released this frame.
//
// Purpose : To tell if a mouse button was just released (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool MouseButtonReleased(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseButtonReleasedEx"
//
// Last Modified: 5/25/2008
//
// Input : ucButton - The mouse button to check for (i.e. 0, 1, or 2)
// 0 = left, 1 = right, 2 = middle
//
// Return : true if the mouse button was released this frame.
//
// Purpose : To tell if a mouse button was just released (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool MouseButtonReleasedEx(unsigned char ucButton);
///////////////////////////////////////////////////////////////////
// Function: "MouseCheckBufferedButtons"
//
// Last Modified: 6/13/2008
//
// Input : void
//
// Return : The mouse button that was just pressed (i.e. 0, 1, or 2). -1 if there was no button pressed.
//
// Purpose : To tell if a mouse button was just pressed (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
int MouseCheckBufferedButtons(void);
///////////////////////////////////////////////////////////////////
// Function: "MouseCheckBufferedButtonsEx"
//
// Last Modified: 5/27/2008
//
// Input : void
//
// Return : The mouse button that was just pressed (i.e. 0, 1, or 2). -1 if there was no button pressed.
//
// Purpose : To tell if a mouse button was just pressed (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
int MouseCheckBufferedButtonsEx(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseMovementX"
//
// Last Modified : 5/25/2008
//
// Input : void
//
// Return : The amount the mouse has moved this frame.
//
// Purpose : To report the relative motion of the mouse
// in the X dimension.
///////////////////////////////////////////////////////////////////
long MouseMovementX(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseMovementY"
//
// Last Modified : 5/25/2008
//
// Input : void
//
// Return : The amount the mouse has moved this frame.
//
// Purpose : To report the relative motion of the mouse
// in the Y dimension.
///////////////////////////////////////////////////////////////////
long MouseMovementY(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseWheelMovement"
//
// Last Modified : 5/25/2008
//
// Input : void
//
// Return : The amount the mouse wheel has moved this frame.
// Positive(+) values mean pushing the wheel away from you.
// Negative(-) values mean pulling the wheel toward you.
//
// Purpose : To report the relative motion of the mouse
// wheel.
///////////////////////////////////////////////////////////////////
long MouseWheelMovement(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseGetNumButtons"
//
// Last Modified : 5/26/2008
//
// Input : void
//
// Return : The number of buttons supported on the device.
//
// Purpose : To report the number of buttons on the device.
///////////////////////////////////////////////////////////////////
int MouseGetNumButtons(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseGetPosX"
//
// Last Modified : 6/23/2008
//
// Input : void
//
// Return : The "psuedo" position of the mouse.
//
// Purpose : To help track the "psuedo" position of the mouse.
///////////////////////////////////////////////////////////////////
int MouseGetPosX(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseGetPosY"
//
// Last Modified : 6/23/2008
//
// Input : void
//
// Return : The "psuedo" position of the mouse.
//
// Purpose : To help track the "psuedo" position of the mouse.
///////////////////////////////////////////////////////////////////
int MouseGetPosY(void);
///////////////////////////////////////////////////////////////////
// Function : "MouseSetPosX"
//
// Last Modified : 7/05/2008
//
// Input : The "psuedo" position of the mouse.
//
// Return : void
//
// Purpose : To set the "psuedo" position of the mouse.
///////////////////////////////////////////////////////////////////
void MouseSetPosX(int nPosX);
///////////////////////////////////////////////////////////////////
// Function : "MouseSetPosY"
//
// Last Modified : 7/05/2008
//
// Input : The "psuedo" position of the mouse.
//
// Return : void
//
// Purpose : To set the "psuedo" position of the mouse.
///////////////////////////////////////////////////////////////////
void MouseSetPosY(int nPosY);
///////////////////////////////////////////////////////////////////
// JOYSTICKS //
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonDown"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button is currently down.
//
// Purpose : Gets the current (immediate) state of a joystick button.
///////////////////////////////////////////////////////////////////
bool JoystickButtonDown(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonPressed"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button was pressed this frame.
//
// Purpose : To tell if a joystick button was just pressed (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool JoystickButtonPressed(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonPressedEx"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button was pressed this frame.
//
// Purpose : To tell if a joystick button was just pressed (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool JoystickButtonPressedEx(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonUp"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button is currently up.
//
// Purpose : Gets the current (immediate) state of a joystick button.
///////////////////////////////////////////////////////////////////
bool JoystickButtonUp(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonReleased"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button was released this frame.
//
// Purpose : To tell if a joystick button was just released (using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool JoystickButtonReleased(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickButtonReleasedEx"
//
// Last Modified: 6/01/2008
//
// Input : ucButton - The joystick button to check for.
// nJoyNum - The joystick to check.
//
// Return : true if the joystick button was released this frame.
//
// Purpose : To tell if a joystick button was just released (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool JoystickButtonReleasedEx(unsigned char ucButton, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// D-pad:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Function: "JoystickDPadDown"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the D-pad direction is currently being held down.
//
// Purpose : To tell if a D-pad direction is down.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickDPadDown(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickDPadPressed"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the D-pad was pressed a certain direction.
//
// Purpose : To get the (buffered) direction the D-pad was pressed (without using DirectInput's Buffered Input).
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickDPadPressed(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickDPadUp"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the D-pad direction is currently up.
//
// Purpose : To tell if a D-pad direction is up.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickDPadUp(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickDPadReleased"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the D-pad direction was released this frame.
//
// Purpose : To tell if a D-pad direction was just released (without using DirectInput's Buffered Input).
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickDPadReleased(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Analog Sticks:
///////////////////////////////////////////////////////////////////
// L-stick:
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickDirDown"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the left stick is currently held a certain direction.
//
// Purpose : To get the (immediate) direction the stick is being held.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickGetLStickDirDown(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickDirPressed"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the left stick was pressed a certain direction.
//
// Purpose : To get the (buffered) direction the stick was pressed (without using DirectInput's Buffered Input).
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
bool JoystickGetLStickDirPressed(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickXAmount"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -JOYSTICK_RANGE to +JOYSTICK_RANGE ((-) Left and (+) Right)
//
// Purpose : To get the position of the joystick in a digital range.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
int JoystickGetLStickXAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickYAmount"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -JOYSTICK_RANGE to +JOYSTICK_RANGE (-JOYSTICK_RANGE is Up, +JOYSTICK_RANGE is Down)
//
// Purpose : To get the position of the joystick in a digital range.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
int JoystickGetLStickYAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickXNormalized"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -1.0 to +1.0 (-1.0 is Left, +1.0 is Right)
//
// Purpose : To get the position of the joystick in a normalized range.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
float JoystickGetLStickXNormalized(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLStickYNormalized"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -1.0 to +1.0 (-1.0 is Up, +1.0 is Down)
//
// Purpose : To get the position of the joystick in a normalized range.
//
// NOTE: L-stick and D-pad can usually be swapped by pressing a "Mode" button on the controller.
///////////////////////////////////////////////////////////////////
float JoystickGetLStickYNormalized(int nJoyNum = 0);
// R-stick:
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickDirDown"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the right stick is currently held a certain direction.
//
// Purpose : To get the (immediate) direction the stick is being held.
///////////////////////////////////////////////////////////////////
bool JoystickGetRStickDirDown(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickDirPressed"
//
// Last Modified: 6/01/2008
//
// Input : nDir - The direction to check (i.e. DIR_RIGHT).
// nJoyNum - The joystick to check.
//
// Return : true if the right stick was pressed a certain direction.
//
// Purpose : To get the (buffered) direction the stick was pressed (without using DirectInput's Buffered Input).
///////////////////////////////////////////////////////////////////
bool JoystickGetRStickDirPressed(int nDir, int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickXAmount"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -JOYSTICK_RANGE to +JOYSTICK_RANGE ((-) Left and (+) Right)
//
// Purpose : To get the position of the joystick in a digital range.
///////////////////////////////////////////////////////////////////
int JoystickGetRStickXAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickYAmount"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -JOYSTICK_RANGE to +JOYSTICK_RANGE (-JOYSTICK_RANGE is Up, +JOYSTICK_RANGE is Down)
//
// Purpose : To get the position of the joystick in a digital range.
///////////////////////////////////////////////////////////////////
int JoystickGetRStickYAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickXNormalized"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -1.0 to +1.0 (-1.0 is Left, +1.0 is Right)
//
// Purpose : To get the position of the joystick in a normalized range.
///////////////////////////////////////////////////////////////////
float JoystickGetRStickXNormalized(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRStickYNormalized"
//
// Last Modified: 6/01/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : -1.0 to +1.0 (-1.0 is Up, +1.0 is Down)
//
// Purpose : To get the position of the joystick in a normalized range.
///////////////////////////////////////////////////////////////////
float JoystickGetRStickYNormalized(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Triggers:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLTriggerAmount"
//
// Last Modified: 6/12/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : 0 to JOYSTICK_AXIS_RANGE
//
// Purpose : To get the position of the trigger in a digital range.
//
// NOTE: If both triggers are pulled at the same time the reading won't
// be accurate as their input is combined into one axis by DirectInput.
///////////////////////////////////////////////////////////////////
int JoystickGetLTriggerAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRTriggerAmount"
//
// Last Modified: 6/012/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : 0 to JOYSTICK_AXIS_RANGE
//
// Purpose : To get the position of the trigger in a digital range.
//
// NOTE: If both triggers are pulled at the same time the reading won't
// be accurate as their input is combined into one axis by DirectInput.
///////////////////////////////////////////////////////////////////
int JoystickGetRTriggerAmount(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetLTriggerNormalized"
//
// Last Modified: 6/12/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : 0.0 to 1.0 to (0.0 is not pressed, +1.0 is pulled all the way down)
//
// Purpose : To get the position of the trigger in a normalized range.
//
// NOTE: If both triggers are pulled at the same time the reading won't
// be accurate as their input is combined into one axis by DirectInput.
///////////////////////////////////////////////////////////////////
float JoystickGetLTriggerNormalized(int nJoyNum = 0);
///////////////////////////////////////////////////////////////////
// Function: "JoystickGetRTriggerNormalized"
//
// Last Modified: 6/12/2008
//
// Input : nJoyNum - The joystick to check.
//
// Return : 0.0 to 1.0 to (0.0 is not pressed, +1.0 is pulled all the way down)
//
// Purpose : To get the position of the trigger in a normalized range.
//
// NOTE: If both triggers are pulled at the same time the reading won't
// be accurate as their input is combined into one axis by DirectInput.
///////////////////////////////////////////////////////////////////
float JoystickGetRTriggerNormalized(int nJoyNum = 0);