Check if Joystick Button exists when requested and pass 0 and warn if it doesn't

Change-Id: I2194859ef8b263f1a20aba52ec154fb0a1fc8078
This commit is contained in:
Kevin O'Connor
2014-11-21 11:32:08 -05:00
parent 14a1e6ae8e
commit 7e5ed03d28
9 changed files with 41 additions and 26 deletions

View File

@@ -324,14 +324,17 @@ JNIEXPORT jshortArray JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetwor
* Signature: (B)S
*/
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickButtons
(JNIEnv *, jclass, jbyte joystickNum)
(JNIEnv * env, jclass, jbyte joystickNum, jobject count)
{
HALJoystickButtons buttons;
uint8_t count;
HALGetJoystickButtons(joystickNum, &buttons, &count);
return buttons;
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickButtons";
HALJoystickButtons joystickButtons;
HALGetJoystickButtons(joystickNum, &joystickButtons);
jbyte *countPtr = (jbyte*)env->GetDirectBufferAddress(count);
NETCOMM_LOG(logDEBUG) << "Buttons = " << joystickButtons.buttons;
NETCOMM_LOG(logDEBUG) << "Count = " << (jint)joystickButtons.count;
*countPtr = joystickButtons.count;
NETCOMM_LOG(logDEBUG) << "CountBuffer = " << (jint)*countPtr;
return joystickButtons.buttons;
}
/*