mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[hal,wpilib] Use new DS available API from mrccomm (#8302)
Instead of just having a max count for joystick values, there's an available mask of values. This is because in the future we're expecting there to be holes in the list of available buttons and axes. This updates everything to support that scenario. Also, Joystick buttons, axes, and POVs all now start at 0 instead of 1.
This commit is contained in:
@@ -427,11 +427,12 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchTime
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickAxes
|
||||
* Signature: (B[F)V
|
||||
* Signature: (B[FS)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxes
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jfloatArray axesArray)
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jfloatArray axesArray,
|
||||
jshort availableAxes)
|
||||
{
|
||||
HAL_JoystickAxes axes;
|
||||
{
|
||||
@@ -440,7 +441,7 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxes
|
||||
auto arraySize = arrayRef.size();
|
||||
int maxCount =
|
||||
arraySize < HAL_kMaxJoystickAxes ? arraySize : HAL_kMaxJoystickAxes;
|
||||
axes.count = maxCount;
|
||||
axes.available = availableAxes;
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
axes.axes[i] = arrayRef[i];
|
||||
}
|
||||
@@ -452,11 +453,12 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxes
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickPOVs
|
||||
* Signature: (B[B)V
|
||||
* Signature: (B[BS)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVs
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jbyteArray povsArray)
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jbyteArray povsArray,
|
||||
jshort availablePovs)
|
||||
{
|
||||
HAL_JoystickPOVs povs;
|
||||
{
|
||||
@@ -465,7 +467,7 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVs
|
||||
auto arraySize = arrayRef.size();
|
||||
int maxCount =
|
||||
arraySize < HAL_kMaxJoystickPOVs ? arraySize : HAL_kMaxJoystickPOVs;
|
||||
povs.count = maxCount;
|
||||
povs.available = availablePovs;
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
povs.povs[i] = static_cast<HAL_JoystickPOV>(arrayRef[i]);
|
||||
}
|
||||
@@ -477,17 +479,15 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVs
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickButtons
|
||||
* Signature: (BII)V
|
||||
* Signature: (BJJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtons
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jint buttons, jint count)
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jlong buttons,
|
||||
jlong availableButtons)
|
||||
{
|
||||
if (count > 32) {
|
||||
count = 32;
|
||||
}
|
||||
HAL_JoystickButtons joystickButtons;
|
||||
joystickButtons.count = count;
|
||||
joystickButtons.available = availableButtons;
|
||||
joystickButtons.buttons = buttons;
|
||||
HALSIM_SetJoystickButtons(joystickNum, &joystickButtons);
|
||||
}
|
||||
@@ -654,49 +654,49 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOV
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickButtonsValue
|
||||
* Signature: (II)V
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtonsValue
|
||||
(JNIEnv*, jclass, jint stick, jint buttons)
|
||||
(JNIEnv*, jclass, jint stick, jlong buttons)
|
||||
{
|
||||
HALSIM_SetJoystickButtonsValue(stick, buttons);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickAxisCount
|
||||
* Method: setJoystickAxesAvailable
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxisCount
|
||||
(JNIEnv*, jclass, jint stick, jint count)
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxesAvailable
|
||||
(JNIEnv*, jclass, jint stick, jint available)
|
||||
{
|
||||
HALSIM_SetJoystickAxisCount(stick, count);
|
||||
HALSIM_SetJoystickAxesAvailable(stick, available);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickPOVCount
|
||||
* Method: setJoystickPOVsAvailable
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVCount
|
||||
(JNIEnv*, jclass, jint stick, jint count)
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVsAvailable
|
||||
(JNIEnv*, jclass, jint stick, jint available)
|
||||
{
|
||||
HALSIM_SetJoystickPOVCount(stick, count);
|
||||
HALSIM_SetJoystickPOVsAvailable(stick, available);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickButtonCount
|
||||
* Signature: (II)V
|
||||
* Method: setJoystickButtonsAvailable
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtonCount
|
||||
(JNIEnv*, jclass, jint stick, jint count)
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtonsAvailable
|
||||
(JNIEnv*, jclass, jint stick, jlong available)
|
||||
{
|
||||
HALSIM_SetJoystickButtonCount(stick, count);
|
||||
HALSIM_SetJoystickButtonsAvailable(stick, available);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -737,18 +737,6 @@ Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickName
|
||||
HALSIM_SetJoystickName(stick, &str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickAxisType
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxisType
|
||||
(JNIEnv*, jclass, jint stick, jint axis, jint type)
|
||||
{
|
||||
HALSIM_SetJoystickAxisType(stick, axis, type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setGameSpecificMessage
|
||||
|
||||
Reference in New Issue
Block a user