Get rid of //aos/prime
It's not a useful distinction to make any more.
Change-Id: Ieacfe8af4502108b8a5949234a1a3b6a6dd7b7e9
diff --git a/aos/input/BUILD b/aos/input/BUILD
new file mode 100644
index 0000000..30cb053
--- /dev/null
+++ b/aos/input/BUILD
@@ -0,0 +1,18 @@
+package(default_visibility = ['//visibility:public'])
+
+cc_library(
+ name = 'joystick_input',
+ srcs = [
+ 'joystick_input.cc',
+ ],
+ hdrs = [
+ 'joystick_input.h',
+ ],
+ deps = [
+ '//aos/common/input:driver_station_data',
+ '//aos/common/messages:robot_state',
+ '//aos/common/network:socket',
+ '//aos/common/logging',
+ '//aos/common/logging:queue_logging',
+ ],
+)
diff --git a/aos/input/joystick_input.cc b/aos/input/joystick_input.cc
new file mode 100644
index 0000000..a6ada96
--- /dev/null
+++ b/aos/input/joystick_input.cc
@@ -0,0 +1,66 @@
+#include "aos/input/joystick_input.h"
+
+#include <string.h>
+
+#include "aos/common/messages/robot_state.q.h"
+#include "aos/common/logging/logging.h"
+#include "aos/common/logging/queue_logging.h"
+
+namespace aos {
+namespace input {
+
+void JoystickInput::Run() {
+ driver_station::Data data;
+ while (true) {
+ joystick_state.FetchAnother();
+
+ data.Update(*joystick_state);
+
+ {
+ using driver_station::JoystickFeature;
+ using driver_station::ButtonLocation;
+ for (int joystick = 1; joystick <= JoystickFeature::kJoysticks;
+ ++joystick) {
+ for (int button = 1; button <= ButtonLocation::kButtons; ++button) {
+ ButtonLocation location(joystick, button);
+ if (data.PosEdge(location)) {
+ LOG(INFO, "PosEdge(%d, %d)\n", joystick, button);
+ }
+ if (data.NegEdge(location)) {
+ LOG(INFO, "NegEdge(%d, %d)\n", joystick, button);
+ }
+ }
+ if (data.GetPOV(joystick) != data.GetOldPOV(joystick)) {
+ LOG(INFO, "POV %d %d->%d\n", joystick, data.GetOldPOV(joystick),
+ data.GetPOV(joystick));
+ }
+ }
+ }
+ {
+ using driver_station::ControlBit;
+ if (data.PosEdge(ControlBit::kFmsAttached)) {
+ LOG(INFO, "PosEdge(kFmsAttached)\n");
+ }
+ if (data.NegEdge(ControlBit::kFmsAttached)) {
+ LOG(INFO, "NegEdge(kFmsAttached)\n");
+ }
+ if (data.PosEdge(ControlBit::kAutonomous)) {
+ LOG(INFO, "PosEdge(kAutonomous)\n");
+ }
+ if (data.NegEdge(ControlBit::kAutonomous)) {
+ LOG(INFO, "NegEdge(kAutonomous)\n");
+ }
+ if (data.PosEdge(ControlBit::kEnabled)) {
+ LOG(INFO, "PosEdge(kEnabled)\n");
+ }
+ if (data.NegEdge(ControlBit::kEnabled)) {
+ LOG(INFO, "NegEdge(kEnabled)\n");
+ }
+ }
+
+ RunIteration(data);
+ }
+}
+
+} // namespace input
+} // namespace aos
diff --git a/aos/input/joystick_input.h b/aos/input/joystick_input.h
new file mode 100644
index 0000000..ec8b52a
--- /dev/null
+++ b/aos/input/joystick_input.h
@@ -0,0 +1,32 @@
+#ifndef AOS_INPUT_JOYSTICK_INPUT_H_
+#define AOS_INPUT_JOYSTICK_INPUT_H_
+
+#include "aos/common/input/driver_station_data.h"
+
+namespace aos {
+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:
+ void Run();
+
+ private:
+ // Subclasses should do whatever they want with data here.
+ virtual void RunIteration(const driver_station::Data &data) = 0;
+};
+
+// Class which will proxy joystick information from UDP packets to the queues.
+class JoystickProxy {
+ public:
+ void Run();
+};
+
+} // namespace input
+} // namespace aos
+
+#endif // AOS_INPUT_JOYSTICK_INPUT_H_