Split joystick_reader into hardware shim + application.
Change-Id: If31e6dd7ece547a2952ec21e2f4bc745ee6f9d84
diff --git a/aos/common/input/driver_station_data.cc b/aos/common/input/driver_station_data.cc
index 18b3403..d97601a 100644
--- a/aos/common/input/driver_station_data.cc
+++ b/aos/common/input/driver_station_data.cc
@@ -6,7 +6,7 @@
Data::Data() : current_values_(), old_values_() {}
-void Data::Update(const NetworkRobotJoysticks &new_values) {
+void Data::Update(const RobotState &new_values) {
old_values_ = current_values_;
current_values_ = new_values;
}
@@ -14,22 +14,22 @@
namespace {
bool GetButton(const ButtonLocation location,
- const NetworkRobotJoysticks &values) {
+ const RobotState &values) {
return values.joysticks[location.joystick() - 1].buttons &
(1 << (location.number() - 1));
}
bool GetControlBitValue(const ControlBit bit,
- const NetworkRobotJoysticks &values) {
+ const RobotState &values) {
switch (bit) {
case ControlBit::kTestMode:
- return values.control.test_mode();
+ return values.test_mode;
case ControlBit::kFmsAttached:
- return values.control.fms_attached();
+ return values.fms_attached;
case ControlBit::kAutonomous:
- return values.control.autonomous();
+ return values.autonomous;
case ControlBit::kEnabled:
- return values.control.enabled();
+ return values.enabled;
default:
__builtin_unreachable();
}
@@ -66,9 +66,7 @@
}
float Data::GetAxis(JoystickAxis axis) const {
- // TODO(brians): check this math against what our joysticks report as their
- // logical minimums and maximums
- return current_values_.joysticks[axis.joystick() - 1].axes[axis.number() - 1] / 127.0;
+ return current_values_.joysticks[axis.joystick() - 1].axis[axis.number() - 1];
}
} // namespace driver_station
diff --git a/aos/common/input/driver_station_data.h b/aos/common/input/driver_station_data.h
index 4bef0b6..a8a9ddf 100644
--- a/aos/common/input/driver_station_data.h
+++ b/aos/common/input/driver_station_data.h
@@ -6,7 +6,7 @@
#include <memory>
-#include "aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h"
+#include "aos/common/messages/robot_state.q.h"
namespace aos {
namespace input {
@@ -20,8 +20,8 @@
: joystick_(joystick), number_(number) {}
// How many joysticks there are.
- static const int kJoysticks = sizeof(NetworkRobotJoysticks::joysticks) /
- sizeof(NetworkRobotJoysticks::joysticks[0]);
+ static const int kJoysticks = sizeof(RobotState::joysticks) /
+ sizeof(RobotState::joysticks[0]);
// Which joystick number this is (1-based).
int joystick() const { return joystick_; }
@@ -59,8 +59,8 @@
: JoystickFeature(joystick, number) {}
// How many axes there are available on each joystick.
- static const int kAxes = sizeof(NetworkRobotJoysticks::Joystick::axes) /
- sizeof(NetworkRobotJoysticks::Joystick::axes[0]);
+ static const int kAxes = sizeof(Joystick::axis) /
+ sizeof(Joystick::axis[0]);
};
class Data {
@@ -70,7 +70,7 @@
Data();
// Updates the current information with a new set of values.
- void Update(const NetworkRobotJoysticks &new_values);
+ void Update(const RobotState &new_values);
bool IsPressed(ButtonLocation location) const;
bool PosEdge(ButtonLocation location) const;
@@ -84,7 +84,7 @@
float GetAxis(JoystickAxis axis) const;
private:
- NetworkRobotJoysticks current_values_, old_values_;
+ RobotState current_values_, old_values_;
};
} // namespace driver_station
diff --git a/aos/common/input/input.gyp b/aos/common/input/input.gyp
index e5c964c..7d5af30 100644
--- a/aos/common/input/input.gyp
+++ b/aos/common/input/input.gyp
@@ -8,9 +8,11 @@
],
'dependencies': [
'<(EXTERNALS):WPILib-NetworkRobotValues',
+ '<(AOS)/common/messages/messages.gyp:robot_state',
],
'export_dependent_settings': [
'<(EXTERNALS):WPILib-NetworkRobotValues',
+ '<(AOS)/common/messages/messages.gyp:robot_state',
],
},
],