-
Notifications
You must be signed in to change notification settings - Fork 0
/
vjoy.h
36 lines (30 loc) · 776 Bytes
/
vjoy.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
#include <IOKit/IOKitLib.h>
struct JoystickValues {
int8_t x;
int8_t y;
int8_t z;
int8_t rx;
int8_t buttons;
};
typedef unsigned char byte;
class FooHIDJoystick
{
public:
FooHIDJoystick(const std::string &name, const std::string &serialNumber);
~FooHIDJoystick();
bool hasError() const;
std::string errorMessage() const;
void setValue(JoystickValues newValues);
private:
bool createDevice() const;
bool sendToDevice() const;
void destroyDevice() const;
const std::string name;
const std::string serialNumber;
io_connect_t connection = 0;
JoystickValues values = {127, 127};
std::string _errorMessage;
bool _hasError = true;
bool connectionOpened = false;
bool deviceCreated = false;
};