[hal,wpilib] Add Touchpad support (#8401)

This commit is contained in:
Thad House
2025-11-21 13:57:11 -08:00
committed by GitHub
parent 8546d301e3
commit 32fc543dc8
34 changed files with 1319 additions and 437 deletions

View File

@@ -710,6 +710,38 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setJoystickButtonsA
HALSIM_SetJoystickButtonsAvailable(stick, available);
}
/*
* Class: org_wpilib_hardware_hal_simulation_DriverStationDataJNI
* Method: setTouchpadCounts
* Signature: (II[I)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setTouchpadCounts
(JNIEnv* env, jclass, jint stick, jint touchpadCount, jintArray fingerCounts)
{
JSpan<const jint> jArrayRef(env, fingerCounts);
uint8_t fingerCountsLocal[2];
size_t toCopy = (std::min)(jArrayRef.size(), static_cast<size_t>(2));
for (size_t i = 0; i < toCopy; ++i) {
fingerCountsLocal[i] = static_cast<uint8_t>(jArrayRef[i]);
}
HALSIM_SetJoystickTouchpadCounts(stick, touchpadCount, fingerCountsLocal);
}
/*
* Class: org_wpilib_hardware_hal_simulation_DriverStationDataJNI
* Method: setTouchpadFinger
* Signature: (IIIZFF)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setTouchpadFinger
(JNIEnv*, jclass, jint stick, jint touchpadIndex, jint fingerIndex,
jboolean down, jfloat x, jfloat y)
{
HALSIM_SetJoystickTouchpadFinger(stick, touchpadIndex, fingerIndex, down, x,
y);
}
/*
* Class: org_wpilib_hardware_hal_simulation_DriverStationDataJNI
* Method: setJoystickIsGamepad