forked from khampf/g13
-
Notifications
You must be signed in to change notification settings - Fork 1
/
g13_stick.hpp
67 lines (48 loc) · 1.28 KB
/
g13_stick.hpp
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
//
// Created by khampf on 07-05-2020.
//
#ifndef G13_G13_STICK_HPP
#define G13_G13_STICK_HPP
#include <vector>
#include "helper.hpp"
namespace G13 {
class G13_Device;
typedef Helper::Coord<int> G13_StickCoord;
typedef Helper::Bounds<int> G13_StickBounds;
typedef Helper::Coord<unsigned char> G13_ZoneCoord;
typedef Helper::Bounds<unsigned char> G13_ZoneBounds;
// *************************************************************************
class G13_StickZone;
enum stick_mode_t {
STICK_ABSOLUTE,
// STICK_RELATIVE,
STICK_KEYS,
STICK_CALCENTER,
STICK_CALBOUNDS,
STICK_CALNORTH
};
class G13_Stick {
public:
explicit G13_Stick(G13_Device &keypad);
void ParseJoystick(const unsigned char *buf);
void set_mode(stick_mode_t);
G13_StickZone *zone(const std::string &, bool create = false);
void RemoveZone(const G13_StickZone &zone);
/*
[[nodiscard]] const std::vector<G13_StickZone> &zones() const {
return m_zones;
}
*/
void dump(std::ostream &) const;
protected:
void RecalcCalibrated();
G13_Device &_keypad;
std::vector<G13_StickZone> m_zones;
G13_StickBounds m_bounds;
G13_StickCoord m_center_pos;
G13_StickCoord m_north_pos;
G13_StickCoord m_current_pos;
stick_mode_t m_stick_mode;
};
} // namespace G13
#endif // G13_G13_STICK_HPP