blob: 4b5c5a6950bcb0340ad0a6598a5a2d3975d4be84 [file] [log] [blame]
Brian Silvermanc2065732015-11-28 22:55:30 +00001#ifndef AOS_INPUT_JOYSTICK_INPUT_H_
2#define AOS_INPUT_JOYSTICK_INPUT_H_
Brian Silvermanba3de7e2013-05-08 16:18:15 -07003
Austin Schuhb58ceb62017-02-05 14:21:57 -08004#include <atomic>
5
John Park33858a32018-09-28 23:05:48 -07006#include "aos/input/driver_station_data.h"
Brian Silvermanba3de7e2013-05-08 16:18:15 -07007
8namespace aos {
9namespace input {
10
Brian Silvermanc25bc892013-05-09 19:09:34 -070011// A class for handling joystick packet values.
12// It will call RunIteration each time a new packet is received.
13//
Brian Silverman699f0cb2015-02-05 19:45:01 -050014// This class automatically handles updating ::aos::joystick_state and logging
15// (at INFO) button edges.
Brian Silvermanba3de7e2013-05-08 16:18:15 -070016class JoystickInput {
17 public:
18 void Run();
19
20 private:
Brian Silvermanc25bc892013-05-09 19:09:34 -070021 // Subclasses should do whatever they want with data here.
Brian Silvermanba3de7e2013-05-08 16:18:15 -070022 virtual void RunIteration(const driver_station::Data &data) = 0;
Austin Schuhb58ceb62017-02-05 14:21:57 -080023
24 static void Quit(int /*signum*/);
25
26 static ::std::atomic<bool> run_;
Brian Silvermanba3de7e2013-05-08 16:18:15 -070027};
28
Austin Schuh374fd172014-10-25 17:57:54 -070029// Class which will proxy joystick information from UDP packets to the queues.
30class JoystickProxy {
31 public:
32 void Run();
33};
34
Brian Silvermanba3de7e2013-05-08 16:18:15 -070035} // namespace input
36} // namespace aos
37
Brian Silvermanc2065732015-11-28 22:55:30 +000038#endif // AOS_INPUT_JOYSTICK_INPUT_H_