Move aos/input and aos/robot_state to frc971/input
Neither folder makes any sense as part of aos/.
Change-Id: I10e0532da4e688c18a9354012b783c43566fd2a1
diff --git a/frc971/input/joystick_input.h b/frc971/input/joystick_input.h
new file mode 100644
index 0000000..074908d
--- /dev/null
+++ b/frc971/input/joystick_input.h
@@ -0,0 +1,46 @@
+#ifndef AOS_INPUT_JOYSTICK_INPUT_H_
+#define AOS_INPUT_JOYSTICK_INPUT_H_
+
+#include <atomic>
+
+#include "aos/events/event_loop.h"
+#include "frc971/input/driver_station_data.h"
+
+namespace frc971 {
+namespace input {
+
+// A class for handling joystick packet values.
+// It will call RunIteration each time a new packet is received.
+//
+// This class automatically handles updating ::aos::joystick_state and logging
+// (at INFO) button edges.
+class JoystickInput {
+ public:
+ explicit JoystickInput(::aos::EventLoop *event_loop)
+ : event_loop_(event_loop) {
+ event_loop_->MakeWatcher(
+ "/aos", [this](const ::aos::JoystickState &joystick_state) {
+ this->HandleData(&joystick_state);
+ });
+ event_loop->SetRuntimeRealtimePriority(28);
+ }
+
+ protected:
+ int mode() const { return mode_; }
+
+ private:
+ void HandleData(const ::aos::JoystickState *joystick_state);
+
+ // Subclasses should do whatever they want with data here.
+ virtual void RunIteration(const driver_station::Data &data) = 0;
+
+ ::aos::EventLoop *event_loop_;
+ driver_station::Data data_;
+
+ int mode_;
+};
+
+} // namespace input
+} // namespace frc971
+
+#endif // AOS_INPUT_JOYSTICK_INPUT_H_