add logging for POV presses
Change-Id: Id21727ce9f76a9b9ef93e27131bec9b242843d62
diff --git a/aos/common/input/driver_station_data.cc b/aos/common/input/driver_station_data.cc
index 00a126e..2df98be 100644
--- a/aos/common/input/driver_station_data.cc
+++ b/aos/common/input/driver_station_data.cc
@@ -19,7 +19,7 @@
(1 << (location.number() - 1));
}
-bool GetPOV(const POVLocation location, const JoystickState &values) {
+bool DoGetPOV(const POVLocation location, const JoystickState &values) {
return values.joysticks[location.joystick() - 1].pov == location.number();
}
@@ -56,15 +56,25 @@
}
bool Data::IsPressed(const POVLocation location) const {
- return GetPOV(location, current_values_);
+ return DoGetPOV(location, current_values_);
}
bool Data::PosEdge(const POVLocation location) const {
- return !GetPOV(location, old_values_) && GetPOV(location, current_values_);
+ return !DoGetPOV(location, old_values_) &&
+ DoGetPOV(location, current_values_);
}
bool Data::NegEdge(const POVLocation location) const {
- return GetPOV(location, old_values_) && !GetPOV(location, current_values_);
+ return DoGetPOV(location, old_values_) &&
+ !DoGetPOV(location, current_values_);
+}
+
+int32_t Data::GetPOV(int joystick) const {
+ return current_values_.joysticks[joystick - 1].pov;
+}
+
+int32_t Data::GetOldPOV(int joystick) const {
+ return old_values_.joysticks[joystick - 1].pov;
}
bool Data::GetControlBit(const ControlBit bit) const {
diff --git a/aos/common/input/driver_station_data.h b/aos/common/input/driver_station_data.h
index 41d54f5..507ad61 100644
--- a/aos/common/input/driver_station_data.h
+++ b/aos/common/input/driver_station_data.h
@@ -85,6 +85,10 @@
bool PosEdge(POVLocation location) const;
bool NegEdge(POVLocation location) const;
+ // Returns the current and previous "values" for the POV.
+ int32_t GetPOV(int joystick) const;
+ int32_t GetOldPOV(int joystick) const;
+
bool IsPressed(ButtonLocation location) const;
bool PosEdge(ButtonLocation location) const;
bool NegEdge(ButtonLocation location) const;
diff --git a/aos/prime/input/joystick_input.cc b/aos/prime/input/joystick_input.cc
index 3975930..cf9e7c0 100644
--- a/aos/prime/input/joystick_input.cc
+++ b/aos/prime/input/joystick_input.cc
@@ -30,6 +30,10 @@
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));
+ }
}
}
{