Make redundant joysticks work in auto
Change-Id: Icae39c7f0581ea7027d83a3591e21fc83d7a5f48
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/input/redundant_joystick_data.cc b/frc971/input/redundant_joystick_data.cc
index 3274856..a25e6c3 100644
--- a/frc971/input/redundant_joystick_data.cc
+++ b/frc971/input/redundant_joystick_data.cc
@@ -9,7 +9,7 @@
RedundantData::RedundantData(const Data &data) : joystick_map_(), data_(data) {
// Start with a naive map.
for (int i = 0; i < JoystickFeature::kJoysticks; i++) {
- joystick_map_.at(i) = i;
+ joystick_map_.at(i) = -1;
}
for (int i = 0; i < JoystickFeature::kJoysticks; i++) {
@@ -32,6 +32,9 @@
};
int RedundantData::MapRedundantJoystick(int joystick) const {
+ if (joystick < 0 || joystick >= static_cast<int>(joystick_map_.size())) {
+ return -1;
+ }
return joystick_map_.at(joystick);
}