From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14
---
source/src/hidapi/android/hid.cpp | 52 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/source/src/hidapi/android/hid.cpp b/source/src/hidapi/android/hid.cpp
index dd0edf1..e5af5ad 100644
--- a/source/src/hidapi/android/hid.cpp
+++ b/source/src/hidapi/android/hid.cpp
@@ -436,6 +436,12 @@
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
+ if ( !g_HIDDeviceManagerCallbackHandler )
+ {
+ LOGV( "Device open without callback handler" );
+ return false;
+ }
+
m_bIsWaitingForOpen = false;
m_bOpenResult = env->CallBooleanMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerOpen, m_nId );
ExceptionCheck( env, "BOpen" );
@@ -545,11 +551,18 @@
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
- jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
- int nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendOutputReport, m_nId, pBuf );
- ExceptionCheck( env, "SendOutputReport" );
-
- env->DeleteLocalRef( pBuf );
+ int nRet = -1;
+ if ( g_HIDDeviceManagerCallbackHandler )
+ {
+ jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
+ nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendOutputReport, m_nId, pBuf );
+ ExceptionCheck( env, "SendOutputReport" );
+ env->DeleteLocalRef( pBuf );
+ }
+ else
+ {
+ LOGV( "SendOutputReport without callback handler" );
+ }
return nRet;
}
@@ -560,10 +573,18 @@
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
- jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
- int nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendFeatureReport, m_nId, pBuf );
- ExceptionCheck( env, "SendFeatureReport" );
- env->DeleteLocalRef( pBuf );
+ int nRet = -1;
+ if ( g_HIDDeviceManagerCallbackHandler )
+ {
+ jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
+ nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendFeatureReport, m_nId, pBuf );
+ ExceptionCheck( env, "SendFeatureReport" );
+ env->DeleteLocalRef( pBuf );
+ }
+ else
+ {
+ LOGV( "SendFeatureReport without callback handler" );
+ }
return nRet;
}
@@ -586,6 +607,12 @@
JNIEnv *env;
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
+
+ if ( !g_HIDDeviceManagerCallbackHandler )
+ {
+ LOGV( "GetFeatureReport without callback handler" );
+ return -1;
+ }
{
hid_mutex_guard cvl( &m_cvLock );
@@ -657,8 +684,11 @@
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
- env->CallVoidMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerClose, m_nId );
- ExceptionCheck( env, "Close" );
+ if ( g_HIDDeviceManagerCallbackHandler )
+ {
+ env->CallVoidMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerClose, m_nId );
+ ExceptionCheck( env, "Close" );
+ }
hid_mutex_guard dataLock( &m_dataLock );
m_vecData.clear();
--
Gitblit v1.9.3