android: register all methods using JNI_OnLoad

This commit is contained in:
Anonymous Maarten
2022-12-22 02:27:38 +01:00
committed by Sam Lantinga
parent c9887c5c72
commit 4676d1d31e
5 changed files with 58 additions and 141 deletions

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 2021 Valve Corporation
Copyright (C) 2022 Valve Corporation
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,7 @@
//
// This layer glues the hidapi API to Android's USB and BLE stack.
#include "hid.h"
// Common to stub version and non-stub version of functions
#include <jni.h>
@@ -1428,3 +1429,15 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceFeatureReport)
}
#endif /* SDL_HIDAPI_DISABLED */
extern "C"
JNINativeMethod HIDDeviceManager_tab[8] = {
{ "HIDDeviceRegisterCallback", "()V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallback) },
{ "HIDDeviceReleaseCallback", "()V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceReleaseCallback) },
{ "HIDDeviceConnected", "(ILjava/lang/String;IILjava/lang/String;ILjava/lang/String;Ljava/lang/String;IIII)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceConnected) },
{ "HIDDeviceOpenPending", "(I)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceOpenPending) },
{ "HIDDeviceOpenResult", "(IZ)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceOpenResult) },
{ "HIDDeviceDisconnected", "(I)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceDisconnected) },
{ "HIDDeviceInputReport", "(I[B)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceInputReport) },
{ "HIDDeviceFeatureReport", "(I[B)V", (void*)HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceFeatureReport) }
};

41
src/hidapi/android/hid.h Normal file
View File

@@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 2022 Valve Corporation
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
// Purpose: Exporting table containing HIDDeviceManager native methods
#ifndef SDL_android_hid_h_
#define SDL_android_hid_h_
#include <jni.h>
#if defined(__cplusplus)
extern "C" {
#endif
extern JNINativeMethod HIDDeviceManager_tab[8];
#if defined(__cplusplus)
}
#endif
#endif
/* vi: set ts=4 sw=4 expandtab: */