RSeries astromech firmware
JoystickController.h
Go to the documentation of this file.
1 #ifndef JoystickController_h
2 #define JoystickController_h
3 
5 {
6 public:
7  struct AnalogStick
8  {
9  int8_t lx;
10  int8_t ly;
11  int8_t rx;
12  int8_t ry;
13  };
14 
15  struct AnalogButton
16  {
17  uint8_t up;
18  uint8_t right;
19  uint8_t down;
20  uint8_t left;
21 
22  uint8_t l2;
23  uint8_t r2;
24  uint8_t l1;
25  uint8_t r1;
26 
27  uint8_t triangle;
28  uint8_t circle;
29  uint8_t cross;
30  uint8_t square;
31  };
32 
33  struct Analog
34  {
37  };
38 
39  struct Button
40  {
41  uint8_t select : 1;
42  uint8_t l3 : 1;
43  uint8_t r3 : 1;
44  uint8_t start : 1;
45 
46  uint8_t up : 1;
47  uint8_t right : 1;
48  uint8_t down : 1;
49  uint8_t left : 1;
50 
51  uint8_t upright : 1;
52  uint8_t upleft : 1;
53  uint8_t downright: 1;
54  uint8_t downleft : 1;
55 
56  uint8_t l2 : 1;
57  uint8_t r2 : 1;
58  uint8_t l1 : 1;
59  uint8_t r1 : 1;
60 
61  uint8_t triangle : 1;
62  uint8_t circle : 1;
63  uint8_t cross : 1;
64  uint8_t square : 1;
65 
66  uint8_t ps : 1;
67  uint8_t share : 1;
68  uint8_t options : 1;
69  uint8_t touchpad : 1;
70  };
71 
73  {
74  kShutdown = 0x01,
75  kDying = 0x02,
76  kLow = 0x03,
77  kHigh = 0x04,
78  kFull = 0x05,
79  kCharging = 0xEE
80  };
81 
83  {
86  };
87 
88  struct Status
89  {
92  uint8_t charging : 1;
93  uint8_t rumbling : 1;
94  uint8_t audio : 1;
95  uint8_t mic : 1;
96  };
97 
98  /********************/
99  /* S E N S O R S */
100  /********************/
101 
102  struct Gyroscope
103  {
104  int16_t z;
105  };
106 
108  {
109  int16_t x;
110  int16_t y;
111  int16_t z;
112  };
113 
114  struct Sensor
115  {
118  };
119 
120  struct Event
121  {
126  };
127 
128  struct State
129  {
134  };
135 
138 
140  fConnected(false),
141  fConnecting(false),
142  fCongested(false)
143  {
144  }
145 
146  inline bool isConnected() const { return fConnected; }
147  inline bool isConnecting() const { return fConnecting; }
148  inline bool isCongested() const { return fCongested; }
149 
150  virtual void disconnect() {}
151 
152  virtual void notify() {}
153  virtual void onConnect() { fConnected = true; }
154  virtual void onDisconnect() { fConnected = false; }
155  virtual void stop() {}
156 
157  // virtual float getThrottle() const { return (float)state.analog.button.l2/255.0; }
158  // virtual float getThrottle() const { return (float)state.analog.button.l2/255.0; }
159 
160 protected:
164 };
165 
166 #endif
JoystickController::Event
Definition: JoystickController.h:120
JoystickController::Status::charging
uint8_t charging
Definition: JoystickController.h:92
JoystickController::state
State state
Definition: JoystickController.h:136
JoystickController::AnalogButton::l2
uint8_t l2
Definition: JoystickController.h:22
JoystickController::Button::cross
uint8_t cross
Definition: JoystickController.h:63
JoystickController::isConnecting
bool isConnecting() const
Definition: JoystickController.h:147
JoystickController::Button::left
uint8_t left
Definition: JoystickController.h:49
JoystickController::Accelerometer
Definition: JoystickController.h:107
JoystickController::JoystickController
JoystickController()
Definition: JoystickController.h:139
JoystickController::kHigh
@ kHigh
Definition: JoystickController.h:77
JoystickController::Status
Definition: JoystickController.h:88
JoystickController::AnalogStick::lx
int8_t lx
Definition: JoystickController.h:9
JoystickController::kLow
@ kLow
Definition: JoystickController.h:76
JoystickController::Button::share
uint8_t share
Definition: JoystickController.h:67
JoystickController::isConnected
bool isConnected() const
Definition: JoystickController.h:146
JoystickController::notify
virtual void notify()
Definition: JoystickController.h:152
JoystickController::AnalogButton
Definition: JoystickController.h:15
JoystickController::kBluetooth
@ kBluetooth
Definition: JoystickController.h:85
JoystickController::Event::button_down
Button button_down
Definition: JoystickController.h:122
JoystickController::State
Definition: JoystickController.h:128
JoystickController::Status::audio
uint8_t audio
Definition: JoystickController.h:94
JoystickController::State::analog
Analog analog
Definition: JoystickController.h:130
JoystickController::Button::start
uint8_t start
Definition: JoystickController.h:44
JoystickController::onDisconnect
virtual void onDisconnect()
Definition: JoystickController.h:154
JoystickController::Button::r1
uint8_t r1
Definition: JoystickController.h:59
JoystickController::AnalogButton::up
uint8_t up
Definition: JoystickController.h:17
JoystickController::stop
virtual void stop()
Definition: JoystickController.h:155
JoystickController::Button::r3
uint8_t r3
Definition: JoystickController.h:43
JoystickController::Button::r2
uint8_t r2
Definition: JoystickController.h:57
JoystickController::State::button
Button button
Definition: JoystickController.h:131
JoystickController::AnalogStick::rx
int8_t rx
Definition: JoystickController.h:11
JoystickController::AnalogButton::cross
uint8_t cross
Definition: JoystickController.h:29
JoystickController::kFull
@ kFull
Definition: JoystickController.h:78
JoystickController::Sensor::accelerometer
Accelerometer accelerometer
Definition: JoystickController.h:116
JoystickController::AnalogButton::down
uint8_t down
Definition: JoystickController.h:19
JoystickController::Analog::stick
AnalogStick stick
Definition: JoystickController.h:35
JoystickController::AnalogButton::right
uint8_t right
Definition: JoystickController.h:18
JoystickController::Analog
Definition: JoystickController.h:33
JoystickController::AnalogButton::l1
uint8_t l1
Definition: JoystickController.h:24
JoystickController::AnalogStick::ly
int8_t ly
Definition: JoystickController.h:10
JoystickController::Button::square
uint8_t square
Definition: JoystickController.h:64
JoystickController::AnalogButton::triangle
uint8_t triangle
Definition: JoystickController.h:27
JoystickController::Accelerometer::x
int16_t x
Definition: JoystickController.h:109
JoystickController::Button::downleft
uint8_t downleft
Definition: JoystickController.h:54
JoystickController::Button::options
uint8_t options
Definition: JoystickController.h:68
JoystickController::AnalogStick
Definition: JoystickController.h:7
JoystickController::fCongested
bool fCongested
Definition: JoystickController.h:163
JoystickController::Button::upright
uint8_t upright
Definition: JoystickController.h:51
JoystickController::Button::circle
uint8_t circle
Definition: JoystickController.h:62
JoystickController::ConnectionStatus
ConnectionStatus
Definition: JoystickController.h:82
JoystickController::Button::ps
uint8_t ps
Definition: JoystickController.h:66
JoystickController::Button::l1
uint8_t l1
Definition: JoystickController.h:58
JoystickController::AnalogButton::circle
uint8_t circle
Definition: JoystickController.h:28
JoystickController::Analog::button
AnalogButton button
Definition: JoystickController.h:36
JoystickController::Event::button_up
Button button_up
Definition: JoystickController.h:123
JoystickController::Button::l3
uint8_t l3
Definition: JoystickController.h:42
JoystickController::Button::upleft
uint8_t upleft
Definition: JoystickController.h:52
JoystickController::Button::up
uint8_t up
Definition: JoystickController.h:46
JoystickController::State::status
Status status
Definition: JoystickController.h:132
JoystickController::event
Event event
Definition: JoystickController.h:137
JoystickController::Button::down
uint8_t down
Definition: JoystickController.h:48
JoystickController::Button
Definition: JoystickController.h:39
JoystickController::onConnect
virtual void onConnect()
Definition: JoystickController.h:153
JoystickController::AnalogButton::square
uint8_t square
Definition: JoystickController.h:30
JoystickController::Status::battery
enum BatteryStatus battery
Definition: JoystickController.h:90
JoystickController::AnalogButton::r1
uint8_t r1
Definition: JoystickController.h:25
JoystickController::AnalogStick::ry
int8_t ry
Definition: JoystickController.h:12
JoystickController::Button::l2
uint8_t l2
Definition: JoystickController.h:56
JoystickController::Status::mic
uint8_t mic
Definition: JoystickController.h:95
JoystickController::Button::right
uint8_t right
Definition: JoystickController.h:47
JoystickController::fConnected
bool fConnected
Definition: JoystickController.h:161
JoystickController::Accelerometer::y
int16_t y
Definition: JoystickController.h:110
JoystickController
Definition: JoystickController.h:4
JoystickController::disconnect
virtual void disconnect()
Definition: JoystickController.h:150
JoystickController::Button::triangle
uint8_t triangle
Definition: JoystickController.h:61
JoystickController::Button::touchpad
uint8_t touchpad
Definition: JoystickController.h:69
JoystickController::Sensor
Definition: JoystickController.h:114
JoystickController::Event::long_button_up
Button long_button_up
Definition: JoystickController.h:124
JoystickController::Gyroscope
Definition: JoystickController.h:102
JoystickController::Sensor::gyroscope
Gyroscope gyroscope
Definition: JoystickController.h:117
JoystickController::kUSB
@ kUSB
Definition: JoystickController.h:84
JoystickController::isCongested
bool isCongested() const
Definition: JoystickController.h:148
JoystickController::Accelerometer::z
int16_t z
Definition: JoystickController.h:111
JoystickController::BatteryStatus
BatteryStatus
Definition: JoystickController.h:72
JoystickController::Event::analog_changed
Analog analog_changed
Definition: JoystickController.h:125
JoystickController::AnalogButton::r2
uint8_t r2
Definition: JoystickController.h:23
JoystickController::AnalogButton::left
uint8_t left
Definition: JoystickController.h:20
JoystickController::Gyroscope::z
int16_t z
Definition: JoystickController.h:104
JoystickController::fConnecting
bool fConnecting
Definition: JoystickController.h:162
JoystickController::State::sensor
Sensor sensor
Definition: JoystickController.h:133
JoystickController::Button::downright
uint8_t downright
Definition: JoystickController.h:53
JoystickController::Status::rumbling
uint8_t rumbling
Definition: JoystickController.h:93
JoystickController::kDying
@ kDying
Definition: JoystickController.h:75
JoystickController::Status::connection
enum ConnectionStatus connection
Definition: JoystickController.h:91
JoystickController::kShutdown
@ kShutdown
Definition: JoystickController.h:74
JoystickController::kCharging
@ kCharging
Definition: JoystickController.h:79
JoystickController::Button::select
uint8_t select
Definition: JoystickController.h:41