Brian Silverman | c206573 | 2015-11-28 22:55:30 +0000 | [diff] [blame] | 1 | #ifndef AOS_INPUT_JOYSTICK_INPUT_H_ |
| 2 | #define AOS_INPUT_JOYSTICK_INPUT_H_ |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 3 | |
Austin Schuh | b58ceb6 | 2017-02-05 14:21:57 -0800 | [diff] [blame] | 4 | #include <atomic> |
| 5 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 6 | #include "aos/input/driver_station_data.h" |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 7 | |
| 8 | namespace aos { |
| 9 | namespace input { |
| 10 | |
Brian Silverman | c25bc89 | 2013-05-09 19:09:34 -0700 | [diff] [blame] | 11 | // A class for handling joystick packet values. |
| 12 | // It will call RunIteration each time a new packet is received. |
| 13 | // |
Brian Silverman | 699f0cb | 2015-02-05 19:45:01 -0500 | [diff] [blame] | 14 | // This class automatically handles updating ::aos::joystick_state and logging |
| 15 | // (at INFO) button edges. |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 16 | class JoystickInput { |
| 17 | public: |
| 18 | void Run(); |
| 19 | |
| 20 | private: |
Brian Silverman | c25bc89 | 2013-05-09 19:09:34 -0700 | [diff] [blame] | 21 | // Subclasses should do whatever they want with data here. |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 22 | virtual void RunIteration(const driver_station::Data &data) = 0; |
Austin Schuh | b58ceb6 | 2017-02-05 14:21:57 -0800 | [diff] [blame] | 23 | |
| 24 | static void Quit(int /*signum*/); |
| 25 | |
| 26 | static ::std::atomic<bool> run_; |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 27 | }; |
| 28 | |
Austin Schuh | 374fd17 | 2014-10-25 17:57:54 -0700 | [diff] [blame] | 29 | // Class which will proxy joystick information from UDP packets to the queues. |
| 30 | class JoystickProxy { |
| 31 | public: |
| 32 | void Run(); |
| 33 | }; |
| 34 | |
Brian Silverman | ba3de7e | 2013-05-08 16:18:15 -0700 | [diff] [blame] | 35 | } // namespace input |
| 36 | } // namespace aos |
| 37 | |
Brian Silverman | c206573 | 2015-11-28 22:55:30 +0000 | [diff] [blame] | 38 | #endif // AOS_INPUT_JOYSTICK_INPUT_H_ |