Changes HAL to return -1 to 1 for joysticks (#35)

First part of the HAL changes. Returns -1 to 1 for joysticks instead of
-128 to 127. Implemented by replacing the old structure with a new
structure that uses floats instead of shorts.
This commit is contained in:
Thad House
2016-05-21 01:42:16 -07:00
committed by Peter Johnson
parent a4f0c4fbe0
commit 54092378e9
6 changed files with 34 additions and 18 deletions

View File

@@ -146,7 +146,7 @@ Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeH
*/
JNIEXPORT jbyte JNICALL
Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxes(
JNIEnv * env, jclass, jbyte joystickNum, jshortArray axesArray) {
JNIEnv * env, jclass, jbyte joystickNum, jfloatArray axesArray) {
NETCOMM_LOG(logDEBUG) << "Calling HALJoystickAxes";
HALJoystickAxes axes;
HALGetJoystickAxes(joystickNum, &axes);
@@ -157,7 +157,7 @@ Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJ
ThrowIllegalArgumentException(env, "Native array size larger then passed in java array size");
}
env->SetShortArrayRegion(axesArray, 0, axes.count, axes.axes);
env->SetFloatArrayRegion(axesArray, 0, axes.count, axes.axes);
return axes.count;
}