-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJoystickEvent.h
43 lines (32 loc) · 1.03 KB
/
JoystickEvent.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
//
// Created by guru on 11.10.23.
//
#ifndef DOJOYSTICK_JOYSTICKEVENT_H
#define DOJOYSTICK_JOYSTICKEVENT_H
#include <linux/joystick.h>
#include <string>
class JoystickEvent {
public:
typedef enum { SINGLE = 0,
DOUBLE,
HOLD,
DOUBLE_HOLD,
DOWN } CLICK_TYPE;
public:
JoystickEvent(js_event deviceEvent, CLICK_TYPE t) : nativeEvent(deviceEvent), clickType(t) {}
int getButtonNumber() const {
return nativeEvent.number;
}
bool isButtonDown() const { return nativeEvent.value == 1; }
bool isButtonUp() const { return nativeEvent.value == 0; }
void print() const;
void print(CLICK_TYPE type) const;
static void print_js_event(struct js_event js);
std::string clickTypeToString(CLICK_TYPE clickType) const;
js_event getNativeEvent() const { return nativeEvent; }
CLICK_TYPE getClickType() const { return clickType; }
private:
js_event nativeEvent;
CLICK_TYPE clickType;
};
#endif//DOJOYSTICK_JOYSTICKEVENT_H