-
Notifications
You must be signed in to change notification settings - Fork 0
/
xbox_controller.h
executable file
·88 lines (65 loc) · 1.65 KB
/
xbox_controller.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
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <windows.h>
#include <iostream>
#include <Xinput.h>
#define BUTTON_SIZE 14
#define DEFAULT_DEADZONE 8269
#define MAX_MOTOR_SPEED 65500
#define MAX_STICK 32767
#define MINI_STICK -32768
#define MAX_TRIGGER 255
#define LEFT_SIDE 0
#define RIGHT_SIDE 1
#define UP 0
#define DOWN 1
#define LEFT 2
#define RIGHT 3
#define START 4
#define BACK 5
#define L_THUMB 6
#define R_THUMB 7
#define L_SHOULDER 8
#define R_SHOULDER 9
#define BUTTON_A 10
#define BUTTON_B 11
#define BUTTON_X 12
#define BUTTON_Y 13
typedef struct _COORDINATE {
SHORT axisX;
SHORT axisY;
} COORDINATE;
class XboxController{
private:
DWORD index;
XINPUT_BATTERY_INFORMATION BatteryInformation;
XINPUT_STATE State;
XINPUT_VIBRATION Vibration;
bool pushButtons[BUTTON_SIZE];
static const int buttonMask[14];
COORDINATE deadZone;
public:
// Constructor function
XboxController();
XboxController(DWORD controller_num);
// Functions for Battery Information
void PrintBatteryInform();
int GetBatteryInform();
// Set gamepad's status
void SetPushButtons();
// Get Packet Number, use for check any in input
DWORD GetPacketNumber();
// Functions for getting status of push buttons
void PrintPushButtons();
bool GetPushButton(int buttonName);
// Functions for getting position of thumbs
void SetDeadZone(int X, int Y);
COORDINATE GetStick(int side);
// Function for get value of a Trigger
int GetTrigger(int side);
// Set vibrations
void SetVibration(WORD leftMotor, WORD rightMotor);
//
int GetIndex();
};
#endif