SDL
2.0
|
#include <jni.h>
#include <android/log.h>
#include <pthread.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "../hidapi/hidapi.h"
Go to the source code of this file.
Data Structures | |
struct | hid_device |
class | hid_device_ref< T > |
class | hid_mutex_guard |
class | hid_buffer |
class | hid_buffer_pool |
struct | hid_buffer_pool::hid_buffer_entry |
class | CHIDDevice |
Macros | |
#define | TAG "hidapi" |
#define | LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) |
#define | LOGV(...) |
#define | LOGD(...) |
#define | SDL_JAVA_PREFIX org_libsdl_app |
#define | CONCAT1(prefix, class, function) CONCAT2(prefix, class, function) |
#define | CONCAT2(prefix, class, function) Java_ ## prefix ## _ ## class ## _ ## function |
#define | HID_DEVICE_MANAGER_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, HIDDeviceManager, function) |
Typedefs | |
typedef uint32_t | uint32 |
typedef uint64_t | uint64 |
Functions | |
static jbyteArray | NewByteArray (JNIEnv *env, const uint8_t *pData, size_t nDataLen) |
static char * | CreateStringFromJString (JNIEnv *env, const jstring &sString) |
static wchar_t * | CreateWStringFromJString (JNIEnv *env, const jstring &sString) |
static wchar_t * | CreateWStringFromWString (const wchar_t *pwSrc) |
static hid_device_info * | CopyHIDDeviceInfo (const hid_device_info *pInfo) |
static void | FreeHIDDeviceInfo (hid_device_info *pInfo) |
static uint64_t | get_timespec_ms (const struct timespec &ts) |
static hid_device_ref< CHIDDevice > | FindDevice (int nDeviceId) |
static void | ThreadDestroyed (void *value) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceRegisterCallback (JNIEnv *env, jobject thiz) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceReleaseCallback (JNIEnv *env, jobject thiz) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceConnected (JNIEnv *env, jobject thiz, int nDeviceID, jstring sIdentifier, int nVendorId, int nProductId, jstring sSerialNumber, int nReleaseNumber, jstring sManufacturer, jstring sProduct, int nInterface) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceOpenPending (JNIEnv *env, jobject thiz, int nDeviceID) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceOpenResult (JNIEnv *env, jobject thiz, int nDeviceID, bool bOpened) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceDisconnected (JNIEnv *env, jobject thiz, int nDeviceID) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceInputReport (JNIEnv *env, jobject thiz, int nDeviceID, jbyteArray value) |
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() | HIDDeviceFeatureReport (JNIEnv *env, jobject thiz, int nDeviceID, jbyteArray value) |
int | hid_init (void) |
Initialize the HIDAPI library. More... | |
struct hid_device_info HID_API_EXPORT *HID_API_CALL | hid_enumerate (unsigned short vendor_id, unsigned short product_id) |
Enumerate the HID Devices. More... | |
void HID_API_EXPORT HID_API_CALL | hid_free_enumeration (struct hid_device_info *devs) |
Free an enumeration Linked List. More... | |
HID_API_EXPORT hid_device *HID_API_CALL | hid_open (unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) |
Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. More... | |
HID_API_EXPORT hid_device *HID_API_CALL | hid_open_path (const char *path, int bExclusive) |
Open a HID device by its path name. More... | |
int HID_API_EXPORT HID_API_CALL | hid_write (hid_device *device, const unsigned char *data, size_t length) |
Write an Output report to a HID device. More... | |
int HID_API_EXPORT HID_API_CALL | hid_read_timeout (hid_device *device, unsigned char *data, size_t length, int milliseconds) |
Read an Input report from a HID device with timeout. More... | |
int HID_API_EXPORT HID_API_CALL | hid_read (hid_device *device, unsigned char *data, size_t length) |
Read an Input report from a HID device. More... | |
int HID_API_EXPORT HID_API_CALL | hid_set_nonblocking (hid_device *device, int nonblock) |
Set the device handle to be non-blocking. More... | |
int HID_API_EXPORT HID_API_CALL | hid_send_feature_report (hid_device *device, const unsigned char *data, size_t length) |
Send a Feature report to the device. More... | |
int HID_API_EXPORT HID_API_CALL | hid_get_feature_report (hid_device *device, unsigned char *data, size_t length) |
Get a feature report from a HID device. More... | |
void HID_API_EXPORT HID_API_CALL | hid_close (hid_device *device) |
Close a HID device. More... | |
int HID_API_EXPORT_CALL | hid_get_manufacturer_string (hid_device *device, wchar_t *string, size_t maxlen) |
Get The Manufacturer String from a HID device. More... | |
int HID_API_EXPORT_CALL | hid_get_product_string (hid_device *device, wchar_t *string, size_t maxlen) |
Get The Product String from a HID device. More... | |
int HID_API_EXPORT_CALL | hid_get_serial_number_string (hid_device *device, wchar_t *string, size_t maxlen) |
Get The Serial Number String from a HID device. More... | |
int HID_API_EXPORT_CALL | hid_get_indexed_string (hid_device *device, int string_index, wchar_t *string, size_t maxlen) |
Get a string from a HID device, based on its string index. More... | |
HID_API_EXPORT const wchar_t *HID_API_CALL | hid_error (hid_device *device) |
Get a string describing the last error which occurred. More... | |
int | hid_exit (void) |
Finalize the HIDAPI library. More... | |
Variables | |
static JavaVM * | g_JVM |
static pthread_key_t | g_ThreadKey |
static jclass | g_HIDDeviceManagerCallbackClass |
static jobject | g_HIDDeviceManagerCallbackHandler |
static jmethodID | g_midHIDDeviceManagerOpen |
static jmethodID | g_midHIDDeviceManagerSendOutputReport |
static jmethodID | g_midHIDDeviceManagerSendFeatureReport |
static jmethodID | g_midHIDDeviceManagerGetFeatureReport |
static jmethodID | g_midHIDDeviceManagerClose |
static pthread_mutex_t | g_DevicesMutex = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | g_DevicesRefCountMutex = PTHREAD_MUTEX_INITIALIZER |
static hid_device_ref< CHIDDevice > | g_Devices |
#define CONCAT1 | ( | prefix, | |
class, | |||
function | |||
) | CONCAT2(prefix, class, function) |
#define CONCAT2 | ( | prefix, | |
class, | |||
function | |||
) | Java_ ## prefix ## _ ## class ## _ ## function |
#define HID_DEVICE_MANAGER_JAVA_INTERFACE | ( | function | ) | CONCAT1(SDL_JAVA_PREFIX, HIDDeviceManager, function) |
Definition at line 32 of file hid.cpp.
Referenced by ThreadDestroyed().
#define LOGD | ( | ... | ) |
Definition at line 26 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), hid_close(), and hid_open_path().
#define LOGE | ( | ... | ) | __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) |
Definition at line 19 of file hid.cpp.
Referenced by CHIDDevice::ExceptionCheck().
#define LOGV | ( | ... | ) |
Definition at line 25 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), CHIDDevice::GetFeatureReport(), hid_close(), hid_get_feature_report(), hid_open_path(), hid_read(), hid_read_timeout(), hid_send_feature_report(), hid_write(), HIDDeviceConnected(), HIDDeviceDisconnected(), HIDDeviceFeatureReport(), HIDDeviceOpenPending(), HIDDeviceOpenResult(), HIDDeviceRegisterCallback(), and HIDDeviceReleaseCallback().
#define TAG "hidapi" |
Definition at line 16 of file hid.cpp.
Referenced by HIDDeviceRegisterCallback().
|
static |
Definition at line 315 of file hid.cpp.
References CreateWStringFromWString(), hid_device_info::manufacturer_string, hid_device_info::path, hid_device_info::product_string, and hid_device_info::serial_number.
Referenced by hid_enumerate().
|
static |
|
static |
|
static |
Definition at line 306 of file hid.cpp.
References malloc, and memcpy.
Referenced by CopyHIDDeviceInfo().
|
static |
Definition at line 709 of file hid.cpp.
References g_DevicesMutex, CHIDDevice::GetId(), and CHIDDevice::next.
Referenced by hid_close(), hid_get_feature_report(), hid_get_manufacturer_string(), hid_get_product_string(), hid_get_serial_number_string(), hid_read_timeout(), hid_send_feature_report(), hid_write(), HIDDeviceFeatureReport(), HIDDeviceInputReport(), HIDDeviceOpenPending(), and HIDDeviceOpenResult().
|
static |
Definition at line 326 of file hid.cpp.
References free, hid_device_info::manufacturer_string, hid_device_info::path, hid_device_info::product_string, and hid_device_info::serial_number.
Referenced by hid_free_enumeration(), and CHIDDevice::~CHIDDevice().
|
static |
Definition at line 343 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), and CHIDDevice::GetFeatureReport().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceConnected | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID, | ||
jstring | sIdentifier, | ||
int | nVendorId, | ||
int | nProductId, | ||
jstring | sSerialNumber, | ||
int | nReleaseNumber, | ||
jstring | sManufacturer, | ||
jstring | sProduct, | ||
int | nInterface | ||
) |
Definition at line 831 of file hid.cpp.
References CHIDDevice::CHIDDevice(), CreateStringFromJString(), CreateWStringFromJString(), g_DevicesMutex, hid_device_info::interface_number, LOGV, hid_device_info::manufacturer_string, memset, CHIDDevice::next, hid_device_info::path, hid_device_info::product_id, hid_device_info::product_string, hid_device_info::release_number, hid_device_info::serial_number, and hid_device_info::vendor_id.
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceDisconnected | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID | ||
) |
Definition at line 887 of file hid.cpp.
References CHIDDevice::Close(), g_DevicesMutex, LOGV, and CHIDDevice::next.
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceFeatureReport | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID, | ||
jbyteArray | value | ||
) |
Definition at line 934 of file hid.cpp.
References FindDevice(), LOGV, NULL, and CHIDDevice::ProcessFeatureReport().
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceInputReport | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID, | ||
jbyteArray | value | ||
) |
Definition at line 918 of file hid.cpp.
References FindDevice(), NULL, and CHIDDevice::ProcessInput().
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceOpenPending | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID | ||
) |
Definition at line 865 of file hid.cpp.
References FindDevice(), LOGV, and CHIDDevice::SetOpenPending().
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceOpenResult | ( | JNIEnv * | env, |
jobject | thiz, | ||
int | nDeviceID, | ||
bool | bOpened | ||
) |
Definition at line 876 of file hid.cpp.
References FindDevice(), LOGV, and CHIDDevice::SetOpenResult().
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceRegisterCallback | ( | JNIEnv * | env, |
jobject | thiz | ||
) |
Definition at line 761 of file hid.cpp.
References g_HIDDeviceManagerCallbackClass, g_HIDDeviceManagerCallbackHandler, g_JVM, g_midHIDDeviceManagerClose, g_midHIDDeviceManagerGetFeatureReport, g_midHIDDeviceManagerOpen, g_midHIDDeviceManagerSendFeatureReport, g_midHIDDeviceManagerSendOutputReport, g_ThreadKey, LOGV, NULL, TAG, and ThreadDestroyed().
Referenced by ThreadDestroyed().
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE() HIDDeviceReleaseCallback | ( | JNIEnv * | env, |
jobject | thiz | ||
) |
Definition at line 818 of file hid.cpp.
References g_HIDDeviceManagerCallbackClass, g_HIDDeviceManagerCallbackHandler, LOGV, and NULL.
Referenced by ThreadDestroyed().
Definition at line 270 of file hid.cpp.
Referenced by CHIDDevice::GetFeatureReport(), CHIDDevice::SendFeatureReport(), and CHIDDevice::SendOutputReport().
Definition at line 724 of file hid.cpp.
References g_JVM, g_ThreadKey, HID_DEVICE_MANAGER_JAVA_INTERFACE, HIDDeviceConnected(), HIDDeviceDisconnected(), HIDDeviceFeatureReport(), HIDDeviceInputReport(), HIDDeviceOpenPending(), HIDDeviceOpenResult(), HIDDeviceRegisterCallback(), HIDDeviceReleaseCallback(), and NULL.
Referenced by HIDDeviceRegisterCallback().
|
static |
|
static |
Definition at line 705 of file hid.cpp.
Referenced by FindDevice(), hid_enumerate(), hid_open_path(), HIDDeviceConnected(), and HIDDeviceDisconnected().
|
static |
Definition at line 706 of file hid.cpp.
Referenced by hid_close(), and hid_open_path().
|
static |
Definition at line 335 of file hid.cpp.
Referenced by HIDDeviceRegisterCallback(), and HIDDeviceReleaseCallback().
|
static |
Definition at line 336 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), CHIDDevice::Close(), CHIDDevice::GetFeatureReport(), HIDDeviceRegisterCallback(), HIDDeviceReleaseCallback(), CHIDDevice::SendFeatureReport(), and CHIDDevice::SendOutputReport().
|
static |
Definition at line 46 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), CHIDDevice::Close(), CHIDDevice::GetFeatureReport(), HIDDeviceRegisterCallback(), CHIDDevice::SendFeatureReport(), CHIDDevice::SendOutputReport(), and ThreadDestroyed().
|
static |
Definition at line 341 of file hid.cpp.
Referenced by CHIDDevice::Close(), and HIDDeviceRegisterCallback().
|
static |
Definition at line 340 of file hid.cpp.
Referenced by CHIDDevice::GetFeatureReport(), and HIDDeviceRegisterCallback().
|
static |
Definition at line 337 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), and HIDDeviceRegisterCallback().
|
static |
Definition at line 339 of file hid.cpp.
Referenced by HIDDeviceRegisterCallback(), and CHIDDevice::SendFeatureReport().
|
static |
Definition at line 338 of file hid.cpp.
Referenced by HIDDeviceRegisterCallback(), and CHIDDevice::SendOutputReport().
|
static |
Definition at line 47 of file hid.cpp.
Referenced by CHIDDevice::BOpen(), CHIDDevice::Close(), CHIDDevice::GetFeatureReport(), HIDDeviceRegisterCallback(), CHIDDevice::SendFeatureReport(), CHIDDevice::SendOutputReport(), and ThreadDestroyed().