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
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <jni.h>
|
2018-05-13 17:09:56 -07:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/util/jni_util.hpp"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
#include "SimulatorJNI.h"
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hal/Types.h"
|
|
|
|
|
#include "wpi/hal/Value.h"
|
|
|
|
|
#include "wpi/hal/handles/UnlimitedHandleResource.h"
|
|
|
|
|
#include "wpi/hal/simulation/NotifyListener.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-12-28 01:19:59 -08:00
|
|
|
namespace hal::sim {
|
2018-05-11 12:38:23 -07:00
|
|
|
class BufferCallbackStore {
|
|
|
|
|
public:
|
|
|
|
|
void create(JNIEnv* env, jobject obj);
|
|
|
|
|
void performCallback(const char* name, uint8_t* buffer, uint32_t length);
|
|
|
|
|
void free(JNIEnv* env);
|
|
|
|
|
void setCallbackId(int32_t id) { callbackId = id; }
|
|
|
|
|
int32_t getCallbackId() { return callbackId; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
wpi::java::JGlobal<jobject> m_call;
|
|
|
|
|
int32_t callbackId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void InitializeBufferStore();
|
|
|
|
|
|
2020-12-27 22:52:53 -08:00
|
|
|
using RegisterBufferCallbackFunc = int32_t (*)(int32_t index,
|
|
|
|
|
HAL_BufferCallback callback,
|
|
|
|
|
void* param);
|
|
|
|
|
using FreeBufferCallbackFunc = void (*)(int32_t index, int32_t uid);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
SIM_JniHandle AllocateBufferCallback(JNIEnv* env, jint index, jobject callback,
|
|
|
|
|
RegisterBufferCallbackFunc createCallback);
|
|
|
|
|
void FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
|
|
|
|
FreeBufferCallbackFunc freeCallback);
|
2020-12-28 01:19:59 -08:00
|
|
|
} // namespace hal::sim
|