From 34719cba96ad9ec60b10ac348eb37e95a6fa0908 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 22 Sep 2023 10:14:16 -0700
Subject: [PATCH] Fixed crash in hid_init() if the HIDDeviceManager isn't
available
---
src/hidapi/android/hid.cpp | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp
index 1f4d8c6a0076..098feb85d868 100644
--- a/src/hidapi/android/hid.cpp
+++ b/src/hidapi/android/hid.cpp
@@ -1031,7 +1031,7 @@ extern "C"
int hid_init(void)
{
- if ( !g_initialized )
+ if ( !g_initialized && g_HIDDeviceManagerCallbackHandler )
{
// HIDAPI doesn't work well with Android < 4.3
if (SDL_GetAndroidSDKVersion() >= 18) {
@@ -1040,12 +1040,6 @@ int hid_init(void)
g_JVM->AttachCurrentThread( &env, NULL );
pthread_setspecific( g_ThreadKey, (void*)env );
- if ( !g_HIDDeviceManagerCallbackHandler )
- {
- LOGV( "hid_init() without callback handler" );
- return -1;
- }
-
// Bluetooth is currently only used for Steam Controllers, so check that hint
// before initializing Bluetooth, which will prompt the user for permission.
bool init_usb = true;