From 45f3b761030d56806b4eaa83d91fa6770232b763 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 4 Dec 2014 14:21:33 -0500 Subject: [PATCH] Fix off-by-one in button checking (fixes artf3861) Change-Id: Ic3c33bf08417fef9c7432a19a419534b76cb8597 --- wpilibc/wpilibC++Devices/src/DriverStation.cpp | 2 +- .../src/main/java/edu/wpi/first/wpilibj/DriverStation.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibc/wpilibC++Devices/src/DriverStation.cpp b/wpilibc/wpilibC++Devices/src/DriverStation.cpp index a73a81ebe8..c25ecd8052 100644 --- a/wpilibc/wpilibC++Devices/src/DriverStation.cpp +++ b/wpilibc/wpilibC++Devices/src/DriverStation.cpp @@ -224,7 +224,7 @@ bool DriverStation::GetStickButton(uint32_t stick, uint8_t button) } HALJoystickButtons joystickButtons; HALGetJoystickButtons(stick, &joystickButtons); - if(button >= joystickButtons.count) + if(button > joystickButtons.count) { ReportJoystickUnpluggedError("WARNING: Joystick Button missing, check if all controllers are plugged in\n"); return false; diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index 9c639b0a04..9e8cb7f240 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -244,7 +244,7 @@ public class DriverStation implements RobotState.Interface { int buttons = FRCNetworkCommunicationsLibrary.HALGetJoystickButtons((byte)stick, countBuffer); byte count = 0; count = countBuffer.get(); - if(button >= count) { + if(button > count) { reportJoystickUnpluggedError("WARNING: Joystick Button " + button + " on port " + stick + " not available, check if controller is plugged in\n"); return false; }