2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
2023-09-17 20:00:16 -07:00
|
|
|
#include <wpi/StringExtras.h>
|
2018-07-22 22:43:24 -04:00
|
|
|
#include <wpi/jni_util.h>
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
#include "CallbackStore.h"
|
2020-06-27 22:11:24 -07:00
|
|
|
#include "edu_wpi_first_hal_simulation_DriverStationDataJNI.h"
|
|
|
|
|
#include "hal/simulation/DriverStationData.h"
|
|
|
|
|
#include "hal/simulation/MockHooks.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-06-26 17:12:55 -07:00
|
|
|
using namespace hal;
|
2018-07-22 22:43:24 -04:00
|
|
|
using namespace wpi::java;
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
extern "C" {
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerEnabledCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerEnabledCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationEnabledCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelEnabledCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelEnabledCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(env, handle,
|
|
|
|
|
&HALSIM_CancelDriverStationEnabledCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getEnabled
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getEnabled
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setEnabled
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setEnabled
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationEnabled(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerAutonomousCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerAutonomousCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationAutonomousCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelAutonomousCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelAutonomousCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(
|
|
|
|
|
env, handle, &HALSIM_CancelDriverStationAutonomousCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getAutonomous
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getAutonomous
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationAutonomous();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setAutonomous
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setAutonomous
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationAutonomous(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerTestCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerTestCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify, &HALSIM_RegisterDriverStationTestCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelTestCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelTestCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(env, handle,
|
|
|
|
|
&HALSIM_CancelDriverStationTestCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getTest
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getTest
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationTest();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setTest
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setTest
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationTest(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerEStopCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerEStopCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify, &HALSIM_RegisterDriverStationEStopCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelEStopCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelEStopCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(env, handle,
|
|
|
|
|
&HALSIM_CancelDriverStationEStopCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getEStop
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getEStop
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationEStop();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setEStop
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setEStop
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationEStop(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerFmsAttachedCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerFmsAttachedCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationFmsAttachedCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelFmsAttachedCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelFmsAttachedCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(
|
|
|
|
|
env, handle, &HALSIM_CancelDriverStationFmsAttachedCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getFmsAttached
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getFmsAttached
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationFmsAttached();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setFmsAttached
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setFmsAttached
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationFmsAttached(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: registerDsAttachedCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerDsAttachedCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationDsAttachedCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: cancelDsAttachedCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelDsAttachedCallback
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return sim::FreeCallbackNoIndex(
|
|
|
|
|
env, handle, &HALSIM_CancelDriverStationDsAttachedCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getDsAttached
|
|
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getDsAttached
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetDriverStationDsAttached();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setDsAttached
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setDsAttached
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass, jboolean value)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_SetDriverStationDsAttached(value);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: registerAllianceStationIdCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerAllianceStationIdCallback
|
|
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
|
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationAllianceStationIdCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: cancelAllianceStationIdCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelAllianceStationIdCallback
|
|
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
|
|
|
|
return sim::FreeCallbackNoIndex(
|
|
|
|
|
env, handle, &HALSIM_CancelDriverStationAllianceStationIdCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: getAllianceStationId
|
|
|
|
|
* Signature: ()I
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getAllianceStationId
|
|
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
|
|
|
|
return HALSIM_GetDriverStationAllianceStationId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setAllianceStationId
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setAllianceStationId
|
|
|
|
|
(JNIEnv*, jclass, jint value)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetDriverStationAllianceStationId(
|
|
|
|
|
static_cast<HAL_AllianceStationID>(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: registerMatchTimeCallback
|
|
|
|
|
* Signature: (Ljava/lang/Object;Z)I
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerMatchTimeCallback
|
|
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
|
|
|
|
return sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
&HALSIM_RegisterDriverStationMatchTimeCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: cancelMatchTimeCallback
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelMatchTimeCallback
|
|
|
|
|
(JNIEnv* env, jclass, jint handle)
|
|
|
|
|
{
|
|
|
|
|
return sim::FreeCallbackNoIndex(env, handle,
|
|
|
|
|
&HALSIM_CancelDriverStationMatchTimeCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: getMatchTime
|
|
|
|
|
* Signature: ()D
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jdouble JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getMatchTime
|
|
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
|
|
|
|
return HALSIM_GetDriverStationMatchTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setMatchTime
|
|
|
|
|
* Signature: (D)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchTime
|
|
|
|
|
(JNIEnv*, jclass, jdouble value)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetDriverStationMatchTime(value);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: setJoystickAxes
|
|
|
|
|
* Signature: (B[F)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxes
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jbyte joystickNum, jfloatArray axesArray)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HAL_JoystickAxes axes;
|
|
|
|
|
{
|
2023-08-24 00:02:56 -07:00
|
|
|
JSpan<const jfloat> jArrayRef(env, axesArray);
|
2018-05-11 12:38:23 -07:00
|
|
|
auto arrayRef = jArrayRef.array();
|
|
|
|
|
auto arraySize = arrayRef.size();
|
|
|
|
|
int maxCount =
|
|
|
|
|
arraySize < HAL_kMaxJoystickAxes ? arraySize : HAL_kMaxJoystickAxes;
|
|
|
|
|
axes.count = maxCount;
|
|
|
|
|
for (int i = 0; i < maxCount; i++) {
|
|
|
|
|
axes.axes[i] = arrayRef[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
HALSIM_SetJoystickAxes(joystickNum, &axes);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: setJoystickPOVs
|
2025-05-16 22:15:14 -07:00
|
|
|
* Signature: (B[B)V
|
2018-05-11 12:38:23 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVs
|
2025-05-16 22:15:14 -07:00
|
|
|
(JNIEnv* env, jclass, jbyte joystickNum, jbyteArray povsArray)
|
2018-05-13 17:09:56 -07:00
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HAL_JoystickPOVs povs;
|
|
|
|
|
{
|
2025-05-16 22:15:14 -07:00
|
|
|
JSpan<const jbyte> jArrayRef(env, povsArray);
|
2018-05-11 12:38:23 -07:00
|
|
|
auto arrayRef = jArrayRef.array();
|
|
|
|
|
auto arraySize = arrayRef.size();
|
|
|
|
|
int maxCount =
|
|
|
|
|
arraySize < HAL_kMaxJoystickPOVs ? arraySize : HAL_kMaxJoystickPOVs;
|
|
|
|
|
povs.count = maxCount;
|
|
|
|
|
for (int i = 0; i < maxCount; i++) {
|
|
|
|
|
povs.povs[i] = arrayRef[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
HALSIM_SetJoystickPOVs(joystickNum, &povs);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: setJoystickButtons
|
|
|
|
|
* Signature: (BII)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtons
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jbyte joystickNum, jint buttons, jint count)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
if (count > 32) {
|
|
|
|
|
count = 32;
|
|
|
|
|
}
|
|
|
|
|
HAL_JoystickButtons joystickButtons;
|
|
|
|
|
joystickButtons.count = count;
|
|
|
|
|
joystickButtons.buttons = buttons;
|
|
|
|
|
HALSIM_SetJoystickButtons(joystickNum, &joystickButtons);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: getJoystickOutputs
|
|
|
|
|
* Signature: (I)J
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jlong JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getJoystickOutputs
|
|
|
|
|
(JNIEnv* env, jclass, jint stick)
|
|
|
|
|
{
|
|
|
|
|
int64_t outputs = 0;
|
|
|
|
|
int32_t leftRumble;
|
|
|
|
|
int32_t rightRumble;
|
|
|
|
|
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
|
|
|
|
|
return outputs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: getJoystickRumble
|
|
|
|
|
* Signature: (II)I
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jint JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getJoystickRumble
|
|
|
|
|
(JNIEnv* env, jclass, jint stick, jint rumbleNum)
|
|
|
|
|
{
|
|
|
|
|
int64_t outputs;
|
|
|
|
|
int32_t leftRumble = 0;
|
|
|
|
|
int32_t rightRumble = 0;
|
|
|
|
|
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
|
|
|
|
|
return rumbleNum == 0 ? leftRumble : rightRumble;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: setMatchInfo
|
2018-07-22 22:43:24 -04:00
|
|
|
* Signature: (Ljava/lang/String;Ljava/lang/String;III)V
|
2018-05-11 12:38:23 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchInfo
|
2018-07-22 22:43:24 -04:00
|
|
|
(JNIEnv* env, jclass, jstring eventName, jstring gameSpecificMessage,
|
|
|
|
|
jint matchNumber, jint replayNumber, jint matchType)
|
|
|
|
|
{
|
|
|
|
|
JStringRef eventNameRef{env, eventName};
|
|
|
|
|
JStringRef gameSpecificMessageRef{env, gameSpecificMessage};
|
|
|
|
|
|
|
|
|
|
HAL_MatchInfo halMatchInfo;
|
2023-09-17 20:00:16 -07:00
|
|
|
wpi::format_to_n_c_str(halMatchInfo.eventName, sizeof(halMatchInfo.eventName),
|
|
|
|
|
"{}", eventNameRef.str());
|
|
|
|
|
wpi::format_to_n_c_str(
|
|
|
|
|
reinterpret_cast<char*>(halMatchInfo.gameSpecificMessage),
|
|
|
|
|
sizeof(halMatchInfo.gameSpecificMessage), "{}",
|
|
|
|
|
gameSpecificMessageRef.str());
|
2018-07-22 22:43:24 -04:00
|
|
|
halMatchInfo.gameSpecificMessageSize = gameSpecificMessageRef.size();
|
|
|
|
|
halMatchInfo.matchType = (HAL_MatchType)matchType;
|
|
|
|
|
halMatchInfo.matchNumber = matchNumber;
|
|
|
|
|
halMatchInfo.replayNumber = replayNumber;
|
|
|
|
|
HALSIM_SetMatchInfo(&halMatchInfo);
|
|
|
|
|
}
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: registerAllCallbacks
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (Ljava/lang/Object;Z)V
|
2018-05-11 12:38:23 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerAllCallbacks
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
sim::AllocateCallbackNoIndex(
|
|
|
|
|
env, callback, initialNotify,
|
|
|
|
|
[](HAL_NotifyCallback cb, void* param, HAL_Bool in) {
|
|
|
|
|
HALSIM_RegisterDriverStationAllCallbacks(cb, param, in);
|
|
|
|
|
return 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-11 12:38:23 -07:00
|
|
|
* Method: notifyNewData
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_notifyNewData
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_NotifyDriverStationNewData();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-27 19:11:26 -08:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2019-12-27 19:11:26 -08:00
|
|
|
* Method: setSendError
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setSendError
|
2019-12-27 19:11:26 -08:00
|
|
|
(JNIEnv*, jclass, jboolean shouldSend)
|
|
|
|
|
{
|
|
|
|
|
if (shouldSend) {
|
|
|
|
|
HALSIM_SetSendError(nullptr);
|
|
|
|
|
} else {
|
|
|
|
|
HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
|
|
|
|
|
HAL_Bool isLVCode, const char* details,
|
|
|
|
|
const char* location, const char* callStack,
|
2020-02-18 20:44:40 -08:00
|
|
|
HAL_Bool printMsg) { return 0; });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2020-02-18 20:44:40 -08:00
|
|
|
* Method: setSendConsoleLine
|
|
|
|
|
* Signature: (Z)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setSendConsoleLine
|
2020-02-18 20:44:40 -08:00
|
|
|
(JNIEnv*, jclass, jboolean shouldSend)
|
|
|
|
|
{
|
|
|
|
|
if (shouldSend) {
|
|
|
|
|
HALSIM_SetSendConsoleLine(nullptr);
|
|
|
|
|
} else {
|
|
|
|
|
HALSIM_SetSendConsoleLine([](const char* line) { return 0; });
|
2019-12-27 19:11:26 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickButton
|
|
|
|
|
* Signature: (IIZ)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButton
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint button, jboolean state)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickButton(stick, button, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickAxis
|
|
|
|
|
* Signature: (IID)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxis
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint axis, jdouble value)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickAxis(stick, axis, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickPOV
|
|
|
|
|
* Signature: (III)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOV
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint pov, jint value)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickPOV(stick, pov, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickButtonsValue
|
|
|
|
|
* Signature: (II)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtonsValue
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint buttons)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickButtonsValue(stick, buttons);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickAxisCount
|
|
|
|
|
* Signature: (II)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxisCount
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint count)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickAxisCount(stick, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickPOVCount
|
|
|
|
|
* Signature: (II)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVCount
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint count)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickPOVCount(stick, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickButtonCount
|
|
|
|
|
* Signature: (II)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtonCount
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint count)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickButtonCount(stick, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2025-05-16 22:15:14 -07:00
|
|
|
* Method: setJoystickIsGamepad
|
2020-07-15 00:33:57 -07:00
|
|
|
* Signature: (IZ)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2025-05-16 22:15:14 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickIsGamepad
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jboolean isGamepad)
|
2020-07-15 00:33:57 -07:00
|
|
|
{
|
2025-05-16 22:15:14 -07:00
|
|
|
HALSIM_SetJoystickIsGamepad(stick, isGamepad);
|
2020-07-15 00:33:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickType
|
|
|
|
|
* Signature: (II)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickType
|
|
|
|
|
(JNIEnv*, jclass, jint stick, jint type)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetJoystickType(stick, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setJoystickName
|
|
|
|
|
* Signature: (ILjava/lang/String;)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickName
|
|
|
|
|
(JNIEnv* env, jclass, jint stick, jstring name)
|
|
|
|
|
{
|
2022-12-09 16:10:23 -05:00
|
|
|
JStringRef nameJString{env, name};
|
Change C APIs to a unified string implementation (#6299)
Currently in the entire C API of WPILib we have ~8 different ways of handling strings. The C API actually isn't built for pure C callers (We don't actually have any of those). Instead, they're built for interop between languages like LabVIEW and C# which can talk to C API's directly.
For output parameters, the choice was fairly obvious. An output struct containing a const string pointer and a length makes the most sense. Its easy to use these from most other languages, and doesn't require special null termination handling. Freeing these is also easy, as if you ever receive one of these string structures, theres just a single function call to free it.
Input parameters are a bit more complex. To be used from pure C, and from LabVIEW, a null terminated string is the best in most cases. However, null terminated strings in general have a lot of downsides. Additionally, from LabVIEW there are other considerations around encoding that having a wrapper struct helps make a bit easier. From a language like C#, a wrapper struct is by far the easiest, as custom marshalling can make it trivial to marshal both UTF8 and UTF16 strings down.
The final consideration is its nice to have an identical concept for both input and output. It makes the rules fairly easy to understand.
WPILib will not have any APIs that manipulate a string allocated externally. This means WPI_String can be const, as across the boundary it is always const.
If a WPILib API takes a const WPI_String*, WPILib will not manipulate or attempt to free that string, and that string is treated as an input. It is up to the caller to handle that memory, WPILib will never hold onto that memory longer than the call.
If a WPILib API takes a WPI_String*, that string is an output. WPILib will allocate that API with WPI_AllocateString(), fill in the string, and return to the caller. When the caller is done with the string, they must free it with WPI_FreeString().
If an output struct contains a WPI_String member, that member is considered read only, and should not be explicitly freed. The caller should call the free function for that struct.
If an array of WPI_Strings are returned, each individual string is considered read only, and should not be explicitly freed. The free function for that array should be called by the caller.
If an input struct containing a WPI_String, or an input array of WPI_Strings is passed to WPILib, the individual strings will not be manipulated or freed by WPILib, and the caller owns and should free that memory.
Callbacks also follow these rules. The most common is a callback either getting passed a const WPI_String* or a struct containing a WPI_String. In both of these cases, the callback target should consider these strings read only, and not attempt to free them or manipulate them.
2024-05-13 05:35:14 -07:00
|
|
|
auto str = wpi::make_string(nameJString);
|
|
|
|
|
HALSIM_SetJoystickName(stick, &str);
|
2020-07-15 00:33:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
* Signature: (Ljava/lang/String;)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setGameSpecificMessage
|
|
|
|
|
(JNIEnv* env, jclass, jstring message)
|
|
|
|
|
{
|
2022-12-09 16:10:23 -05:00
|
|
|
JStringRef messageJString{env, message};
|
Change C APIs to a unified string implementation (#6299)
Currently in the entire C API of WPILib we have ~8 different ways of handling strings. The C API actually isn't built for pure C callers (We don't actually have any of those). Instead, they're built for interop between languages like LabVIEW and C# which can talk to C API's directly.
For output parameters, the choice was fairly obvious. An output struct containing a const string pointer and a length makes the most sense. Its easy to use these from most other languages, and doesn't require special null termination handling. Freeing these is also easy, as if you ever receive one of these string structures, theres just a single function call to free it.
Input parameters are a bit more complex. To be used from pure C, and from LabVIEW, a null terminated string is the best in most cases. However, null terminated strings in general have a lot of downsides. Additionally, from LabVIEW there are other considerations around encoding that having a wrapper struct helps make a bit easier. From a language like C#, a wrapper struct is by far the easiest, as custom marshalling can make it trivial to marshal both UTF8 and UTF16 strings down.
The final consideration is its nice to have an identical concept for both input and output. It makes the rules fairly easy to understand.
WPILib will not have any APIs that manipulate a string allocated externally. This means WPI_String can be const, as across the boundary it is always const.
If a WPILib API takes a const WPI_String*, WPILib will not manipulate or attempt to free that string, and that string is treated as an input. It is up to the caller to handle that memory, WPILib will never hold onto that memory longer than the call.
If a WPILib API takes a WPI_String*, that string is an output. WPILib will allocate that API with WPI_AllocateString(), fill in the string, and return to the caller. When the caller is done with the string, they must free it with WPI_FreeString().
If an output struct contains a WPI_String member, that member is considered read only, and should not be explicitly freed. The caller should call the free function for that struct.
If an array of WPI_Strings are returned, each individual string is considered read only, and should not be explicitly freed. The free function for that array should be called by the caller.
If an input struct containing a WPI_String, or an input array of WPI_Strings is passed to WPILib, the individual strings will not be manipulated or freed by WPILib, and the caller owns and should free that memory.
Callbacks also follow these rules. The most common is a callback either getting passed a const WPI_String* or a struct containing a WPI_String. In both of these cases, the callback target should consider these strings read only, and not attempt to free them or manipulate them.
2024-05-13 05:35:14 -07:00
|
|
|
auto str = wpi::make_string(messageJString);
|
|
|
|
|
HALSIM_SetGameSpecificMessage(&str);
|
2020-07-15 00:33:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setEventName
|
|
|
|
|
* Signature: (Ljava/lang/String;)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setEventName
|
|
|
|
|
(JNIEnv* env, jclass, jstring name)
|
|
|
|
|
{
|
2022-12-09 16:10:23 -05:00
|
|
|
JStringRef nameJString{env, name};
|
Change C APIs to a unified string implementation (#6299)
Currently in the entire C API of WPILib we have ~8 different ways of handling strings. The C API actually isn't built for pure C callers (We don't actually have any of those). Instead, they're built for interop between languages like LabVIEW and C# which can talk to C API's directly.
For output parameters, the choice was fairly obvious. An output struct containing a const string pointer and a length makes the most sense. Its easy to use these from most other languages, and doesn't require special null termination handling. Freeing these is also easy, as if you ever receive one of these string structures, theres just a single function call to free it.
Input parameters are a bit more complex. To be used from pure C, and from LabVIEW, a null terminated string is the best in most cases. However, null terminated strings in general have a lot of downsides. Additionally, from LabVIEW there are other considerations around encoding that having a wrapper struct helps make a bit easier. From a language like C#, a wrapper struct is by far the easiest, as custom marshalling can make it trivial to marshal both UTF8 and UTF16 strings down.
The final consideration is its nice to have an identical concept for both input and output. It makes the rules fairly easy to understand.
WPILib will not have any APIs that manipulate a string allocated externally. This means WPI_String can be const, as across the boundary it is always const.
If a WPILib API takes a const WPI_String*, WPILib will not manipulate or attempt to free that string, and that string is treated as an input. It is up to the caller to handle that memory, WPILib will never hold onto that memory longer than the call.
If a WPILib API takes a WPI_String*, that string is an output. WPILib will allocate that API with WPI_AllocateString(), fill in the string, and return to the caller. When the caller is done with the string, they must free it with WPI_FreeString().
If an output struct contains a WPI_String member, that member is considered read only, and should not be explicitly freed. The caller should call the free function for that struct.
If an array of WPI_Strings are returned, each individual string is considered read only, and should not be explicitly freed. The free function for that array should be called by the caller.
If an input struct containing a WPI_String, or an input array of WPI_Strings is passed to WPILib, the individual strings will not be manipulated or freed by WPILib, and the caller owns and should free that memory.
Callbacks also follow these rules. The most common is a callback either getting passed a const WPI_String* or a struct containing a WPI_String. In both of these cases, the callback target should consider these strings read only, and not attempt to free them or manipulate them.
2024-05-13 05:35:14 -07:00
|
|
|
auto str = wpi::make_string(nameJString);
|
|
|
|
|
HALSIM_SetEventName(&str);
|
2020-07-15 00:33:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setMatchType
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchType
|
|
|
|
|
(JNIEnv*, jclass, jint type)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetMatchType(static_cast<HAL_MatchType>(static_cast<int>(type)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setMatchNumber
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchNumber
|
|
|
|
|
(JNIEnv*, jclass, jint matchNumber)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetMatchNumber(matchNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
|
|
|
|
* Method: setReplayNumber
|
|
|
|
|
* Signature: (I)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setReplayNumber
|
|
|
|
|
(JNIEnv*, jclass, jint replayNumber)
|
|
|
|
|
{
|
|
|
|
|
HALSIM_SetReplayNumber(replayNumber);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/*
|
2020-06-27 22:11:24 -07:00
|
|
|
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: resetData
|
|
|
|
|
* Signature: ()V
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
JNIEXPORT void JNICALL
|
2020-06-27 22:11:24 -07:00
|
|
|
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_resetData
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv*, jclass)
|
|
|
|
|
{
|
2018-05-11 12:38:23 -07:00
|
|
|
HALSIM_ResetDriverStationData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|