2015-06-21 17:33:46 +02:00
/*
Simple DirectMedia Layer
2025-01-01 07:45:41 -08:00
Copyright ( C ) 1997 - 2025 Sam Lantinga < slouken @ libsdl . org >
2015-06-21 17:33:46 +02:00
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 .
*/
2022-11-29 18:34:15 -08:00
# include "SDL_internal.h"
2020-04-07 09:38:57 -07:00
2024-01-24 02:40:51 +01:00
# ifdef SDL_PLATFORM_ANDROID
2015-06-21 17:33:46 +02:00
# include "SDL_android.h"
# include "../../events/SDL_events_c.h"
# include "../../video/android/SDL_androidkeyboard.h"
# include "../../video/android/SDL_androidmouse.h"
# include "../../video/android/SDL_androidtouch.h"
2024-11-12 22:58:39 +09:00
# include "../../video/android/SDL_androidpen.h"
2015-06-21 17:33:46 +02:00
# include "../../video/android/SDL_androidvideo.h"
# include "../../video/android/SDL_androidwindow.h"
# include "../../joystick/android/SDL_sysjoystick_c.h"
2017-08-12 08:15:09 -07:00
# include "../../haptic/android/SDL_syshaptic_c.h"
2022-12-22 02:27:38 +01:00
# include "../../hidapi/android/hid.h"
2023-04-05 21:54:36 +02:00
# include "../../SDL_hints_c.h"
2015-06-21 17:33:46 +02:00
# include <android/log.h>
2020-05-04 02:27:29 -04:00
# include <android/configuration.h>
# include <android/asset_manager_jni.h>
2019-05-23 14:19:00 -07:00
# include <sys/system_properties.h>
2015-06-21 17:33:46 +02:00
# include <pthread.h>
# include <sys/types.h>
# include <unistd.h>
2017-08-28 14:34:15 -07:00
# include <dlfcn.h>
2016-12-02 02:25:12 -08:00
2022-11-30 12:51:59 -08:00
# 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 SDL_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLActivity, function)
# define SDL_JAVA_AUDIO_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLAudioManager, function)
# define SDL_JAVA_CONTROLLER_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function)
# define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function) CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function)
2016-12-02 02:25:12 -08:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Audio encoding definitions
2022-11-30 12:51:59 -08:00
# define ENCODING_PCM_8BIT 3
# define ENCODING_PCM_16BIT 2
# define ENCODING_PCM_FLOAT 4
2016-12-02 02:25:12 -08:00
2025-01-10 15:27:08 -08:00
// Java class SDLActivity
2022-10-03 17:36:17 -07:00
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE ( nativeGetVersion ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2022-10-03 17:36:17 -07:00
2017-08-28 14:34:15 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetupJNI ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2017-08-28 14:34:15 -07:00
2024-08-05 20:23:36 +09:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeInitMainThread ) (
2024-08-03 15:34:38 +02:00
JNIEnv * env , jclass cls ) ;
2024-08-05 20:23:36 +09:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeCleanupMainThread ) (
2024-08-03 15:34:38 +02:00
JNIEnv * env , jclass cls ) ;
2017-08-28 14:34:15 -07:00
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE ( nativeRunMain ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring library , jstring function , jobject array ) ;
2017-08-28 14:34:15 -07:00
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeDropFile ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jstring filename ) ;
2016-12-02 02:25:12 -08:00
2019-01-17 11:05:05 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetScreenResolution ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint surfaceWidth , jint surfaceHeight ,
2023-01-25 14:55:50 +01:00
jint deviceWidth , jint deviceHeight , jfloat density , jfloat rate ) ;
2016-12-02 02:25:12 -08:00
2019-01-17 11:05:05 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeResize ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2019-01-17 11:05:05 +01:00
2019-01-09 22:41:52 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceCreated ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2019-01-09 22:41:52 +01:00
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceDestroyed ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyDown ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint keycode ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyUp ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint keycode ) ;
2016-12-02 02:25:12 -08:00
2019-05-23 11:05:43 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( onNativeSoftReturnKey ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2019-05-23 11:05:43 -07:00
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyboardFocusLost ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeTouch ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint touch_device_id_in , jint pointer_finger_id_in ,
jint action , jfloat x , jfloat y , jfloat p ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeMouse ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint button , jint action , jfloat x , jfloat y , jboolean relative ) ;
2016-12-02 02:25:12 -08:00
2024-11-12 22:58:39 +09:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativePen ) (
JNIEnv * env , jclass jcls ,
jint pen_id_in , jint button , jint action , jfloat x , jfloat y , jfloat p ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeAccel ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jfloat x , jfloat y , jfloat z ) ;
2016-12-02 02:25:12 -08:00
2017-08-27 18:43:52 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeClipboardChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2017-08-27 18:43:52 -07:00
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeLowMemory ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2016-12-02 02:25:12 -08:00
2020-05-08 21:40:28 +02:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeLocaleChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2020-05-08 21:40:28 +02:00
2023-03-07 00:01:34 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeDarkModeChanged ) (
JNIEnv * env , jclass cls , jboolean enabled ) ;
2019-01-10 15:35:46 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSendQuit ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2016-12-02 02:25:12 -08:00
2019-01-10 15:43:07 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeQuit ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2019-01-10 15:43:07 +01:00
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativePause ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeResume ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ) ;
2016-12-02 02:25:12 -08:00
Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC
Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.
- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.
- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.
So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.
I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634
So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeFocusChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls , jboolean hasFocus ) ;
Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC
Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.
- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.
- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.
So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.
I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634
So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
2016-12-02 02:25:12 -08:00
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE ( nativeGetHint ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name ) ;
2016-12-02 02:25:12 -08:00
2021-11-15 16:52:54 -08:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( nativeGetHintBoolean ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name , jboolean default_value ) ;
2021-11-15 16:52:54 -08:00
2017-11-04 09:37:29 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetenv ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name , jstring value ) ;
2017-11-04 09:37:29 -07:00
2023-06-17 00:52:40 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetNaturalOrientation ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jint orientation ) ;
2018-08-23 14:05:25 -07:00
2023-06-17 00:52:40 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeRotationChanged ) (
JNIEnv * env , jclass cls ,
jint rotation ) ;
2024-07-22 18:59:53 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeInsetsChanged ) (
JNIEnv * env , jclass cls ,
jint left , jint right , jint top , jint bottom ) ;
2019-01-10 21:40:57 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeAddTouch ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jint touchId , jstring name ) ;
2019-01-10 21:40:57 +01:00
2020-02-13 10:19:05 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativePermissionResult ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jint requestCode , jboolean result ) ;
2020-02-13 10:19:05 -08:00
2023-04-05 21:54:36 +02:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( nativeAllowRecreateActivity ) (
JNIEnv * env , jclass jcls ) ;
2023-06-09 09:41:54 +02:00
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE ( nativeCheckSDLThreadCounter ) (
JNIEnv * env , jclass jcls ) ;
2024-05-06 12:14:20 +08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeFileDialog ) (
JNIEnv * env , jclass jcls ,
jint requestCode , jobjectArray fileList , jint filter ) ;
2025-01-10 15:27:08 -08:00
static JNINativeMethod SDLActivity_tab [ ] = {
2022-11-30 12:51:59 -08:00
{ " nativeGetVersion " , " ()Ljava/lang/String; " , SDL_JAVA_INTERFACE ( nativeGetVersion ) } ,
{ " nativeSetupJNI " , " ()I " , SDL_JAVA_INTERFACE ( nativeSetupJNI ) } ,
2024-08-05 20:23:36 +09:00
{ " nativeInitMainThread " , " ()V " , SDL_JAVA_INTERFACE ( nativeInitMainThread ) } ,
{ " nativeCleanupMainThread " , " ()V " , SDL_JAVA_INTERFACE ( nativeCleanupMainThread ) } ,
2022-11-30 12:51:59 -08:00
{ " nativeRunMain " , " (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I " , SDL_JAVA_INTERFACE ( nativeRunMain ) } ,
{ " onNativeDropFile " , " (Ljava/lang/String;)V " , SDL_JAVA_INTERFACE ( onNativeDropFile ) } ,
2023-01-25 14:55:50 +01:00
{ " nativeSetScreenResolution " , " (IIIIFF)V " , SDL_JAVA_INTERFACE ( nativeSetScreenResolution ) } ,
2022-11-30 12:51:59 -08:00
{ " onNativeResize " , " ()V " , SDL_JAVA_INTERFACE ( onNativeResize ) } ,
{ " onNativeSurfaceCreated " , " ()V " , SDL_JAVA_INTERFACE ( onNativeSurfaceCreated ) } ,
{ " onNativeSurfaceChanged " , " ()V " , SDL_JAVA_INTERFACE ( onNativeSurfaceChanged ) } ,
{ " onNativeSurfaceDestroyed " , " ()V " , SDL_JAVA_INTERFACE ( onNativeSurfaceDestroyed ) } ,
{ " onNativeKeyDown " , " (I)V " , SDL_JAVA_INTERFACE ( onNativeKeyDown ) } ,
{ " onNativeKeyUp " , " (I)V " , SDL_JAVA_INTERFACE ( onNativeKeyUp ) } ,
{ " onNativeSoftReturnKey " , " ()Z " , SDL_JAVA_INTERFACE ( onNativeSoftReturnKey ) } ,
{ " onNativeKeyboardFocusLost " , " ()V " , SDL_JAVA_INTERFACE ( onNativeKeyboardFocusLost ) } ,
{ " onNativeTouch " , " (IIIFFF)V " , SDL_JAVA_INTERFACE ( onNativeTouch ) } ,
{ " onNativeMouse " , " (IIFFZ)V " , SDL_JAVA_INTERFACE ( onNativeMouse ) } ,
2024-11-12 22:58:39 +09:00
{ " onNativePen " , " (IIIFFF)V " , SDL_JAVA_INTERFACE ( onNativePen ) } ,
2022-11-30 12:51:59 -08:00
{ " onNativeAccel " , " (FFF)V " , SDL_JAVA_INTERFACE ( onNativeAccel ) } ,
{ " onNativeClipboardChanged " , " ()V " , SDL_JAVA_INTERFACE ( onNativeClipboardChanged ) } ,
{ " nativeLowMemory " , " ()V " , SDL_JAVA_INTERFACE ( nativeLowMemory ) } ,
{ " onNativeLocaleChanged " , " ()V " , SDL_JAVA_INTERFACE ( onNativeLocaleChanged ) } ,
2023-03-07 00:01:34 -08:00
{ " onNativeDarkModeChanged " , " (Z)V " , SDL_JAVA_INTERFACE ( onNativeDarkModeChanged ) } ,
2022-11-30 12:51:59 -08:00
{ " nativeSendQuit " , " ()V " , SDL_JAVA_INTERFACE ( nativeSendQuit ) } ,
{ " nativeQuit " , " ()V " , SDL_JAVA_INTERFACE ( nativeQuit ) } ,
{ " nativePause " , " ()V " , SDL_JAVA_INTERFACE ( nativePause ) } ,
{ " nativeResume " , " ()V " , SDL_JAVA_INTERFACE ( nativeResume ) } ,
{ " nativeFocusChanged " , " (Z)V " , SDL_JAVA_INTERFACE ( nativeFocusChanged ) } ,
{ " nativeGetHint " , " (Ljava/lang/String;)Ljava/lang/String; " , SDL_JAVA_INTERFACE ( nativeGetHint ) } ,
{ " nativeGetHintBoolean " , " (Ljava/lang/String;Z)Z " , SDL_JAVA_INTERFACE ( nativeGetHintBoolean ) } ,
{ " nativeSetenv " , " (Ljava/lang/String;Ljava/lang/String;)V " , SDL_JAVA_INTERFACE ( nativeSetenv ) } ,
2023-06-17 00:52:40 -07:00
{ " nativeSetNaturalOrientation " , " (I)V " , SDL_JAVA_INTERFACE ( nativeSetNaturalOrientation ) } ,
{ " onNativeRotationChanged " , " (I)V " , SDL_JAVA_INTERFACE ( onNativeRotationChanged ) } ,
2024-07-22 18:59:53 -07:00
{ " onNativeInsetsChanged " , " (IIII)V " , SDL_JAVA_INTERFACE ( onNativeInsetsChanged ) } ,
2022-11-30 12:51:59 -08:00
{ " nativeAddTouch " , " (ILjava/lang/String;)V " , SDL_JAVA_INTERFACE ( nativeAddTouch ) } ,
2023-04-05 21:54:36 +02:00
{ " nativePermissionResult " , " (IZ)V " , SDL_JAVA_INTERFACE ( nativePermissionResult ) } ,
{ " nativeAllowRecreateActivity " , " ()Z " , SDL_JAVA_INTERFACE ( nativeAllowRecreateActivity ) } ,
2024-05-06 12:14:20 +08:00
{ " nativeCheckSDLThreadCounter " , " ()I " , SDL_JAVA_INTERFACE ( nativeCheckSDLThreadCounter ) } ,
{ " onNativeFileDialog " , " (I[Ljava/lang/String;I)V " , SDL_JAVA_INTERFACE ( onNativeFileDialog ) }
2019-12-12 18:38:36 +01:00
} ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Java class SDLInputConnection
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeCommitText ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring text , jint newCursorPosition ) ;
2016-12-02 02:25:12 -08:00
2018-09-27 14:56:29 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeGenerateScancodeForUnichar ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jchar chUnicode ) ;
2018-09-27 14:56:29 -07:00
2019-12-12 18:38:36 +01:00
static JNINativeMethod SDLInputConnection_tab [ ] = {
2022-11-30 12:51:59 -08:00
{ " nativeCommitText " , " (Ljava/lang/String;I)V " , SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeCommitText ) } ,
{ " nativeGenerateScancodeForUnichar " , " (C)V " , SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeGenerateScancodeForUnichar ) }
2019-12-12 18:38:36 +01:00
} ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Java class SDLAudioManager
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE ( nativeSetupJNI ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2017-09-22 08:30:46 -07:00
2022-12-16 17:38:57 +02:00
JNIEXPORT void JNICALL
2025-03-23 17:14:21 +01:00
SDL_JAVA_AUDIO_INTERFACE ( nativeAddAudioDevice ) ( JNIEnv * env , jclass jcls , jboolean recording , jstring name ,
2022-12-19 17:02:10 +02:00
jint device_id ) ;
2022-12-16 17:38:57 +02:00
JNIEXPORT void JNICALL
2025-03-23 17:14:21 +01:00
SDL_JAVA_AUDIO_INTERFACE ( nativeRemoveAudioDevice ) ( JNIEnv * env , jclass jcls , jboolean recording ,
2022-12-19 17:02:10 +02:00
jint device_id ) ;
2022-12-16 17:38:57 +02:00
2019-12-12 18:38:36 +01:00
static JNINativeMethod SDLAudioManager_tab [ ] = {
2022-12-16 17:38:57 +02:00
{ " nativeSetupJNI " , " ()I " , SDL_JAVA_AUDIO_INTERFACE ( nativeSetupJNI ) } ,
2025-03-23 17:14:21 +01:00
{ " nativeAddAudioDevice " , " (ZLjava/lang/String;I)V " , SDL_JAVA_AUDIO_INTERFACE ( nativeAddAudioDevice ) } ,
{ " nativeRemoveAudioDevice " , " (ZI)V " , SDL_JAVA_AUDIO_INTERFACE ( nativeRemoveAudioDevice ) }
2019-12-12 18:38:36 +01:00
} ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Java class SDLControllerManager
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeSetupJNI ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadDown ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint keycode ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadUp ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint keycode ) ;
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativeJoy ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint axis , jfloat value ) ;
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativeHat ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint hat_id , jint x , jint y ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddJoystick ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jstring device_name , jstring device_desc , jint vendor_id , jint product_id ,
2024-06-05 09:47:25 -07:00
jint button_mask , jint naxes , jint axis_mask , jint nhats , jboolean can_rumble ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveJoystick ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddHaptic ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jstring device_name ) ;
2017-09-22 08:30:46 -07:00
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveHaptic ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id ) ;
2017-09-22 08:30:46 -07:00
2019-12-12 18:38:36 +01:00
static JNINativeMethod SDLControllerManager_tab [ ] = {
2022-11-30 12:51:59 -08:00
{ " nativeSetupJNI " , " ()I " , SDL_JAVA_CONTROLLER_INTERFACE ( nativeSetupJNI ) } ,
2024-08-22 17:33:49 -07:00
{ " onNativePadDown " , " (II)Z " , SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadDown ) } ,
{ " onNativePadUp " , " (II)Z " , SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadUp ) } ,
2022-11-30 12:51:59 -08:00
{ " onNativeJoy " , " (IIF)V " , SDL_JAVA_CONTROLLER_INTERFACE ( onNativeJoy ) } ,
{ " onNativeHat " , " (IIII)V " , SDL_JAVA_CONTROLLER_INTERFACE ( onNativeHat ) } ,
2024-08-22 17:33:49 -07:00
{ " nativeAddJoystick " , " (ILjava/lang/String;Ljava/lang/String;IIIIIIZ)V " , SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddJoystick ) } ,
{ " nativeRemoveJoystick " , " (I)V " , SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveJoystick ) } ,
{ " nativeAddHaptic " , " (ILjava/lang/String;)V " , SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddHaptic ) } ,
{ " nativeRemoveHaptic " , " (I)V " , SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveHaptic ) }
2019-12-12 18:38:36 +01:00
} ;
2017-09-22 08:30:46 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Uncomment this to log messages entering and exiting methods in this file
// #define DEBUG_JNI
2015-06-21 17:33:46 +02:00
2018-09-27 14:56:29 -07:00
static void checkJNIReady ( void ) ;
2015-06-21 17:33:46 +02:00
/*******************************************************************************
This file links the Java side of Android with libsdl
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <jni.h>
/*******************************************************************************
Globals
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static pthread_key_t mThreadKey ;
2019-01-11 15:27:53 +01:00
static pthread_once_t key_once = PTHREAD_ONCE_INIT ;
static JavaVM * mJavaVM = NULL ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Main activity
2015-06-21 17:33:46 +02:00
static jclass mActivityClass ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// method signatures
2020-02-13 10:19:05 -08:00
static jmethodID midClipboardGetText ;
static jmethodID midClipboardHasText ;
static jmethodID midClipboardSetText ;
static jmethodID midCreateCustomCursor ;
2021-12-21 22:07:17 +01:00
static jmethodID midDestroyCustomCursor ;
2017-08-14 14:14:45 -07:00
static jmethodID midGetContext ;
2020-02-13 10:19:05 -08:00
static jmethodID midGetManifestEnvironmentVariables ;
static jmethodID midGetNativeSurface ;
static jmethodID midInitTouch ;
2018-02-06 15:03:35 -08:00
static jmethodID midIsAndroidTV ;
2018-06-05 12:46:13 -07:00
static jmethodID midIsChromebook ;
2018-06-18 13:14:02 -07:00
static jmethodID midIsDeXMode ;
2017-08-14 14:14:45 -07:00
static jmethodID midIsScreenKeyboardShown ;
2020-02-13 10:19:05 -08:00
static jmethodID midIsTablet ;
static jmethodID midManualBackButton ;
static jmethodID midMinimizeWindow ;
2020-10-01 14:41:09 +02:00
static jmethodID midOpenURL ;
2020-02-13 10:19:05 -08:00
static jmethodID midRequestPermission ;
2021-02-19 12:54:57 +03:00
static jmethodID midShowToast ;
2020-02-13 10:19:05 -08:00
static jmethodID midSendMessage ;
static jmethodID midSetActivityTitle ;
2018-03-15 18:22:48 -07:00
static jmethodID midSetCustomCursor ;
2020-02-13 10:19:05 -08:00
static jmethodID midSetOrientation ;
static jmethodID midSetRelativeMouseEnabled ;
2018-03-15 18:22:48 -07:00
static jmethodID midSetSystemCursor ;
2020-02-13 10:19:05 -08:00
static jmethodID midSetWindowStyle ;
static jmethodID midShouldMinimizeOnFocusLoss ;
static jmethodID midShowTextInput ;
2018-06-05 12:46:11 -07:00
static jmethodID midSupportsRelativeMouse ;
2024-05-07 00:05:49 +08:00
static jmethodID midOpenFileDescriptor ;
2024-05-06 12:14:20 +08:00
static jmethodID midShowFileDialog ;
2025-05-20 18:09:28 -04:00
static jmethodID midGetPreferredLocales ;
2017-08-27 18:43:52 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// audio manager
2017-09-22 08:30:46 -07:00
static jclass mAudioManagerClass ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// method signatures
2023-07-26 15:45:40 -04:00
static jmethodID midRegisterAudioDeviceCallback ;
static jmethodID midUnregisterAudioDeviceCallback ;
2019-01-10 18:05:56 +01:00
static jmethodID midAudioSetThreadPriority ;
2017-09-22 08:30:46 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// controller manager
2017-09-22 08:30:46 -07:00
static jclass mControllerManagerClass ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// method signatures
2017-09-22 08:30:46 -07:00
static jmethodID midPollInputDevices ;
static jmethodID midPollHapticDevices ;
static jmethodID midHapticRun ;
2024-06-05 09:47:25 -07:00
static jmethodID midHapticRumble ;
2018-08-24 10:41:57 -07:00
static jmethodID midHapticStop ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Accelerometer data storage
2023-06-17 00:52:40 -07:00
static SDL_DisplayOrientation displayNaturalOrientation ;
static SDL_DisplayOrientation displayCurrentOrientation ;
2015-06-21 17:33:46 +02:00
static float fLastAccelerometer [ 3 ] ;
2024-08-22 09:21:26 -07:00
static bool bHasNewData ;
2015-06-21 17:33:46 +02:00
2024-08-22 09:21:26 -07:00
static bool bHasEnvironmentVariables ;
2020-02-13 10:19:05 -08:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Android AssetManager
2020-05-08 11:00:51 +02:00
static void Internal_Android_Create_AssetManager ( void ) ;
static void Internal_Android_Destroy_AssetManager ( void ) ;
static AAssetManager * asset_manager = NULL ;
static jobject javaAssetManagerRef = 0 ;
2024-07-23 20:55:24 -07:00
static SDL_Mutex * Android_ActivityMutex = NULL ;
2024-07-24 12:43:44 -07:00
static SDL_Mutex * Android_LifecycleMutex = NULL ;
static SDL_Semaphore * Android_LifecycleEventSem = NULL ;
static SDL_AndroidLifecycleEvent Android_LifecycleEvents [ SDL_NUM_ANDROID_LIFECYCLE_EVENTS ] ;
static int Android_NumLifecycleEvents ;
2024-07-23 20:55:24 -07:00
2015-06-21 17:33:46 +02:00
/*******************************************************************************
Functions called by JNI
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2019-01-11 21:52:43 +01:00
/* From http://developer.android.com/guide/practices/jni.html
* All threads are Linux threads , scheduled by the kernel .
* They ' re usually started from managed code ( using Thread . start ) , but they can also be created elsewhere and then
* attached to the JavaVM . For example , a thread started with pthread_create can be attached with the
* JNI AttachCurrentThread or AttachCurrentThreadAsDaemon functions . Until a thread is attached , it has no JNIEnv ,
* and cannot make JNI calls .
* Attaching a natively - created thread causes a java . lang . Thread object to be constructed and added to the " main "
* ThreadGroup , making it visible to the debugger . Calling AttachCurrentThread on an already - attached thread
* is a no - op .
* Note : You can call this function any number of times for the same thread , there ' s no harm in it
*/
/* From http://developer.android.com/guide/practices/jni.html
* Threads attached through JNI must call DetachCurrentThread before they exit . If coding this directly is awkward ,
* in Android 2.0 ( Eclair ) and higher you can use pthread_key_create to define a destructor function that will be
* called before the thread exits , and call DetachCurrentThread from there . ( Use that key with pthread_setspecific
* to store the JNIEnv in thread - local - storage ; that way it ' ll be passed into your destructor as the argument . )
* Note : The destructor is not called unless the stored value is ! = NULL
* Note : You can call this function any number of times for the same thread , there ' s no harm in it
* ( except for some lost CPU cycles )
*/
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Set local storage value
2024-08-22 17:33:49 -07:00
static bool Android_JNI_SetEnv ( JNIEnv * env )
2022-11-30 12:51:59 -08:00
{
2019-01-11 21:52:43 +01:00
int status = pthread_setspecific ( mThreadKey , env ) ;
if ( status < 0 ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d) " , status ) ;
2024-08-22 17:33:49 -07:00
return false ;
2019-01-11 21:52:43 +01:00
}
2024-08-22 17:33:49 -07:00
return true ;
2019-01-11 21:52:43 +01:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Get local storage value
2022-11-30 12:51:59 -08:00
JNIEnv * Android_JNI_GetEnv ( void )
2019-01-11 21:52:43 +01:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Get JNIEnv from the Thread local storage
2019-01-11 21:52:43 +01:00
JNIEnv * env = pthread_getspecific ( mThreadKey ) ;
2023-11-09 22:29:15 +01:00
if ( ! env ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread()
2019-01-20 22:11:56 +01:00
int status ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// There should be a JVM
2023-11-09 22:29:15 +01:00
if ( ! mJavaVM ) {
2019-01-20 22:11:56 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed, there is no JavaVM " ) ;
2019-01-20 22:17:41 +01:00
return NULL ;
2019-01-20 22:11:56 +01:00
}
/* Attach the current thread to the JVM and get a JNIEnv.
* It will be detached by pthread_create destructor ' Android_JNI_ThreadDestroyed ' */
status = ( * mJavaVM ) - > AttachCurrentThread ( mJavaVM , & env , NULL ) ;
if ( status < 0 ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed to attach current thread (err=%d) " , status ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Save JNIEnv into the Thread local storage
2024-08-22 17:33:49 -07:00
if ( ! Android_JNI_SetEnv ( env ) ) {
2019-01-20 22:11:56 +01:00
return NULL ;
}
2019-01-11 21:52:43 +01:00
}
return env ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Set up an external thread for using JNI with Android_JNI_GetEnv()
2024-08-22 17:33:49 -07:00
bool Android_JNI_SetupThread ( void )
2019-01-11 21:52:43 +01:00
{
JNIEnv * env ;
int status ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// There should be a JVM
2023-11-09 22:29:15 +01:00
if ( ! mJavaVM ) {
2019-01-11 21:52:43 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed, there is no JavaVM " ) ;
2024-08-22 17:33:49 -07:00
return false ;
2019-01-11 21:52:43 +01:00
}
/* Attach the current thread to the JVM and get a JNIEnv.
* It will be detached by pthread_create destructor ' Android_JNI_ThreadDestroyed ' */
status = ( * mJavaVM ) - > AttachCurrentThread ( mJavaVM , & env , NULL ) ;
if ( status < 0 ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed to attach current thread (err=%d) " , status ) ;
2024-08-22 17:33:49 -07:00
return false ;
2019-01-11 21:52:43 +01:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Save JNIEnv into the Thread local storage
2024-08-22 17:33:49 -07:00
if ( ! Android_JNI_SetEnv ( env ) ) {
return false ;
2019-01-11 21:52:43 +01:00
}
2024-08-22 17:33:49 -07:00
return true ;
2019-01-11 21:52:43 +01:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Destructor called for each thread where mThreadKey is not NULL
2022-11-30 12:51:59 -08:00
static void Android_JNI_ThreadDestroyed ( void * value )
2019-01-11 21:52:43 +01:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required
2022-11-30 12:51:59 -08:00
JNIEnv * env = ( JNIEnv * ) value ;
2023-11-09 22:29:15 +01:00
if ( env ) {
2019-01-11 21:52:43 +01:00
( * mJavaVM ) - > DetachCurrentThread ( mJavaVM ) ;
Android_JNI_SetEnv ( NULL ) ;
}
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Creation of local storage mThreadKey
2022-11-30 12:51:59 -08:00
static void Android_JNI_CreateKey ( void )
2019-01-11 15:27:53 +01:00
{
int status = pthread_key_create ( & mThreadKey , Android_JNI_ThreadDestroyed ) ;
if ( status < 0 ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Error initializing mThreadKey with pthread_key_create() (err=%d) " , status ) ;
}
}
2022-11-30 12:51:59 -08:00
static void Android_JNI_CreateKey_once ( void )
2019-01-11 15:27:53 +01:00
{
int status = pthread_once ( & key_once , Android_JNI_CreateKey ) ;
if ( status < 0 ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Error initializing mThreadKey with pthread_once() (err=%d) " , status ) ;
}
}
2022-11-30 12:51:59 -08:00
static void register_methods ( JNIEnv * env , const char * classname , JNINativeMethod * methods , int nb )
2019-12-12 18:38:36 +01:00
{
jclass clazz = ( * env ) - > FindClass ( env , classname ) ;
2023-11-09 22:29:15 +01:00
if ( ! clazz | | ( * env ) - > RegisterNatives ( env , clazz , methods , nb ) < 0 ) {
2019-12-12 18:38:36 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed to register methods of %s " , classname ) ;
return ;
}
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Library init
2019-01-03 13:14:16 +01:00
JNIEXPORT jint JNICALL JNI_OnLoad ( JavaVM * vm , void * reserved )
2015-06-21 17:33:46 +02:00
{
2019-12-12 18:38:36 +01:00
JNIEnv * env = NULL ;
2022-05-28 07:49:18 -07:00
mJavaVM = vm ;
2019-12-12 18:38:36 +01:00
if ( ( * mJavaVM ) - > GetEnv ( mJavaVM , ( void * * ) & env , JNI_VERSION_1_4 ) ! = JNI_OK ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " Failed to get JNI Env " ) ;
return JNI_VERSION_1_4 ;
}
2025-01-10 15:27:08 -08:00
register_methods ( env , " org/libsdl/app/SDLActivity " , SDLActivity_tab , SDL_arraysize ( SDLActivity_tab ) ) ;
2019-12-12 20:33:11 +01:00
register_methods ( env , " org/libsdl/app/SDLInputConnection " , SDLInputConnection_tab , SDL_arraysize ( SDLInputConnection_tab ) ) ;
register_methods ( env , " org/libsdl/app/SDLAudioManager " , SDLAudioManager_tab , SDL_arraysize ( SDLAudioManager_tab ) ) ;
register_methods ( env , " org/libsdl/app/SDLControllerManager " , SDLControllerManager_tab , SDL_arraysize ( SDLControllerManager_tab ) ) ;
2022-12-22 02:27:38 +01:00
register_methods ( env , " org/libsdl/app/HIDDeviceManager " , HIDDeviceManager_tab , SDL_arraysize ( HIDDeviceManager_tab ) ) ;
2019-12-12 18:38:36 +01:00
2015-06-21 17:33:46 +02:00
return JNI_VERSION_1_4 ;
}
2019-03-12 14:44:25 -07:00
void checkJNIReady ( void )
2017-09-22 08:30:46 -07:00
{
if ( ! mActivityClass | | ! mAudioManagerClass | | ! mControllerManagerClass ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// We aren't fully initialized, let's just return.
2017-09-22 08:30:46 -07:00
return ;
}
2018-12-30 15:41:28 +01:00
SDL_SetMainReady ( ) ;
2017-09-22 08:30:46 -07:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Get SDL version -- called before SDL_main() to verify JNI bindings
2022-10-03 17:36:17 -07:00
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE ( nativeGetVersion ) ( JNIEnv * env , jclass cls )
{
char version [ 128 ] ;
2024-05-14 07:47:13 -07:00
SDL_snprintf ( version , sizeof ( version ) , " %d.%d.%d " , SDL_MAJOR_VERSION , SDL_MINOR_VERSION , SDL_MICRO_VERSION ) ;
2022-10-03 17:36:17 -07:00
return ( * env ) - > NewStringUTF ( env , version ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Activity initialization -- called before SDL_main() to initialize JNI bindings
2019-01-11 15:36:16 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetupJNI ) ( JNIEnv * env , jclass cls )
2015-06-21 17:33:46 +02:00
{
2017-08-28 14:34:15 -07:00
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " nativeSetupJNI() " ) ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Start with a clean slate
2023-12-07 14:30:40 -08:00
SDL_ClearError ( ) ;
Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
Now, it simply gives back the JNI Env stored for the thread.
- Android_JNI_SetupThreadi() should only be used for external.
For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
and other thread are Java threads which don't need to be attached. i
(even if it doesn't hurt to do it, since it's a no-op).
- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
It's called for all shared libraries which may don't want this setup,
and loading libraries can be also modified to be done from a static context,
or with relinker. So it's not really clear how, who and what it sets up.
=> Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
/*
* Create mThreadKey so we can keep track of the JNIEnv assigned to each thread
* Refer to http : //developer.android.com/guide/practices/design/jni.html for the rationale behind this
*/
Android_JNI_CreateKey_once ( ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Save JNIEnv of SDLActivity
Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
Now, it simply gives back the JNI Env stored for the thread.
- Android_JNI_SetupThreadi() should only be used for external.
For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
and other thread are Java threads which don't need to be attached. i
(even if it doesn't hurt to do it, since it's a no-op).
- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
It's called for all shared libraries which may don't want this setup,
and loading libraries can be also modified to be done from a static context,
or with relinker. So it's not really clear how, who and what it sets up.
=> Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
Android_JNI_SetEnv ( env ) ;
2023-11-09 22:29:15 +01:00
if ( ! mJavaVM ) {
Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
Now, it simply gives back the JNI Env stored for the thread.
- Android_JNI_SetupThreadi() should only be used for external.
For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
and other thread are Java threads which don't need to be attached. i
(even if it doesn't hurt to do it, since it's a no-op).
- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
It's called for all shared libraries which may don't want this setup,
and loading libraries can be also modified to be done from a static context,
or with relinker. So it's not really clear how, who and what it sets up.
=> Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " failed to found a JavaVM " ) ;
}
2019-01-03 20:18:29 +01:00
/* Use a mutex to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
2019-01-03 14:18:06 +01:00
* ( Eg . Java sending Touch events , while native code is destroying the main SDL_Window . )
*/
2023-11-09 22:29:15 +01:00
if ( ! Android_ActivityMutex ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
Android_ActivityMutex = SDL_CreateMutex ( ) ; // Could this be created twice if onCreate() is called a second time ?
2019-01-03 14:18:06 +01:00
}
2023-11-09 22:29:15 +01:00
if ( ! Android_ActivityMutex ) {
2019-01-11 15:27:53 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " failed to create Android_ActivityMutex mutex " ) ;
2019-01-03 14:18:06 +01:00
}
2024-07-24 12:43:44 -07:00
Android_LifecycleMutex = SDL_CreateMutex ( ) ;
if ( ! Android_LifecycleMutex ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " failed to create Android_LifecycleMutex mutex " ) ;
2019-01-14 23:33:48 +01:00
}
2024-07-24 12:43:44 -07:00
Android_LifecycleEventSem = SDL_CreateSemaphore ( 0 ) ;
if ( ! Android_LifecycleEventSem ) {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " failed to create Android_LifecycleEventSem semaphore " ) ;
2019-01-14 23:33:48 +01:00
}
2019-01-11 15:36:16 +01:00
mActivityClass = ( jclass ) ( ( * env ) - > NewGlobalRef ( env , cls ) ) ;
2015-06-21 17:33:46 +02:00
2020-02-13 10:19:05 -08:00
midClipboardGetText = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " clipboardGetText " , " ()Ljava/lang/String; " ) ;
midClipboardHasText = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " clipboardHasText " , " ()Z " ) ;
midClipboardSetText = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " clipboardSetText " , " (Ljava/lang/String;)V " ) ;
2019-01-11 15:36:16 +01:00
midCreateCustomCursor = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " createCustomCursor " , " ([IIIII)I " ) ;
2021-12-21 22:07:17 +01:00
midDestroyCustomCursor = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " destroyCustomCursor " , " (I)V " ) ;
2022-11-30 12:51:59 -08:00
midGetContext = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " getContext " , " ()Landroid/content/Context; " ) ;
2020-02-13 10:19:05 -08:00
midGetManifestEnvironmentVariables = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " getManifestEnvironmentVariables " , " ()Z " ) ;
2022-11-30 12:51:59 -08:00
midGetNativeSurface = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " getNativeSurface " , " ()Landroid/view/Surface; " ) ;
2020-02-13 10:19:05 -08:00
midInitTouch = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " initTouch " , " ()V " ) ;
2022-11-30 12:51:59 -08:00
midIsAndroidTV = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " isAndroidTV " , " ()Z " ) ;
2020-02-13 10:19:05 -08:00
midIsChromebook = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " isChromebook " , " ()Z " ) ;
midIsDeXMode = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " isDeXMode " , " ()Z " ) ;
2022-11-30 12:51:59 -08:00
midIsScreenKeyboardShown = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " isScreenKeyboardShown " , " ()Z " ) ;
2020-02-13 10:19:05 -08:00
midIsTablet = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " isTablet " , " ()Z " ) ;
midManualBackButton = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " manualBackButton " , " ()V " ) ;
2022-11-30 12:51:59 -08:00
midMinimizeWindow = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " minimizeWindow " , " ()V " ) ;
2024-08-22 17:33:49 -07:00
midOpenURL = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " openURL " , " (Ljava/lang/String;)Z " ) ;
2020-02-13 10:19:05 -08:00
midRequestPermission = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " requestPermission " , " (Ljava/lang/String;I)V " ) ;
2024-08-22 17:33:49 -07:00
midShowToast = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " showToast " , " (Ljava/lang/String;IIII)Z " ) ;
2020-02-13 10:19:05 -08:00
midSendMessage = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " sendMessage " , " (II)Z " ) ;
2022-11-30 12:51:59 -08:00
midSetActivityTitle = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setActivityTitle " , " (Ljava/lang/String;)Z " ) ;
2019-01-11 15:36:16 +01:00
midSetCustomCursor = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setCustomCursor " , " (I)Z " ) ;
2022-11-30 12:51:59 -08:00
midSetOrientation = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setOrientation " , " (IIZLjava/lang/String;)V " ) ;
2020-02-13 10:19:05 -08:00
midSetRelativeMouseEnabled = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setRelativeMouseEnabled " , " (Z)Z " ) ;
2019-01-11 15:36:16 +01:00
midSetSystemCursor = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setSystemCursor " , " (I)Z " ) ;
2022-11-30 12:51:59 -08:00
midSetWindowStyle = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " setWindowStyle " , " (Z)V " ) ;
midShouldMinimizeOnFocusLoss = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " shouldMinimizeOnFocusLoss " , " ()Z " ) ;
2024-08-02 06:56:51 -07:00
midShowTextInput = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " showTextInput " , " (IIIII)Z " ) ;
2019-01-11 15:36:16 +01:00
midSupportsRelativeMouse = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " supportsRelativeMouse " , " ()Z " ) ;
2024-05-07 00:05:49 +08:00
midOpenFileDescriptor = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " openFileDescriptor " , " (Ljava/lang/String;Ljava/lang/String;)I " ) ;
2024-05-06 12:14:20 +08:00
midShowFileDialog = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " showFileDialog " , " ([Ljava/lang/String;ZZI)Z " ) ;
2025-05-20 18:09:28 -04:00
midGetPreferredLocales = ( * env ) - > GetStaticMethodID ( env , mActivityClass , " getPreferredLocales " , " ()Ljava/lang/String; " ) ;
2018-08-21 11:23:47 -07:00
2020-02-13 10:19:05 -08:00
if ( ! midClipboardGetText | |
! midClipboardHasText | |
! midClipboardSetText | |
! midCreateCustomCursor | |
2021-12-21 22:07:17 +01:00
! midDestroyCustomCursor | |
2020-02-13 10:19:05 -08:00
! midGetContext | |
! midGetManifestEnvironmentVariables | |
! midGetNativeSurface | |
! midInitTouch | |
! midIsAndroidTV | |
! midIsChromebook | |
! midIsDeXMode | |
! midIsScreenKeyboardShown | |
! midIsTablet | |
! midManualBackButton | |
! midMinimizeWindow | |
2020-10-01 14:41:09 +02:00
! midOpenURL | |
2020-02-13 10:19:05 -08:00
! midRequestPermission | |
2021-02-19 12:54:57 +03:00
! midShowToast | |
2020-02-13 10:19:05 -08:00
! midSendMessage | |
! midSetActivityTitle | |
! midSetCustomCursor | |
! midSetOrientation | |
! midSetRelativeMouseEnabled | |
! midSetSystemCursor | |
! midSetWindowStyle | |
! midShouldMinimizeOnFocusLoss | |
! midShowTextInput | |
2024-05-07 00:05:49 +08:00
! midSupportsRelativeMouse | |
2024-05-06 12:14:20 +08:00
! midOpenFileDescriptor | |
2025-05-20 18:09:28 -04:00
! midShowFileDialog | |
! midGetPreferredLocales ) {
2025-01-10 15:27:08 -08:00
__android_log_print ( ANDROID_LOG_WARN , " SDL " , " Missing some Java callbacks, do you have the latest version of SDLActivity.java? " ) ;
2015-06-21 17:33:46 +02:00
}
2017-08-12 12:24:59 -07:00
2017-09-22 08:30:46 -07:00
checkJNIReady ( ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Audio initialization -- called before SDL_main() to initialize JNI bindings
2019-01-11 15:36:16 +01:00
JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE ( nativeSetupJNI ) ( JNIEnv * env , jclass cls )
2017-09-22 08:30:46 -07:00
{
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " AUDIO nativeSetupJNI() " ) ;
2019-01-11 15:36:16 +01:00
mAudioManagerClass = ( jclass ) ( ( * env ) - > NewGlobalRef ( env , cls ) ) ;
2017-09-22 08:30:46 -07:00
2023-07-26 15:45:40 -04:00
midRegisterAudioDeviceCallback = ( * env ) - > GetStaticMethodID ( env , mAudioManagerClass ,
" registerAudioDeviceCallback " ,
" ()V " ) ;
midUnregisterAudioDeviceCallback = ( * env ) - > GetStaticMethodID ( env , mAudioManagerClass ,
" unregisterAudioDeviceCallback " ,
" ()V " ) ;
2019-01-11 15:36:16 +01:00
midAudioSetThreadPriority = ( * env ) - > GetStaticMethodID ( env , mAudioManagerClass ,
2022-11-30 12:51:59 -08:00
" audioSetThreadPriority " , " (ZI)V " ) ;
2017-09-22 08:30:46 -07:00
2024-07-29 08:05:36 -07:00
if ( ! midRegisterAudioDeviceCallback | | ! midUnregisterAudioDeviceCallback | | ! midAudioSetThreadPriority ) {
2022-12-16 17:38:57 +02:00
__android_log_print ( ANDROID_LOG_WARN , " SDL " ,
" Missing some Java callbacks, do you have the latest version of SDLAudioManager.java? " ) ;
2017-09-22 08:30:46 -07:00
}
checkJNIReady ( ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Controller initialization -- called before SDL_main() to initialize JNI bindings
2019-01-11 15:36:16 +01:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeSetupJNI ) ( JNIEnv * env , jclass cls )
2017-09-22 08:30:46 -07:00
{
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " CONTROLLER nativeSetupJNI() " ) ;
2019-01-11 15:36:16 +01:00
mControllerManagerClass = ( jclass ) ( ( * env ) - > NewGlobalRef ( env , cls ) ) ;
2017-09-22 08:30:46 -07:00
2019-01-11 15:36:16 +01:00
midPollInputDevices = ( * env ) - > GetStaticMethodID ( env , mControllerManagerClass ,
2022-11-30 12:51:59 -08:00
" pollInputDevices " , " ()V " ) ;
2019-01-11 15:36:16 +01:00
midPollHapticDevices = ( * env ) - > GetStaticMethodID ( env , mControllerManagerClass ,
2022-11-30 12:51:59 -08:00
" pollHapticDevices " , " ()V " ) ;
2019-01-11 15:36:16 +01:00
midHapticRun = ( * env ) - > GetStaticMethodID ( env , mControllerManagerClass ,
2022-11-30 12:51:59 -08:00
" hapticRun " , " (IFI)V " ) ;
2024-06-05 09:47:25 -07:00
midHapticRumble = ( * env ) - > GetStaticMethodID ( env , mControllerManagerClass ,
" hapticRumble " , " (IFFI)V " ) ;
2019-01-11 15:36:16 +01:00
midHapticStop = ( * env ) - > GetStaticMethodID ( env , mControllerManagerClass ,
2022-11-30 12:51:59 -08:00
" hapticStop " , " (I)V " ) ;
2017-09-22 08:30:46 -07:00
2024-06-05 09:47:25 -07:00
if ( ! midPollInputDevices | | ! midPollHapticDevices | | ! midHapticRun | | ! midHapticRumble | | ! midHapticStop ) {
2017-09-22 08:30:46 -07:00
__android_log_print ( ANDROID_LOG_WARN , " SDL " , " Missing some Java callbacks, do you have the latest version of SDLControllerManager.java? " ) ;
}
checkJNIReady ( ) ;
2017-08-28 14:34:15 -07:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// SDL main function prototype
2017-08-28 14:34:15 -07:00
typedef int ( * SDL_main_func ) ( int argc , char * argv [ ] ) ;
2023-06-09 09:41:54 +02:00
static int run_count = 0 ;
2025-04-03 10:35:50 -07:00
static bool allow_recreate_activity ;
static bool allow_recreate_activity_set ;
2023-06-09 09:41:54 +02:00
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE ( nativeCheckSDLThreadCounter ) (
JNIEnv * env , jclass jcls )
{
int tmp = run_count ;
run_count + = 1 ;
return tmp ;
}
2023-04-06 10:06:19 +02:00
2025-04-03 10:35:50 -07:00
void Android_SetAllowRecreateActivity ( bool enabled )
{
allow_recreate_activity = enabled ;
allow_recreate_activity_set = true ;
}
2023-04-05 21:54:36 +02:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( nativeAllowRecreateActivity ) (
JNIEnv * env , jclass jcls )
{
2025-04-03 10:35:50 -07:00
return allow_recreate_activity ;
2023-04-05 21:54:36 +02:00
}
2024-08-05 20:23:36 +09:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeInitMainThread ) (
2024-08-03 15:34:38 +02:00
JNIEnv * env , jclass jcls )
2017-08-28 14:34:15 -07:00
{
2024-08-03 15:34:38 +02:00
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " nativeInitSDLThread() %d time " , run_count ) ;
2023-04-06 10:06:19 +02:00
run_count + = 1 ;
2017-08-28 14:44:21 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Save JNIEnv of SDLThread
Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
Now, it simply gives back the JNI Env stored for the thread.
- Android_JNI_SetupThreadi() should only be used for external.
For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
and other thread are Java threads which don't need to be attached. i
(even if it doesn't hurt to do it, since it's a no-op).
- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
It's called for all shared libraries which may don't want this setup,
and loading libraries can be also modified to be done from a static context,
or with relinker. So it's not really clear how, who and what it sets up.
=> Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
Android_JNI_SetEnv ( env ) ;
2024-08-03 15:34:38 +02:00
}
2024-08-05 20:23:36 +09:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeCleanupMainThread ) (
2024-08-03 15:34:38 +02:00
JNIEnv * env , jclass jcls )
{
/* This is a Java thread, it doesn't need to be Detached from the JVM.
* Set to mThreadKey value to NULL not to call pthread_create destructor ' Android_JNI_ThreadDestroyed ' */
Android_JNI_SetEnv ( NULL ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Start up the SDL app
2024-08-03 15:34:38 +02:00
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE ( nativeRunMain ) ( JNIEnv * env , jclass cls , jstring library , jstring function , jobject array )
{
int status = - 1 ;
const char * library_file ;
void * library_handle ;
Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
Now, it simply gives back the JNI Env stored for the thread.
- Android_JNI_SetupThreadi() should only be used for external.
For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
and other thread are Java threads which don't need to be attached. i
(even if it doesn't hurt to do it, since it's a no-op).
- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
It's called for all shared libraries which may don't want this setup,
and loading libraries can be also modified to be done from a static context,
or with relinker. So it's not really clear how, who and what it sets up.
=> Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
2017-08-28 14:34:15 -07:00
library_file = ( * env ) - > GetStringUTFChars ( env , library , NULL ) ;
library_handle = dlopen ( library_file , RTLD_GLOBAL ) ;
2019-07-27 20:21:42 +02:00
2022-11-27 17:38:43 +01:00
if ( library_handle = = NULL ) {
2019-07-27 20:21:42 +02:00
/* When deploying android app bundle format uncompressed native libs may not extract from apk to filesystem.
In this case we should use lib name without path . https : //bugzilla.libsdl.org/show_bug.cgi?id=4739 */
const char * library_name = SDL_strrchr ( library_file , ' / ' ) ;
if ( library_name & & * library_name ) {
library_name + = 1 ;
library_handle = dlopen ( library_name , RTLD_GLOBAL ) ;
}
}
2017-08-28 14:34:15 -07:00
if ( library_handle ) {
const char * function_name ;
SDL_main_func SDL_main ;
function_name = ( * env ) - > GetStringUTFChars ( env , function , NULL ) ;
SDL_main = ( SDL_main_func ) dlsym ( library_handle , function_name ) ;
if ( SDL_main ) {
int i ;
int argc ;
int len ;
char * * argv ;
2024-08-22 09:21:26 -07:00
bool isstack ;
2017-08-28 14:34:15 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Prepare the arguments.
2017-08-28 14:34:15 -07:00
len = ( * env ) - > GetArrayLength ( env , array ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
argv = SDL_small_alloc ( char * , 1 + len + 1 , & isstack ) ; // !!! FIXME: check for NULL
2017-08-28 14:34:15 -07:00
argc = 0 ;
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
2024-02-26 11:28:11 -05:00
https : //github.com/love2d/love-android/issues/24
2017-08-28 14:34:15 -07:00
*/
argv [ argc + + ] = SDL_strdup ( " app_process " ) ;
for ( i = 0 ; i < len ; + + i ) {
2019-01-03 13:14:16 +01:00
char * arg = NULL ;
2017-08-28 14:34:15 -07:00
jstring string = ( * env ) - > GetObjectArrayElement ( env , array , i ) ;
if ( string ) {
2023-02-15 21:29:01 +01:00
const char * utf = ( * env ) - > GetStringUTFChars ( env , string , 0 ) ;
2017-08-28 14:34:15 -07:00
if ( utf ) {
arg = SDL_strdup ( utf ) ;
( * env ) - > ReleaseStringUTFChars ( env , string , utf ) ;
}
( * env ) - > DeleteLocalRef ( env , string ) ;
}
2022-11-27 17:38:43 +01:00
if ( arg = = NULL ) {
2017-08-28 14:34:15 -07:00
arg = SDL_strdup ( " " ) ;
}
argv [ argc + + ] = arg ;
}
argv [ argc ] = NULL ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Run the application.
2017-08-28 14:34:15 -07:00
status = SDL_main ( argc , argv ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Release the arguments.
2017-08-28 14:34:15 -07:00
for ( i = 0 ; i < argc ; + + i ) {
SDL_free ( argv [ i ] ) ;
}
2018-10-22 20:50:32 -04:00
SDL_small_free ( argv , isstack ) ;
2017-08-28 14:34:15 -07:00
} else {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " nativeRunMain(): Couldn't find function %s in library %s " , function_name , library_file ) ;
}
( * env ) - > ReleaseStringUTFChars ( env , function , function_name ) ;
dlclose ( library_handle ) ;
} else {
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " nativeRunMain(): Couldn't load library %s " , library_file ) ;
2017-08-12 12:24:59 -07:00
}
2017-08-28 14:34:15 -07:00
( * env ) - > ReleaseStringUTFChars ( env , library , library_file ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Do not issue an exit or the whole application will terminate instead of just the SDL thread
// exit(status);
2017-08-12 12:24:59 -07:00
2017-08-28 14:34:15 -07:00
return status ;
2015-06-21 17:33:46 +02:00
}
2024-07-24 12:43:44 -07:00
static int FindLifecycleEvent ( SDL_AndroidLifecycleEvent event )
2015-06-21 17:33:46 +02:00
{
2024-07-24 12:43:44 -07:00
for ( int index = 0 ; index < Android_NumLifecycleEvents ; + + index ) {
if ( Android_LifecycleEvents [ index ] = = event ) {
return index ;
}
}
return - 1 ;
2015-06-21 17:33:46 +02:00
}
2024-07-24 12:43:44 -07:00
static void RemoveLifecycleEvent ( int index )
2022-11-30 12:51:59 -08:00
{
2024-07-24 12:43:44 -07:00
if ( index < Android_NumLifecycleEvents - 1 ) {
2025-01-14 14:31:20 -08:00
SDL_memmove ( & Android_LifecycleEvents [ index ] , & Android_LifecycleEvents [ index + 1 ] , ( Android_NumLifecycleEvents - index - 1 ) * sizeof ( Android_LifecycleEvents [ index ] ) ) ;
2024-07-24 12:43:44 -07:00
}
- - Android_NumLifecycleEvents ;
2019-06-24 18:08:11 +02:00
}
2024-07-24 12:43:44 -07:00
void Android_SendLifecycleEvent ( SDL_AndroidLifecycleEvent event )
2022-11-30 12:51:59 -08:00
{
2024-07-24 12:43:44 -07:00
SDL_LockMutex ( Android_LifecycleMutex ) ;
{
int index ;
2024-08-22 09:21:26 -07:00
bool add_event = true ;
2024-07-24 12:43:44 -07:00
switch ( event ) {
case SDL_ANDROID_LIFECYCLE_WAKE :
// We don't need more than one wake queued
index = FindLifecycleEvent ( SDL_ANDROID_LIFECYCLE_WAKE ) ;
if ( index > = 0 ) {
2024-08-22 09:21:26 -07:00
add_event = false ;
2024-07-24 12:43:44 -07:00
}
break ;
case SDL_ANDROID_LIFECYCLE_PAUSE :
// If we have a resume queued, just stay in the paused state
index = FindLifecycleEvent ( SDL_ANDROID_LIFECYCLE_RESUME ) ;
if ( index > = 0 ) {
RemoveLifecycleEvent ( index ) ;
2024-08-22 09:21:26 -07:00
add_event = false ;
2024-07-24 12:43:44 -07:00
}
break ;
case SDL_ANDROID_LIFECYCLE_RESUME :
// If we have a pause queued, just stay in the resumed state
index = FindLifecycleEvent ( SDL_ANDROID_LIFECYCLE_PAUSE ) ;
if ( index > = 0 ) {
RemoveLifecycleEvent ( index ) ;
2024-08-22 09:21:26 -07:00
add_event = false ;
2024-07-24 12:43:44 -07:00
}
break ;
case SDL_ANDROID_LIFECYCLE_LOWMEMORY :
// We don't need more than one low memory event queued
index = FindLifecycleEvent ( SDL_ANDROID_LIFECYCLE_LOWMEMORY ) ;
if ( index > = 0 ) {
2024-08-22 09:21:26 -07:00
add_event = false ;
2024-07-24 12:43:44 -07:00
}
break ;
case SDL_ANDROID_LIFECYCLE_DESTROY :
// Remove all other events, we're done!
while ( Android_NumLifecycleEvents > 0 ) {
RemoveLifecycleEvent ( 0 ) ;
}
break ;
default :
SDL_assert ( ! " Sending unexpected lifecycle event " ) ;
2024-08-22 09:21:26 -07:00
add_event = false ;
2024-07-24 12:43:44 -07:00
break ;
}
if ( add_event ) {
SDL_assert ( Android_NumLifecycleEvents < SDL_arraysize ( Android_LifecycleEvents ) ) ;
Android_LifecycleEvents [ Android_NumLifecycleEvents + + ] = event ;
SDL_SignalSemaphore ( Android_LifecycleEventSem ) ;
}
}
SDL_UnlockMutex ( Android_LifecycleMutex ) ;
2019-06-24 18:08:11 +02:00
}
2024-08-22 09:21:26 -07:00
bool Android_WaitLifecycleEvent ( SDL_AndroidLifecycleEvent * event , Sint64 timeoutNS )
2022-11-30 12:51:59 -08:00
{
2024-08-22 09:21:26 -07:00
bool got_event = false ;
2024-07-24 12:43:44 -07:00
2024-08-22 17:33:49 -07:00
while ( ! got_event & & SDL_WaitSemaphoreTimeoutNS ( Android_LifecycleEventSem , timeoutNS ) ) {
2024-07-24 12:43:44 -07:00
SDL_LockMutex ( Android_LifecycleMutex ) ;
{
if ( Android_NumLifecycleEvents > 0 ) {
* event = Android_LifecycleEvents [ 0 ] ;
RemoveLifecycleEvent ( 0 ) ;
2024-08-22 09:21:26 -07:00
got_event = true ;
2024-07-24 12:43:44 -07:00
}
}
SDL_UnlockMutex ( Android_LifecycleMutex ) ;
}
return got_event ;
}
2019-06-28 16:38:42 +02:00
2024-07-24 12:43:44 -07:00
void Android_LockActivityMutex ( void )
{
2019-06-28 16:38:42 +02:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2024-07-24 12:43:44 -07:00
}
2019-06-28 16:38:42 +02:00
2024-07-24 12:43:44 -07:00
void Android_UnlockActivityMutex ( void )
{
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
2019-06-28 16:38:42 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Drop file
2024-07-24 12:43:44 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeDropFile ) (
JNIEnv * env , jclass jcls ,
jstring filename )
{
const char * path = ( * env ) - > GetStringUTFChars ( env , filename , NULL ) ;
SDL_SendDropFile ( NULL , NULL , path ) ;
( * env ) - > ReleaseStringUTFChars ( env , filename , path ) ;
SDL_SendDropComplete ( NULL ) ;
2019-06-28 16:38:42 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Set screen resolution
2019-01-17 11:05:05 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetScreenResolution ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint surfaceWidth , jint surfaceHeight ,
2023-01-25 14:55:50 +01:00
jint deviceWidth , jint deviceHeight , jfloat density , jfloat rate )
2015-06-21 17:33:46 +02:00
{
2019-01-03 20:18:29 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2019-01-03 14:18:06 +01:00
2023-01-25 14:55:50 +01:00
Android_SetScreenResolution ( surfaceWidth , surfaceHeight , deviceWidth , deviceHeight , density , rate ) ;
2019-01-17 11:05:05 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Resize
2019-01-17 11:05:05 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeResize ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls )
2019-01-17 11:05:05 +01:00
{
SDL_LockMutex ( Android_ActivityMutex ) ;
2022-11-27 17:38:43 +01:00
if ( Android_Window ) {
2019-06-18 10:23:19 +02:00
Android_SendResize ( Android_Window ) ;
2019-01-17 11:05:05 +01:00
}
2019-01-03 14:18:06 +01:00
2019-01-03 20:18:29 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
2023-06-17 00:52:40 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetNaturalOrientation ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint orientation )
2023-06-17 00:52:40 -07:00
{
displayNaturalOrientation = ( SDL_DisplayOrientation ) orientation ;
}
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeRotationChanged ) (
JNIEnv * env , jclass jcls ,
jint rotation )
2018-08-23 14:05:25 -07:00
{
2019-01-16 10:48:28 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2023-06-17 00:52:40 -07:00
if ( displayNaturalOrientation = = SDL_ORIENTATION_LANDSCAPE ) {
rotation + = 90 ;
}
switch ( rotation % 360 ) {
case 0 :
displayCurrentOrientation = SDL_ORIENTATION_PORTRAIT ;
break ;
case 90 :
displayCurrentOrientation = SDL_ORIENTATION_LANDSCAPE ;
break ;
case 180 :
displayCurrentOrientation = SDL_ORIENTATION_PORTRAIT_FLIPPED ;
break ;
case 270 :
displayCurrentOrientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED ;
break ;
default :
displayCurrentOrientation = SDL_ORIENTATION_UNKNOWN ;
break ;
}
2019-03-13 09:39:30 +01:00
2024-12-30 15:49:10 -08:00
Android_SetOrientation ( displayCurrentOrientation ) ;
2019-01-16 10:48:28 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2018-08-23 14:05:25 -07:00
}
2024-07-22 18:59:53 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeInsetsChanged ) (
JNIEnv * env , jclass jcls ,
jint left , jint right , jint top , jint bottom )
{
SDL_LockMutex ( Android_ActivityMutex ) ;
2024-12-30 12:23:00 -08:00
Android_SetWindowSafeAreaInsets ( left , right , top , bottom ) ;
2024-07-22 18:59:53 -07:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
2019-01-10 21:40:57 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeAddTouch ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jint touchId , jstring name )
2019-01-10 21:40:57 +01:00
{
const char * utfname = ( * env ) - > GetStringUTFChars ( env , name , NULL ) ;
2022-11-30 12:51:59 -08:00
SDL_AddTouch ( ( SDL_TouchID ) touchId , SDL_TOUCH_DEVICE_DIRECT , utfname ) ;
2019-01-10 21:40:57 +01:00
( * env ) - > ReleaseStringUTFChars ( env , name , utfname ) ;
}
2022-12-16 17:38:57 +02:00
JNIEXPORT void JNICALL
2025-03-23 17:14:21 +01:00
SDL_JAVA_AUDIO_INTERFACE ( nativeAddAudioDevice ) ( JNIEnv * env , jclass jcls , jboolean recording ,
2023-07-26 15:45:40 -04:00
jstring name , jint device_id )
2022-12-18 12:07:38 +01:00
{
2023-09-30 16:33:30 -04:00
# if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
2023-07-29 19:43:24 -04:00
if ( SDL_GetCurrentAudioDriver ( ) ! = NULL ) {
void * handle = ( void * ) ( ( size_t ) device_id ) ;
if ( ! SDL_FindPhysicalAudioDeviceByHandle ( handle ) ) {
const char * utf8name = ( * env ) - > GetStringUTFChars ( env , name , NULL ) ;
2024-06-14 17:57:14 -04:00
SDL_AddAudioDevice ( recording , SDL_strdup ( utf8name ) , NULL , handle ) ;
2023-07-29 19:43:24 -04:00
( * env ) - > ReleaseStringUTFChars ( env , name , utf8name ) ;
}
}
2023-09-30 16:33:30 -04:00
# endif
2022-12-16 17:38:57 +02:00
}
JNIEXPORT void JNICALL
2025-03-23 17:14:21 +01:00
SDL_JAVA_AUDIO_INTERFACE ( nativeRemoveAudioDevice ) ( JNIEnv * env , jclass jcls , jboolean recording ,
2022-12-18 12:07:38 +01:00
jint device_id )
{
2023-09-30 16:33:30 -04:00
# if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
2022-12-19 17:02:10 +02:00
if ( SDL_GetCurrentAudioDriver ( ) ! = NULL ) {
2024-06-14 17:57:14 -04:00
SDL_Log ( " Removing device with handle %d, recording %d " , device_id , recording ) ;
2023-07-26 15:45:40 -04:00
SDL_AudioDeviceDisconnected ( SDL_FindPhysicalAudioDeviceByHandle ( ( void * ) ( ( size_t ) device_id ) ) ) ;
2022-12-19 17:02:10 +02:00
}
2023-09-30 16:33:30 -04:00
# endif
2022-12-16 17:38:57 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Paddown
2024-08-22 17:33:49 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadDown ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint keycode )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2023-06-22 23:30:41 +02:00
return Android_OnPadDown ( device_id , keycode ) ;
2024-06-08 16:55:15 +01:00
# else
2024-08-22 17:33:49 -07:00
return false ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Padup
2024-08-22 17:33:49 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativePadUp ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint keycode )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2023-06-22 23:30:41 +02:00
return Android_OnPadUp ( device_id , keycode ) ;
2024-06-08 16:55:15 +01:00
# else
2024-08-22 17:33:49 -07:00
return false ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Joy
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativeJoy ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint axis , jfloat value )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2023-06-22 23:30:41 +02:00
Android_OnJoy ( device_id , axis , value ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// POV Hat
2017-09-22 08:30:46 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( onNativeHat ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jint hat_id , jint x , jint y )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2023-06-22 23:30:41 +02:00
Android_OnHat ( device_id , hat_id , x , y ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddJoystick ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id , jstring device_name , jstring device_desc ,
2024-02-11 09:25:16 -08:00
jint vendor_id , jint product_id ,
2024-06-05 09:47:25 -07:00
jint button_mask , jint naxes , jint axis_mask , jint nhats , jboolean can_rumble )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
const char * name = ( * env ) - > GetStringUTFChars ( env , device_name , NULL ) ;
2017-08-28 10:03:39 -07:00
const char * desc = ( * env ) - > GetStringUTFChars ( env , device_desc , NULL ) ;
2015-06-21 17:33:46 +02:00
2024-08-22 17:33:49 -07:00
Android_AddJoystick ( device_id , name , desc , vendor_id , product_id , button_mask , naxes , axis_mask , nhats , can_rumble ) ;
2015-06-21 17:33:46 +02:00
( * env ) - > ReleaseStringUTFChars ( env , device_name , name ) ;
2017-08-28 10:03:39 -07:00
( * env ) - > ReleaseStringUTFChars ( env , device_desc , desc ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveJoystick ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint device_id )
2015-06-21 17:33:46 +02:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_JOYSTICK_ANDROID
2024-08-22 17:33:49 -07:00
Android_RemoveJoystick ( device_id ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_JOYSTICK_ANDROID
2015-06-21 17:33:46 +02:00
}
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeAddHaptic ) (
2019-01-03 13:14:16 +01:00
JNIEnv * env , jclass jcls , jint device_id , jstring device_name )
2017-08-12 08:15:09 -07:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_HAPTIC_ANDROID
2017-08-12 08:15:09 -07:00
const char * name = ( * env ) - > GetStringUTFChars ( env , device_name , NULL ) ;
2024-08-22 17:33:49 -07:00
Android_AddHaptic ( device_id , name ) ;
2017-08-12 08:15:09 -07:00
( * env ) - > ReleaseStringUTFChars ( env , device_name , name ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_HAPTIC_ANDROID
2017-08-12 08:15:09 -07:00
}
2024-08-22 17:33:49 -07:00
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE ( nativeRemoveHaptic ) (
2019-01-03 13:14:16 +01:00
JNIEnv * env , jclass jcls , jint device_id )
2017-08-12 08:15:09 -07:00
{
2024-06-08 16:55:15 +01:00
# ifdef SDL_HAPTIC_ANDROID
2024-08-22 17:33:49 -07:00
Android_RemoveHaptic ( device_id ) ;
2024-06-08 16:55:15 +01:00
# endif
2017-08-12 08:15:09 -07:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Called from surfaceCreated()
2019-01-09 22:41:52 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceCreated ) ( JNIEnv * env , jclass jcls )
{
SDL_LockMutex ( Android_ActivityMutex ) ;
2022-11-27 17:38:43 +01:00
if ( Android_Window ) {
2024-07-16 11:09:18 -07:00
SDL_WindowData * data = Android_Window - > internal ;
2019-01-09 22:41:52 +01:00
data - > native_window = Android_JNI_GetNativeWindow ( ) ;
2024-07-31 02:00:43 +10:00
SDL_SetPointerProperty ( SDL_GetWindowProperties ( Android_Window ) , SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER , data - > native_window ) ;
2019-01-09 22:41:52 +01:00
if ( data - > native_window = = NULL ) {
SDL_SetError ( " Could not fetch native window from UI thread " ) ;
}
}
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Called from surfaceChanged()
2019-01-03 13:14:16 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceChanged ) ( JNIEnv * env , jclass jcls )
2015-06-21 17:33:46 +02:00
{
2019-01-03 20:18:29 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2019-01-03 14:18:06 +01:00
2023-03-29 21:49:01 +00:00
# ifdef SDL_VIDEO_OPENGL_EGL
2024-07-31 12:28:13 +10:00
if ( Android_Window & & ( Android_Window - > flags & SDL_WINDOW_OPENGL ) ) {
2019-01-03 13:14:16 +01:00
SDL_VideoDevice * _this = SDL_GetVideoDevice ( ) ;
2024-07-16 11:09:18 -07:00
SDL_WindowData * data = Android_Window - > internal ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here
2019-01-03 13:14:16 +01:00
if ( data - > egl_surface = = EGL_NO_SURFACE ) {
2023-03-11 13:53:14 +01:00
data - > egl_surface = SDL_EGL_CreateSurface ( _this , Android_Window , ( NativeWindowType ) data - > native_window ) ;
2024-07-31 02:00:43 +10:00
SDL_SetPointerProperty ( SDL_GetWindowProperties ( Android_Window ) , SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER , data - > egl_surface ) ;
2015-06-21 17:33:46 +02:00
}
2017-08-14 14:14:45 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// GL Context handling is done in the event loop because this function is run from the Java thread
2019-01-03 13:14:16 +01:00
}
2022-03-11 15:14:51 +01:00
# endif
2019-01-03 14:18:06 +01:00
2019-01-03 20:18:29 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Called from surfaceDestroyed()
2019-01-03 13:14:16 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeSurfaceDestroyed ) ( JNIEnv * env , jclass jcls )
2015-06-21 17:33:46 +02:00
{
Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).
Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.
It prevents crashes like:
#00 pc 000000000000c0d0 /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
#01 pc 000000000000c7f4 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
#02 pc 000000000000c390 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
#03 pc 000000000000bb10 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
#04 pc 000000000032732c /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
#05 pc 0000000000326dd0 /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
#06 pc 00000000002ae484 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
#07 pc 0000000000249680 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
#08 pc 00000000002cb52c /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
int nb_attempt = 50 ;
retry :
2019-01-03 20:18:29 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2019-01-03 14:18:06 +01:00
2022-11-27 17:38:43 +01:00
if ( Android_Window ) {
2024-07-16 11:09:18 -07:00
SDL_WindowData * data = Android_Window - > internal ;
2017-08-14 14:14:45 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Wait for Main thread being paused and context un-activated to release 'egl_surface'
2024-07-31 12:28:13 +10:00
if ( ( Android_Window - > flags & SDL_WINDOW_OPENGL ) & & ! data - > backup_done ) {
Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).
Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.
It prevents crashes like:
#00 pc 000000000000c0d0 /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
#01 pc 000000000000c7f4 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
#02 pc 000000000000c390 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
#03 pc 000000000000bb10 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
#04 pc 000000000032732c /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
#05 pc 0000000000326dd0 /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
#06 pc 00000000002ae484 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
#07 pc 0000000000249680 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
#08 pc 00000000002cb52c /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
nb_attempt - = 1 ;
if ( nb_attempt = = 0 ) {
SDL_SetError ( " Try to release egl_surface with context probably still active " ) ;
} else {
SDL_UnlockMutex ( Android_ActivityMutex ) ;
SDL_Delay ( 10 ) ;
goto retry ;
}
}
2017-08-14 14:14:45 -07:00
2023-03-29 21:49:01 +00:00
# ifdef SDL_VIDEO_OPENGL_EGL
2019-01-03 13:14:16 +01:00
if ( data - > egl_surface ! = EGL_NO_SURFACE ) {
2023-08-05 00:25:12 -07:00
SDL_EGL_DestroySurface ( SDL_GetVideoDevice ( ) , data - > egl_surface ) ;
2019-01-03 13:14:16 +01:00
data - > egl_surface = EGL_NO_SURFACE ;
}
2022-03-11 15:14:51 +01:00
# endif
2017-08-14 14:14:45 -07:00
2019-01-09 22:41:52 +01:00
if ( data - > native_window ) {
ANativeWindow_release ( data - > native_window ) ;
Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).
Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.
It prevents crashes like:
#00 pc 000000000000c0d0 /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
#01 pc 000000000000c7f4 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
#02 pc 000000000000c390 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
#03 pc 000000000000bb10 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
#04 pc 000000000032732c /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
#05 pc 0000000000326dd0 /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
#06 pc 00000000002ae484 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
#07 pc 0000000000249680 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
#08 pc 00000000002cb52c /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
data - > native_window = NULL ;
2019-01-09 22:41:52 +01:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// GL Context handling is done in the event loop because this function is run from the Java thread
2015-06-21 17:33:46 +02:00
}
2019-01-03 14:18:06 +01:00
2019-01-03 20:18:29 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Keydown
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyDown ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint keycode )
2015-06-21 17:33:46 +02:00
{
2023-06-16 10:05:58 +02:00
SDL_LockMutex ( Android_ActivityMutex ) ;
if ( Android_Window ) {
Android_OnKeyDown ( keycode ) ;
}
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Keyup
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyUp ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint keycode )
2015-06-21 17:33:46 +02:00
{
2023-06-16 10:05:58 +02:00
SDL_LockMutex ( Android_ActivityMutex ) ;
if ( Android_Window ) {
Android_OnKeyUp ( keycode ) ;
}
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Virtual keyboard return key might stop text input
2019-05-23 11:05:43 -07:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( onNativeSoftReturnKey ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls )
2019-05-23 11:05:43 -07:00
{
2024-08-22 09:21:26 -07:00
if ( SDL_GetHintBoolean ( SDL_HINT_RETURN_KEY_HIDES_IME , false ) ) {
2024-06-22 06:16:19 -07:00
SDL_StopTextInput ( Android_Window ) ;
2019-05-23 11:05:43 -07:00
return JNI_TRUE ;
}
return JNI_FALSE ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Keyboard Focus Lost
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeKeyboardFocusLost ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls )
2015-06-21 17:33:46 +02:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget
2024-06-22 06:16:19 -07:00
SDL_StopTextInput ( Android_Window ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Touch
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeTouch ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint touch_device_id_in , jint pointer_finger_id_in ,
jint action , jfloat x , jfloat y , jfloat p )
2015-06-21 17:33:46 +02:00
{
2019-01-03 20:18:29 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2019-01-03 14:18:06 +01:00
2019-01-03 13:14:16 +01:00
Android_OnTouch ( Android_Window , touch_device_id_in , pointer_finger_id_in , action , x , y , p ) ;
2019-01-03 14:18:06 +01:00
2019-01-03 20:18:29 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Mouse
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeMouse ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jint button , jint action , jfloat x , jfloat y , jboolean relative )
2015-06-21 17:33:46 +02:00
{
2019-01-03 20:18:29 +01:00
SDL_LockMutex ( Android_ActivityMutex ) ;
2019-01-03 14:18:06 +01:00
2019-01-03 13:14:16 +01:00
Android_OnMouse ( Android_Window , button , action , x , y , relative ) ;
2019-01-03 14:18:06 +01:00
2019-01-03 20:18:29 +01:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2015-06-21 17:33:46 +02:00
}
2024-11-12 22:58:39 +09:00
// Pen
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativePen ) (
JNIEnv * env , jclass jcls ,
jint pen_id_in , jint button , jint action , jfloat x , jfloat y , jfloat p )
{
SDL_LockMutex ( Android_ActivityMutex ) ;
Android_OnPen ( Android_Window , pen_id_in , button , action , x , y , p ) ;
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Accelerometer
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeAccel ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls ,
jfloat x , jfloat y , jfloat z )
2015-06-21 17:33:46 +02:00
{
fLastAccelerometer [ 0 ] = x ;
fLastAccelerometer [ 1 ] = y ;
fLastAccelerometer [ 2 ] = z ;
2024-08-22 09:21:26 -07:00
bHasNewData = true ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Clipboard
2017-08-27 18:43:52 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeClipboardChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass jcls )
2017-08-27 18:43:52 -07:00
{
2024-10-02 21:19:42 +02:00
// TODO: compute new mime types
SDL_SendClipboardUpdate ( false , NULL , 0 ) ;
2017-08-27 18:43:52 -07:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Low memory
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeLowMemory ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2015-06-21 17:33:46 +02:00
{
2024-07-24 12:43:44 -07:00
Android_SendLifecycleEvent ( SDL_ANDROID_LIFECYCLE_LOWMEMORY ) ;
2015-06-21 17:33:46 +02:00
}
2020-05-08 21:40:28 +02:00
/* Locale
* requires android : configChanges = " layoutDirection|locale " in AndroidManifest . xml */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeLocaleChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2020-05-08 21:40:28 +02:00
{
2023-01-23 17:54:09 -08:00
SDL_SendAppEvent ( SDL_EVENT_LOCALE_CHANGED ) ;
2020-05-08 21:40:28 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Dark mode
2023-03-07 00:01:34 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeDarkModeChanged ) (
JNIEnv * env , jclass cls , jboolean enabled )
{
Android_SetDarkMode ( enabled ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Send Quit event to "SDLThread" thread
2019-01-10 15:35:46 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSendQuit ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2015-06-21 17:33:46 +02:00
{
2024-07-24 12:43:44 -07:00
Android_SendLifecycleEvent ( SDL_ANDROID_LIFECYCLE_DESTROY ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Activity ends
2019-01-10 15:43:07 +01:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeQuit ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2019-01-10 15:43:07 +01:00
{
const char * str ;
if ( Android_ActivityMutex ) {
SDL_DestroyMutex ( Android_ActivityMutex ) ;
Android_ActivityMutex = NULL ;
}
2024-07-24 12:43:44 -07:00
if ( Android_LifecycleMutex ) {
SDL_DestroyMutex ( Android_LifecycleMutex ) ;
Android_LifecycleMutex = NULL ;
2019-01-14 23:33:48 +01:00
}
2024-07-24 12:43:44 -07:00
if ( Android_LifecycleEventSem ) {
SDL_DestroySemaphore ( Android_LifecycleEventSem ) ;
Android_LifecycleEventSem = NULL ;
2019-01-14 23:33:48 +01:00
}
2024-07-24 12:43:44 -07:00
Android_NumLifecycleEvents = 0 ;
2020-05-08 11:00:51 +02:00
Internal_Android_Destroy_AssetManager ( ) ;
2019-01-10 15:43:07 +01:00
str = SDL_GetError ( ) ;
if ( str & & str [ 0 ] ) {
2019-01-11 21:52:43 +01:00
__android_log_print ( ANDROID_LOG_ERROR , " SDL " , " SDLActivity thread ends (error=%s) " , str ) ;
2019-01-10 15:43:07 +01:00
} else {
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " SDLActivity thread ends " ) ;
}
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Pause
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativePause ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2015-06-21 17:33:46 +02:00
{
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " nativePause() " ) ;
2017-08-28 14:34:15 -07:00
2024-07-24 12:43:44 -07:00
Android_SendLifecycleEvent ( SDL_ANDROID_LIFECYCLE_PAUSE ) ;
2015-06-21 17:33:46 +02:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Resume
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeResume ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls )
2015-06-21 17:33:46 +02:00
{
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " nativeResume() " ) ;
2024-07-24 12:43:44 -07:00
Android_SendLifecycleEvent ( SDL_ANDROID_LIFECYCLE_RESUME ) ;
2015-06-21 17:33:46 +02:00
}
Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC
Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.
- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.
- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.
So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.
I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634
So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeFocusChanged ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls , jboolean hasFocus )
Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC
Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.
- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.
- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.
So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.
I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634
So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
{
SDL_LockMutex ( Android_ActivityMutex ) ;
if ( Android_Window ) {
__android_log_print ( ANDROID_LOG_VERBOSE , " SDL " , " nativeFocusChanged() " ) ;
2023-01-23 17:54:09 -08:00
SDL_SendWindowEvent ( Android_Window , ( hasFocus ? SDL_EVENT_WINDOW_FOCUS_GAINED : SDL_EVENT_WINDOW_FOCUS_LOST ) , 0 , 0 ) ;
Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).
Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.
It prevents crashes like:
#00 pc 000000000000c0d0 /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
#01 pc 000000000000c7f4 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
#02 pc 000000000000c390 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
#03 pc 000000000000bb10 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
#04 pc 000000000032732c /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
#05 pc 0000000000326dd0 /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
#06 pc 00000000002ae484 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
#07 pc 0000000000249680 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
#08 pc 00000000002cb52c /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
}
Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC
Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.
- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.
- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.
So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.
I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634
So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
2016-12-02 02:25:12 -08:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeCommitText ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring text , jint newCursorPosition )
2015-06-21 17:33:46 +02:00
{
const char * utftext = ( * env ) - > GetStringUTFChars ( env , text , NULL ) ;
SDL_SendKeyboardText ( utftext ) ;
( * env ) - > ReleaseStringUTFChars ( env , text , utftext ) ;
}
2017-10-26 10:41:38 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION ( nativeGenerateScancodeForUnichar ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jchar chUnicode )
2017-10-26 10:41:38 -07:00
{
2022-12-02 09:03:13 -08:00
SDL_SendKeyboardUnicodeKey ( 0 , chUnicode ) ;
2017-10-26 10:41:38 -07:00
}
2016-12-02 02:25:12 -08:00
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE ( nativeGetHint ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name )
2016-12-02 02:25:12 -08:00
{
2015-06-21 17:33:46 +02:00
const char * utfname = ( * env ) - > GetStringUTFChars ( env , name , NULL ) ;
const char * hint = SDL_GetHint ( utfname ) ;
jstring result = ( * env ) - > NewStringUTF ( env , hint ) ;
( * env ) - > ReleaseStringUTFChars ( env , name , utfname ) ;
return result ;
}
2021-11-15 16:52:54 -08:00
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE ( nativeGetHintBoolean ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name , jboolean default_value )
2021-11-15 16:52:54 -08:00
{
jboolean result ;
const char * utfname = ( * env ) - > GetStringUTFChars ( env , name , NULL ) ;
result = SDL_GetHintBoolean ( utfname , default_value ) ;
( * env ) - > ReleaseStringUTFChars ( env , name , utfname ) ;
return result ;
}
2017-11-04 09:37:29 -07:00
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativeSetenv ) (
2022-11-30 12:51:59 -08:00
JNIEnv * env , jclass cls ,
jstring name , jstring value )
2017-11-04 09:37:29 -07:00
{
const char * utfname = ( * env ) - > GetStringUTFChars ( env , name , NULL ) ;
const char * utfvalue = ( * env ) - > GetStringUTFChars ( env , value , NULL ) ;
2024-09-13 17:00:15 -07:00
// This is only called at startup, to initialize the environment
2024-09-20 11:09:48 -07:00
// Note that we call setenv() directly to avoid affecting SDL environments
2024-09-25 21:56:16 +02:00
setenv ( utfname , utfvalue , 1 ) ; // This should NOT be SDL_setenv()
2017-11-04 09:37:29 -07:00
2025-04-03 10:35:50 -07:00
if ( SDL_strcmp ( utfname , SDL_HINT_ANDROID_ALLOW_RECREATE_ACTIVITY ) = = 0 ) {
// Special handling for this hint, which needs to persist outside the normal application flow
// Only set this the first time we run, in case it's been set by the application via SDL_SetHint()
if ( ! allow_recreate_activity_set ) {
Android_SetAllowRecreateActivity ( SDL_GetStringBoolean ( utfvalue , false ) ) ;
}
}
2017-11-04 09:37:29 -07:00
( * env ) - > ReleaseStringUTFChars ( env , name , utfname ) ;
( * env ) - > ReleaseStringUTFChars ( env , value , utfvalue ) ;
}
2015-06-21 17:33:46 +02:00
/*******************************************************************************
Functions called by SDL into Java
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2023-02-23 20:33:51 +01:00
static SDL_AtomicInt s_active ;
2015-06-21 17:33:46 +02:00
struct LocalReferenceHolder
{
JNIEnv * m_env ;
const char * m_func ;
} ;
static struct LocalReferenceHolder LocalReferenceHolder_Setup ( const char * func )
{
struct LocalReferenceHolder refholder ;
refholder . m_env = NULL ;
refholder . m_func = func ;
# ifdef DEBUG_JNI
SDL_Log ( " Entering function %s " , func ) ;
# endif
return refholder ;
}
2024-08-22 09:21:26 -07:00
static bool LocalReferenceHolder_Init ( struct LocalReferenceHolder * refholder , JNIEnv * env )
2015-06-21 17:33:46 +02:00
{
const int capacity = 16 ;
if ( ( * env ) - > PushLocalFrame ( env , capacity ) < 0 ) {
SDL_SetError ( " Failed to allocate enough JVM local references " ) ;
2024-08-22 09:21:26 -07:00
return false ;
2015-06-21 17:33:46 +02:00
}
2019-04-05 08:15:01 -07:00
SDL_AtomicIncRef ( & s_active ) ;
2015-06-21 17:33:46 +02:00
refholder - > m_env = env ;
2024-08-22 09:21:26 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
static void LocalReferenceHolder_Cleanup ( struct LocalReferenceHolder * refholder )
{
# ifdef DEBUG_JNI
SDL_Log ( " Leaving function %s " , refholder - > m_func ) ;
# endif
if ( refholder - > m_env ) {
2019-01-03 13:14:16 +01:00
JNIEnv * env = refholder - > m_env ;
2015-06-21 17:33:46 +02:00
( * env ) - > PopLocalFrame ( env , NULL ) ;
2019-04-05 08:15:01 -07:00
SDL_AtomicDecRef ( & s_active ) ;
2015-06-21 17:33:46 +02:00
}
}
2022-11-30 12:51:59 -08:00
ANativeWindow * Android_JNI_GetNativeWindow ( void )
2015-06-21 17:33:46 +02:00
{
2018-12-30 22:44:25 +01:00
ANativeWindow * anw = NULL ;
2015-06-21 17:33:46 +02:00
jobject s ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
s = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetNativeSurface ) ;
2018-12-30 22:44:25 +01:00
if ( s ) {
anw = ANativeWindow_fromSurface ( env , s ) ;
( * env ) - > DeleteLocalRef ( env , s ) ;
}
2017-08-14 14:14:45 -07:00
2015-06-21 17:33:46 +02:00
return anw ;
}
void Android_JNI_SetActivityTitle ( const char * title )
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-08-14 14:14:45 -07:00
2019-10-31 15:53:10 +01:00
jstring jtitle = ( * env ) - > NewStringUTF ( env , title ) ;
2019-01-11 15:36:16 +01:00
( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSetActivityTitle , jtitle ) ;
( * env ) - > DeleteLocalRef ( env , jtitle ) ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 09:21:26 -07:00
void Android_JNI_SetWindowStyle ( bool fullscreen )
2018-02-11 18:23:37 -08:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midSetWindowStyle , fullscreen ? 1 : 0 ) ;
2018-02-11 18:23:37 -08:00
}
2017-08-13 20:55:59 -07:00
void Android_JNI_SetOrientation ( int w , int h , int resizable , const char * hint )
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-08-14 14:14:45 -07:00
2019-10-31 15:53:10 +01:00
jstring jhint = ( * env ) - > NewStringUTF ( env , ( hint ? hint : " " ) ) ;
2022-11-30 12:51:59 -08:00
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midSetOrientation , w , h , ( resizable ? 1 : 0 ) , jhint ) ;
2019-01-11 15:36:16 +01:00
( * env ) - > DeleteLocalRef ( env , jhint ) ;
2017-08-13 20:55:59 -07:00
}
2024-07-29 08:05:36 -07:00
SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation ( void )
{
return displayNaturalOrientation ;
}
SDL_DisplayOrientation Android_JNI_GetDisplayCurrentOrientation ( void )
{
return displayCurrentOrientation ;
}
2025-07-27 10:39:20 -04:00
void Android_JNI_MinimizeWindow ( void )
2019-06-10 21:58:03 +02:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midMinimizeWindow ) ;
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_ShouldMinimizeOnFocusLoss ( void )
2019-06-10 21:58:03 +02:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midShouldMinimizeOnFocusLoss ) ;
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_GetAccelerometerValues ( float values [ 3 ] )
2015-06-21 17:33:46 +02:00
{
2024-08-22 17:33:49 -07:00
bool result = false ;
2015-06-21 17:33:46 +02:00
if ( bHasNewData ) {
2023-02-15 21:29:01 +01:00
int i ;
2015-06-21 17:33:46 +02:00
for ( i = 0 ; i < 3 ; + + i ) {
values [ i ] = fLastAccelerometer [ i ] ;
}
2024-08-22 09:21:26 -07:00
bHasNewData = false ;
2024-08-22 17:33:49 -07:00
result = true ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 17:33:49 -07:00
return result ;
2015-06-21 17:33:46 +02:00
}
/*
* Audio support
*/
2024-06-14 17:57:14 -04:00
void Android_StartAudioHotplug ( SDL_AudioDevice * * default_playback , SDL_AudioDevice * * default_recording )
2022-12-18 12:07:38 +01:00
{
2022-12-16 17:38:57 +02:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2023-07-26 15:45:40 -04:00
// this will fire the callback for each existing device right away (which will eventually SDL_AddAudioDevice), and again later when things change.
2023-07-27 18:13:01 -04:00
( * env ) - > CallStaticVoidMethod ( env , mAudioManagerClass , midRegisterAudioDeviceCallback ) ;
2024-06-14 17:57:14 -04:00
* default_playback = * default_recording = NULL ; // !!! FIXME: how do you decide the default device id?
2022-12-16 17:38:57 +02:00
}
2023-07-26 15:45:40 -04:00
void Android_StopAudioHotplug ( void )
2022-12-18 12:07:38 +01:00
{
2023-07-26 15:45:40 -04:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2023-07-27 18:13:01 -04:00
( * env ) - > CallStaticVoidMethod ( env , mAudioManagerClass , midUnregisterAudioDeviceCallback ) ;
2022-12-16 17:38:57 +02:00
}
2024-06-14 17:57:14 -04:00
static void Android_JNI_AudioSetThreadPriority ( int recording , int device_id )
2019-01-10 18:05:56 +01:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2024-06-14 17:57:14 -04:00
( * env ) - > CallStaticVoidMethod ( env , mAudioManagerClass , midAudioSetThreadPriority , recording , device_id ) ;
2019-01-10 18:05:56 +01:00
}
2023-07-26 15:45:40 -04:00
void Android_AudioThreadInit ( SDL_AudioDevice * device )
{
2024-06-14 17:57:14 -04:00
Android_JNI_AudioSetThreadPriority ( ( int ) device - > recording , ( int ) device - > instance_id ) ;
2023-07-26 15:45:40 -04:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Test for an exception and call SDL_SetError with its detail if one occurs
// If the parameter silent is truthy then SDL_SetError() will not be called.
2024-08-22 09:21:26 -07:00
static bool Android_JNI_ExceptionOccurred ( bool silent )
2015-06-21 17:33:46 +02:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2016-02-09 17:36:42 -08:00
jthrowable exception ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Detect mismatch LocalReferenceHolder_Init/Cleanup
2024-09-16 23:21:31 -07:00
SDL_assert ( SDL_GetAtomicInt ( & s_active ) > 0 ) ;
2015-06-21 17:33:46 +02:00
2019-01-11 15:36:16 +01:00
exception = ( * env ) - > ExceptionOccurred ( env ) ;
2015-06-21 17:33:46 +02:00
if ( exception ! = NULL ) {
jmethodID mid ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Until this happens most JNI operations have undefined behaviour
2019-01-11 15:36:16 +01:00
( * env ) - > ExceptionClear ( env ) ;
2015-06-21 17:33:46 +02:00
if ( ! silent ) {
2019-01-11 15:36:16 +01:00
jclass exceptionClass = ( * env ) - > GetObjectClass ( env , exception ) ;
jclass classClass = ( * env ) - > FindClass ( env , " java/lang/Class " ) ;
2016-02-09 17:36:42 -08:00
jstring exceptionName ;
2019-01-03 13:14:16 +01:00
const char * exceptionNameUTF8 ;
2016-02-09 17:36:42 -08:00
jstring exceptionMessage ;
2015-06-21 17:33:46 +02:00
2019-01-11 15:36:16 +01:00
mid = ( * env ) - > GetMethodID ( env , classClass , " getName " , " ()Ljava/lang/String; " ) ;
exceptionName = ( jstring ) ( * env ) - > CallObjectMethod ( env , exceptionClass , mid ) ;
exceptionNameUTF8 = ( * env ) - > GetStringUTFChars ( env , exceptionName , 0 ) ;
2015-06-21 17:33:46 +02:00
2019-01-11 15:36:16 +01:00
mid = ( * env ) - > GetMethodID ( env , exceptionClass , " getMessage " , " ()Ljava/lang/String; " ) ;
exceptionMessage = ( jstring ) ( * env ) - > CallObjectMethod ( env , exception , mid ) ;
2015-06-21 17:33:46 +02:00
if ( exceptionMessage ! = NULL ) {
2019-01-11 15:36:16 +01:00
const char * exceptionMessageUTF8 = ( * env ) - > GetStringUTFChars ( env , exceptionMessage , 0 ) ;
2015-06-21 17:33:46 +02:00
SDL_SetError ( " %s: %s " , exceptionNameUTF8 , exceptionMessageUTF8 ) ;
2019-01-11 15:36:16 +01:00
( * env ) - > ReleaseStringUTFChars ( env , exceptionMessage , exceptionMessageUTF8 ) ;
2015-06-21 17:33:46 +02:00
} else {
SDL_SetError ( " %s " , exceptionNameUTF8 ) ;
}
2019-01-11 15:36:16 +01:00
( * env ) - > ReleaseStringUTFChars ( env , exceptionName , exceptionNameUTF8 ) ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 09:21:26 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 09:21:26 -07:00
return false ;
2015-06-21 17:33:46 +02:00
}
2024-07-17 22:09:32 +04:00
static void Internal_Android_Create_AssetManager ( void )
2022-11-30 12:51:59 -08:00
{
2020-05-08 11:00:51 +02:00
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jmethodID mid ;
jobject context ;
jobject javaAssetManager ;
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2020-05-08 11:00:51 +02:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// javaAssetManager = context.getAssets();
2020-05-08 11:00:51 +02:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , context ) ,
2022-11-30 12:51:59 -08:00
" getAssets " , " ()Landroid/content/res/AssetManager; " ) ;
2020-05-08 11:00:51 +02:00
javaAssetManager = ( * env ) - > CallObjectMethod ( env , context , mid ) ;
/**
* Given a Dalvik AssetManager object , obtain the corresponding native AAssetManager
* object . Note that the caller is responsible for obtaining and holding a VM reference
* to the jobject to prevent its being garbage collected while the native object is
* in use .
*/
javaAssetManagerRef = ( * env ) - > NewGlobalRef ( env , javaAssetManager ) ;
asset_manager = AAssetManager_fromJava ( env , javaAssetManagerRef ) ;
2023-11-09 22:29:15 +01:00
if ( ! asset_manager ) {
2020-05-08 11:00:51 +02:00
( * env ) - > DeleteGlobalRef ( env , javaAssetManagerRef ) ;
2024-08-22 09:21:26 -07:00
Android_JNI_ExceptionOccurred ( true ) ;
2020-05-08 11:00:51 +02:00
}
LocalReferenceHolder_Cleanup ( & refs ) ;
}
2024-07-17 22:09:32 +04:00
static void Internal_Android_Destroy_AssetManager ( void )
2022-11-30 12:51:59 -08:00
{
2020-05-08 11:00:51 +02:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
if ( asset_manager ) {
( * env ) - > DeleteGlobalRef ( env , javaAssetManagerRef ) ;
asset_manager = NULL ;
}
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_FileOpen ( void * * puserdata , const char * fileName , const char * mode )
2015-06-21 17:33:46 +02:00
{
2024-03-12 01:14:38 -04:00
SDL_assert ( puserdata ! = NULL ) ;
2020-08-17 19:50:20 +02:00
AAsset * asset = NULL ;
2024-03-12 01:14:38 -04:00
* puserdata = NULL ;
2015-06-21 17:33:46 +02:00
2023-11-09 22:29:15 +01:00
if ( ! asset_manager ) {
2020-08-17 19:50:20 +02:00
Internal_Android_Create_AssetManager ( ) ;
}
2023-11-09 22:29:15 +01:00
if ( ! asset_manager ) {
2023-10-23 08:27:24 -07:00
return SDL_SetError ( " Couldn't create asset manager " ) ;
2015-06-21 17:33:46 +02:00
}
2020-08-17 19:50:20 +02:00
asset = AAssetManager_open ( asset_manager , fileName , AASSET_MODE_UNKNOWN ) ;
2023-11-09 22:29:15 +01:00
if ( ! asset ) {
2023-10-23 08:27:24 -07:00
return SDL_SetError ( " Couldn't open asset '%s' " , fileName ) ;
2015-06-21 17:33:46 +02:00
}
2024-03-12 01:14:38 -04:00
* puserdata = ( void * ) asset ;
2024-08-22 17:33:49 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
2024-03-14 19:35:02 -04:00
size_t Android_JNI_FileRead ( void * userdata , void * buffer , size_t size , SDL_IOStatus * status )
2015-06-21 17:33:46 +02:00
{
2024-03-12 01:14:38 -04:00
const int bytes = AAsset_read ( ( AAsset * ) userdata , buffer , size ) ;
2023-08-06 13:51:03 -07:00
if ( bytes < 0 ) {
SDL_SetError ( " AAsset_read() failed " ) ;
return 0 ;
}
return ( size_t ) bytes ;
2015-06-21 17:33:46 +02:00
}
2024-03-14 19:35:02 -04:00
size_t Android_JNI_FileWrite ( void * userdata , const void * buffer , size_t size , SDL_IOStatus * status )
2015-06-21 17:33:46 +02:00
{
2024-08-22 17:33:49 -07:00
SDL_SetError ( " Cannot write to Android package filesystem " ) ;
return 0 ;
2015-06-21 17:33:46 +02:00
}
2024-03-12 01:14:38 -04:00
Sint64 Android_JNI_FileSize ( void * userdata )
2015-06-21 17:33:46 +02:00
{
2024-03-12 01:14:38 -04:00
return ( Sint64 ) AAsset_getLength64 ( ( AAsset * ) userdata ) ;
2015-06-21 17:33:46 +02:00
}
2024-06-09 08:26:29 -07:00
Sint64 Android_JNI_FileSeek ( void * userdata , Sint64 offset , SDL_IOWhence whence )
2015-06-21 17:33:46 +02:00
{
2024-06-09 08:26:29 -07:00
return ( Sint64 ) AAsset_seek64 ( ( AAsset * ) userdata , offset , ( int ) whence ) ;
2015-06-21 17:33:46 +02:00
}
2024-09-18 07:52:28 -07:00
bool Android_JNI_FileClose ( void * userdata )
2015-06-21 17:33:46 +02:00
{
2024-03-12 01:14:38 -04:00
AAsset_close ( ( AAsset * ) userdata ) ;
2024-08-22 17:33:49 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
2025-07-11 14:16:18 -04:00
bool Android_JNI_EnumerateAssetDirectory ( const char * path , SDL_EnumerateDirectoryCallback cb , void * userdata )
{
2025-08-04 19:51:37 +03:00
SDL_assert ( path ! = NULL ) ;
2025-07-11 14:16:18 -04:00
if ( ! asset_manager ) {
Internal_Android_Create_AssetManager ( ) ;
if ( ! asset_manager ) {
return SDL_SetError ( " Couldn't create asset manager " ) ;
}
}
AAssetDir * adir = AAssetManager_openDir ( asset_manager , path ) ;
if ( ! adir ) {
return SDL_SetError ( " AAssetManager_openDir failed " ) ;
}
SDL_EnumerationResult result = SDL_ENUM_CONTINUE ;
const char * ent ;
while ( ( result = = SDL_ENUM_CONTINUE ) & & ( ( ent = AAssetDir_getNextFileName ( adir ) ) ! = NULL ) ) {
result = cb ( userdata , path , ent ) ;
}
AAssetDir_close ( adir ) ;
return ( result ! = SDL_ENUM_FAILURE ) ;
}
bool Android_JNI_GetAssetPathInfo ( const char * path , SDL_PathInfo * info )
{
if ( ! asset_manager ) {
Internal_Android_Create_AssetManager ( ) ;
if ( ! asset_manager ) {
return SDL_SetError ( " Couldn't create asset manager " ) ;
}
}
// this is sort of messy, but there isn't a stat()-like interface to the Assets.
AAsset * aasset = AAssetManager_open ( asset_manager , path , AASSET_MODE_UNKNOWN ) ;
if ( aasset ) { // it's a file!
info - > type = SDL_PATHTYPE_FILE ;
info - > size = ( Uint64 ) AAsset_getLength64 ( aasset ) ;
AAsset_close ( aasset ) ;
return true ;
}
2025-07-29 12:14:04 -04:00
AAssetDir * adir = AAssetManager_openDir ( asset_manager , path ) ;
if ( adir ) { // This does _not_ return NULL for a missing directory! Treat empty directories as missing. Better than nothing. :/
const bool contains_something = ( AAssetDir_getNextFileName ( adir ) ! = NULL ) ; // if not NULL, there are files in this directory, so it's _definitely_ a directory.
AAssetDir_close ( adir ) ;
if ( contains_something ) {
info - > type = SDL_PATHTYPE_DIRECTORY ;
info - > size = 0 ;
return true ;
}
}
2025-07-11 14:16:18 -04:00
return SDL_SetError ( " Couldn't open asset '%s' " , path ) ;
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_SetClipboardText ( const char * text )
2015-06-21 17:33:46 +02:00
{
2019-01-03 13:14:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-08-27 18:43:52 -07:00
jstring string = ( * env ) - > NewStringUTF ( env , text ) ;
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midClipboardSetText , string ) ;
( * env ) - > DeleteLocalRef ( env , string ) ;
2024-08-22 17:33:49 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
2022-11-30 12:51:59 -08:00
char * Android_JNI_GetClipboardText ( void )
2015-06-21 17:33:46 +02:00
{
2019-01-03 13:14:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
char * text = NULL ;
2017-08-27 18:43:52 -07:00
jstring string ;
2018-12-30 15:41:28 +01:00
2017-08-27 18:43:52 -07:00
string = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midClipboardGetText ) ;
if ( string ) {
2019-01-03 13:14:16 +01:00
const char * utf = ( * env ) - > GetStringUTFChars ( env , string , 0 ) ;
2017-08-27 18:43:52 -07:00
if ( utf ) {
text = SDL_strdup ( utf ) ;
( * env ) - > ReleaseStringUTFChars ( env , string , utf ) ;
2015-06-21 17:33:46 +02:00
}
2017-08-27 18:43:52 -07:00
( * env ) - > DeleteLocalRef ( env , string ) ;
2015-06-21 17:33:46 +02:00
}
2018-12-30 15:41:28 +01:00
2023-11-09 22:29:15 +01:00
return ( ! text ) ? SDL_strdup ( " " ) : text ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_HasClipboardText ( void )
2015-06-21 17:33:46 +02:00
{
2019-01-03 13:14:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2023-11-03 09:27:29 -07:00
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midClipboardHasText ) ;
2015-06-21 17:33:46 +02:00
}
/* returns 0 on success or -1 on error (others undefined then)
* returns truthy or falsy value in plugged , charged and battery
* returns the value in seconds and percent or - 1 if not available
*/
2019-01-03 13:14:16 +01:00
int Android_JNI_GetPowerInfo ( int * plugged , int * charged , int * battery , int * seconds , int * percent )
2015-06-21 17:33:46 +02:00
{
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
2019-01-03 13:14:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2016-02-09 17:36:42 -08:00
jmethodID mid ;
jobject context ;
jstring action ;
jclass cls ;
jobject filter ;
jobject intent ;
jstring iname ;
jmethodID imid ;
jstring bname ;
jmethodID bmid ;
2015-06-21 17:33:46 +02:00
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return - 1 ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2017-08-14 14:14:45 -07:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
2015-06-21 17:33:46 +02:00
2016-02-09 17:36:42 -08:00
action = ( * env ) - > NewStringUTF ( env , " android.intent.action.BATTERY_CHANGED " ) ;
2015-06-21 17:33:46 +02:00
2016-02-09 17:36:42 -08:00
cls = ( * env ) - > FindClass ( env , " android/content/IntentFilter " ) ;
2015-06-21 17:33:46 +02:00
mid = ( * env ) - > GetMethodID ( env , cls , " <init> " , " (Ljava/lang/String;)V " ) ;
2016-02-09 17:36:42 -08:00
filter = ( * env ) - > NewObject ( env , cls , mid , action ) ;
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , action ) ;
mid = ( * env ) - > GetMethodID ( env , mActivityClass , " registerReceiver " , " (Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent; " ) ;
2016-02-09 17:36:42 -08:00
intent = ( * env ) - > CallObjectMethod ( env , context , mid , NULL , filter ) ;
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , filter ) ;
cls = ( * env ) - > GetObjectClass ( env , intent ) ;
2016-02-09 17:36:42 -08:00
imid = ( * env ) - > GetMethodID ( env , cls , " getIntExtra " , " (Ljava/lang/String;I)I " ) ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
2022-11-30 12:51:59 -08:00
# define GET_INT_EXTRA(var, key) \
int var ; \
iname = ( * env ) - > NewStringUTF ( env , key ) ; \
2019-12-12 20:33:11 +01:00
( var ) = ( * env ) - > CallIntMethod ( env , intent , imid , iname , - 1 ) ; \
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , iname ) ;
2016-02-09 17:36:42 -08:00
bmid = ( * env ) - > GetMethodID ( env , cls , " getBooleanExtra " , " (Ljava/lang/String;Z)Z " ) ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
2022-11-30 12:51:59 -08:00
# define GET_BOOL_EXTRA(var, key) \
int var ; \
bname = ( * env ) - > NewStringUTF ( env , key ) ; \
2019-12-12 20:33:11 +01:00
( var ) = ( * env ) - > CallBooleanMethod ( env , intent , bmid , bname , JNI_FALSE ) ; \
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , bname ) ;
if ( plugged ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
GET_INT_EXTRA ( plug , " plugged " ) // == BatteryManager.EXTRA_PLUGGED (API 5)
2015-06-21 17:33:46 +02:00
if ( plug = = - 1 ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return - 1 ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// 1 == BatteryManager.BATTERY_PLUGGED_AC
// 2 == BatteryManager.BATTERY_PLUGGED_USB
2015-06-21 17:33:46 +02:00
* plugged = ( 0 < plug ) ? 1 : 0 ;
}
if ( charged ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
GET_INT_EXTRA ( status , " status " ) // == BatteryManager.EXTRA_STATUS (API 5)
2015-06-21 17:33:46 +02:00
if ( status = = - 1 ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return - 1 ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// 5 == BatteryManager.BATTERY_STATUS_FULL
2015-06-21 17:33:46 +02:00
* charged = ( status = = 5 ) ? 1 : 0 ;
}
if ( battery ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
GET_BOOL_EXTRA ( present , " present " ) // == BatteryManager.EXTRA_PRESENT (API 5)
2015-06-21 17:33:46 +02:00
* battery = present ? 1 : 0 ;
}
if ( seconds ) {
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
* seconds = - 1 ; // not possible
2015-06-21 17:33:46 +02:00
}
if ( percent ) {
2016-02-09 17:36:42 -08:00
int level ;
int scale ;
2017-08-14 14:14:45 -07:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
2016-02-09 17:36:42 -08:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
GET_INT_EXTRA ( level_temp , " level " ) // == BatteryManager.EXTRA_LEVEL (API 5)
2016-02-09 17:36:42 -08:00
level = level_temp ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Watch out for C89 scoping rules because of the macro
2016-02-09 17:36:42 -08:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
GET_INT_EXTRA ( scale_temp , " scale " ) // == BatteryManager.EXTRA_SCALE (API 5)
2016-02-09 17:36:42 -08:00
scale = scale_temp ;
}
2017-08-14 14:14:45 -07:00
2015-06-21 17:33:46 +02:00
if ( ( level = = - 1 ) | | ( scale = = - 1 ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return - 1 ;
}
* percent = level * 100 / scale ;
}
( * env ) - > DeleteLocalRef ( env , intent ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
return 0 ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Add all touch devices
2024-07-17 22:09:32 +04:00
void Android_JNI_InitTouch ( void )
2022-11-30 12:51:59 -08:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2019-01-10 21:40:57 +01:00
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midInitTouch ) ;
2015-06-21 17:33:46 +02:00
}
void Android_JNI_PollInputDevices ( void )
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-09-22 08:30:46 -07:00
( * env ) - > CallStaticVoidMethod ( env , mControllerManagerClass , midPollInputDevices ) ;
2015-06-21 17:33:46 +02:00
}
2017-08-12 08:15:09 -07:00
void Android_JNI_PollHapticDevices ( void )
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-09-22 08:30:46 -07:00
( * env ) - > CallStaticVoidMethod ( env , mControllerManagerClass , midPollHapticDevices ) ;
2017-08-12 08:15:09 -07:00
}
2017-08-14 14:14:45 -07:00
2018-10-16 08:29:27 -07:00
void Android_JNI_HapticRun ( int device_id , float intensity , int length )
2017-08-12 08:15:09 -07:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2018-10-16 08:29:27 -07:00
( * env ) - > CallStaticVoidMethod ( env , mControllerManagerClass , midHapticRun , device_id , intensity , length ) ;
2024-06-05 09:47:25 -07:00
}
void Android_JNI_HapticRumble ( int device_id , float low_frequency_intensity , float high_frequency_intensity , int length )
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
( * env ) - > CallStaticVoidMethod ( env , mControllerManagerClass , midHapticRumble , device_id , low_frequency_intensity , high_frequency_intensity , length ) ;
2017-08-12 08:15:09 -07:00
}
2018-08-24 10:41:57 -07:00
void Android_JNI_HapticStop ( int device_id )
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
( * env ) - > CallStaticVoidMethod ( env , mControllerManagerClass , midHapticStop , device_id ) ;
}
2017-08-12 08:15:09 -07:00
2025-01-10 15:27:08 -08:00
// See SDLActivity.java for constants.
2022-11-30 12:51:59 -08:00
# define COMMAND_SET_KEEP_SCREEN_ON 5
2022-02-01 11:30:43 +01:00
2024-09-18 07:52:28 -07:00
bool SDL_SendAndroidMessage ( Uint32 command , int param )
2022-02-01 11:30:43 +01:00
{
2024-08-22 17:33:49 -07:00
if ( command < 0x8000 ) {
return SDL_InvalidParamError ( " command " ) ;
2022-02-01 11:30:43 +01:00
}
2024-08-22 17:33:49 -07:00
return Android_JNI_SendMessage ( command , param ) ;
2022-02-01 11:30:43 +01:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// sends message to be handled on the UI event dispatch thread
2024-08-22 17:33:49 -07:00
bool Android_JNI_SendMessage ( int command , int param )
2015-06-21 17:33:46 +02:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2024-08-22 17:33:49 -07:00
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSendMessage , command , param ) ;
2015-06-21 17:33:46 +02:00
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_SuspendScreenSaver ( bool suspend )
2015-06-21 17:33:46 +02:00
{
2024-08-22 09:21:26 -07:00
return Android_JNI_SendMessage ( COMMAND_SET_KEEP_SCREEN_ON , ( suspend = = false ) ? 0 : 1 ) ;
2015-06-21 17:33:46 +02:00
}
2024-08-02 06:56:51 -07:00
void Android_JNI_ShowScreenKeyboard ( int input_type , SDL_Rect * inputRect )
2015-06-21 17:33:46 +02:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-08-14 14:14:45 -07:00
( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midShowTextInput ,
2024-08-02 06:56:51 -07:00
input_type ,
2022-11-30 12:51:59 -08:00
inputRect - > x ,
inputRect - > y ,
inputRect - > w ,
inputRect - > h ) ;
2015-06-21 17:33:46 +02:00
}
2024-01-06 08:11:22 -08:00
void Android_JNI_HideScreenKeyboard ( void )
2015-06-21 17:33:46 +02:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// has to match Activity constant
2015-06-21 17:33:46 +02:00
const int COMMAND_TEXTEDIT_HIDE = 3 ;
Android_JNI_SendMessage ( COMMAND_TEXTEDIT_HIDE , 0 ) ;
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_IsScreenKeyboardShown ( void )
2017-08-13 21:05:15 -07:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2017-08-14 14:14:45 -07:00
jboolean is_shown = 0 ;
2019-01-11 15:36:16 +01:00
is_shown = ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midIsScreenKeyboardShown ) ;
2017-08-13 21:05:15 -07:00
return is_shown ;
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_ShowMessageBox ( const SDL_MessageBoxData * messageboxdata , int * buttonID )
2015-06-21 17:33:46 +02:00
{
JNIEnv * env ;
jclass clazz ;
jmethodID mid ;
jobject context ;
jstring title ;
jstring message ;
jintArray button_flags ;
jintArray button_ids ;
jobjectArray button_texts ;
jintArray colors ;
jobject text ;
jint temp ;
int i ;
env = Android_JNI_GetEnv ( ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// convert parameters
2015-06-21 17:33:46 +02:00
clazz = ( * env ) - > FindClass ( env , " java/lang/String " ) ;
title = ( * env ) - > NewStringUTF ( env , messageboxdata - > title ) ;
message = ( * env ) - > NewStringUTF ( env , messageboxdata - > message ) ;
button_flags = ( * env ) - > NewIntArray ( env , messageboxdata - > numbuttons ) ;
button_ids = ( * env ) - > NewIntArray ( env , messageboxdata - > numbuttons ) ;
button_texts = ( * env ) - > NewObjectArray ( env , messageboxdata - > numbuttons ,
2022-11-30 12:51:59 -08:00
clazz , NULL ) ;
2015-06-21 17:33:46 +02:00
for ( i = 0 ; i < messageboxdata - > numbuttons ; + + i ) {
2019-08-02 17:19:50 -07:00
const SDL_MessageBoxButtonData * sdlButton ;
if ( messageboxdata - > flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT ) {
sdlButton = & messageboxdata - > buttons [ messageboxdata - > numbuttons - 1 - i ] ;
} else {
sdlButton = & messageboxdata - > buttons [ i ] ;
}
temp = sdlButton - > flags ;
2015-06-21 17:33:46 +02:00
( * env ) - > SetIntArrayRegion ( env , button_flags , i , 1 , & temp ) ;
2024-02-11 08:03:26 -08:00
temp = sdlButton - > buttonID ;
2015-06-21 17:33:46 +02:00
( * env ) - > SetIntArrayRegion ( env , button_ids , i , 1 , & temp ) ;
2019-08-02 17:19:50 -07:00
text = ( * env ) - > NewStringUTF ( env , sdlButton - > text ) ;
2015-06-21 17:33:46 +02:00
( * env ) - > SetObjectArrayElement ( env , button_texts , i , text ) ;
( * env ) - > DeleteLocalRef ( env , text ) ;
}
if ( messageboxdata - > colorScheme ) {
2024-09-11 08:08:18 -07:00
colors = ( * env ) - > NewIntArray ( env , SDL_MESSAGEBOX_COLOR_COUNT ) ;
for ( i = 0 ; i < SDL_MESSAGEBOX_COLOR_COUNT ; + + i ) {
2019-08-30 11:35:20 +03:00
temp = ( 0xFFU < < 24 ) |
2015-06-21 17:33:46 +02:00
( messageboxdata - > colorScheme - > colors [ i ] . r < < 16 ) |
( messageboxdata - > colorScheme - > colors [ i ] . g < < 8 ) |
( messageboxdata - > colorScheme - > colors [ i ] . b < < 0 ) ;
( * env ) - > SetIntArrayRegion ( env , colors , i , 1 , & temp ) ;
}
} else {
colors = NULL ;
}
( * env ) - > DeleteLocalRef ( env , clazz ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2017-08-14 14:14:45 -07:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
2015-06-21 17:33:46 +02:00
clazz = ( * env ) - > GetObjectClass ( env , context ) ;
mid = ( * env ) - > GetMethodID ( env , clazz ,
2022-11-30 12:51:59 -08:00
" messageboxShowMessageBox " , " (ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I " ) ;
2024-02-11 08:03:26 -08:00
* buttonID = ( * env ) - > CallIntMethod ( env , context , mid ,
2022-11-30 12:51:59 -08:00
messageboxdata - > flags ,
title ,
message ,
button_flags ,
button_ids ,
button_texts ,
colors ) ;
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , context ) ;
( * env ) - > DeleteLocalRef ( env , clazz ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// delete parameters
2015-06-21 17:33:46 +02:00
( * env ) - > DeleteLocalRef ( env , title ) ;
( * env ) - > DeleteLocalRef ( env , message ) ;
( * env ) - > DeleteLocalRef ( env , button_flags ) ;
( * env ) - > DeleteLocalRef ( env , button_ids ) ;
( * env ) - > DeleteLocalRef ( env , button_texts ) ;
( * env ) - > DeleteLocalRef ( env , colors ) ;
2024-08-22 17:33:49 -07:00
return true ;
2015-06-21 17:33:46 +02:00
}
/*
//////////////////////////////////////////////////////////////////////////////
//
// Functions exposed to SDL applications in SDL_system.h
//////////////////////////////////////////////////////////////////////////////
*/
2024-10-19 10:17:33 -07:00
void * SDL_GetAndroidJNIEnv ( void )
2015-06-21 17:33:46 +02:00
{
return Android_JNI_GetEnv ( ) ;
}
2024-07-15 16:13:23 -07:00
void * SDL_GetAndroidActivity ( void )
2015-06-21 17:33:46 +02:00
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// See SDL_system.h for caveats on using this function.
2015-06-21 17:33:46 +02:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2023-11-09 22:29:15 +01:00
if ( ! env ) {
2015-06-21 17:33:46 +02:00
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// return SDLActivity.getContext();
2017-08-14 14:14:45 -07:00
return ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
2015-06-21 17:33:46 +02:00
}
2019-05-23 14:19:00 -07:00
int SDL_GetAndroidSDKVersion ( void )
{
static int sdk_version ;
if ( ! sdk_version ) {
2022-11-30 12:51:59 -08:00
char sdk [ PROP_VALUE_MAX ] = { 0 } ;
2019-05-23 14:19:00 -07:00
if ( __system_property_get ( " ro.build.version.sdk " , sdk ) ! = 0 ) {
sdk_version = SDL_atoi ( sdk ) ;
}
}
return sdk_version ;
}
2024-08-22 09:21:26 -07:00
bool SDL_IsAndroidTablet ( void )
2018-08-21 20:03:54 -07:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midIsTablet ) ;
}
2024-09-18 07:52:28 -07:00
bool SDL_IsAndroidTV ( void )
2018-02-06 15:03:35 -08:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midIsAndroidTV ) ;
}
2024-09-18 07:52:28 -07:00
bool SDL_IsChromebook ( void )
2018-06-05 12:46:13 -07:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midIsChromebook ) ;
}
2024-09-18 07:52:28 -07:00
bool SDL_IsDeXMode ( void )
2018-06-18 13:14:02 -07:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midIsDeXMode ) ;
}
2024-07-16 07:46:08 -07:00
void SDL_SendAndroidBackButton ( void )
2018-07-12 13:28:13 -07:00
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2019-08-30 08:55:20 +02:00
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midManualBackButton ) ;
2018-07-12 13:28:13 -07:00
}
2024-07-15 16:13:23 -07:00
const char * SDL_GetAndroidInternalStoragePath ( void )
2015-06-21 17:33:46 +02:00
{
static char * s_AndroidInternalFilesPath = NULL ;
2023-11-09 22:29:15 +01:00
if ( ! s_AndroidInternalFilesPath ) {
2015-06-21 17:33:46 +02:00
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
jmethodID mid ;
jobject context ;
jobject fileObject ;
jstring pathString ;
const char * path ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2017-08-14 14:14:45 -07:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
2017-09-22 08:30:46 -07:00
if ( ! context ) {
SDL_SetError ( " Couldn't get Android context! " ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// fileObj = context.getFilesDir();
2015-06-21 17:33:46 +02:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , context ) ,
2022-11-30 12:51:59 -08:00
" getFilesDir " , " ()Ljava/io/File; " ) ;
2015-06-21 17:33:46 +02:00
fileObject = ( * env ) - > CallObjectMethod ( env , context , mid ) ;
if ( ! fileObject ) {
SDL_SetError ( " Couldn't get internal directory " ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// path = fileObject.getCanonicalPath();
2015-06-21 17:33:46 +02:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , fileObject ) ,
2022-11-30 12:51:59 -08:00
" getCanonicalPath " , " ()Ljava/lang/String; " ) ;
2015-06-21 17:33:46 +02:00
pathString = ( jstring ) ( * env ) - > CallObjectMethod ( env , fileObject , mid ) ;
2024-08-22 09:21:26 -07:00
if ( Android_JNI_ExceptionOccurred ( false ) ) {
2018-01-10 19:56:51 -04:00
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
2015-06-21 17:33:46 +02:00
path = ( * env ) - > GetStringUTFChars ( env , pathString , NULL ) ;
s_AndroidInternalFilesPath = SDL_strdup ( path ) ;
( * env ) - > ReleaseStringUTFChars ( env , pathString , path ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
}
2024-07-26 18:57:18 -07:00
return s_AndroidInternalFilesPath ;
2015-06-21 17:33:46 +02:00
}
2024-07-16 21:15:56 -07:00
Uint32 SDL_GetAndroidExternalStorageState ( void )
2015-06-21 17:33:46 +02:00
{
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
jmethodID mid ;
jclass cls ;
jstring stateString ;
2023-02-09 20:44:46 +01:00
const char * state_string ;
2024-07-16 21:15:56 -07:00
Uint32 stateFlags ;
2015-06-21 17:33:46 +02:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
2024-07-16 21:15:56 -07:00
return 0 ;
2015-06-21 17:33:46 +02:00
}
cls = ( * env ) - > FindClass ( env , " android/os/Environment " ) ;
mid = ( * env ) - > GetStaticMethodID ( env , cls ,
2022-11-30 12:51:59 -08:00
" getExternalStorageState " , " ()Ljava/lang/String; " ) ;
2015-06-21 17:33:46 +02:00
stateString = ( jstring ) ( * env ) - > CallStaticObjectMethod ( env , cls , mid ) ;
2023-02-09 20:44:46 +01:00
state_string = ( * env ) - > GetStringUTFChars ( env , stateString , NULL ) ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Print an info message so people debugging know the storage state
2023-02-09 20:44:46 +01:00
__android_log_print ( ANDROID_LOG_INFO , " SDL " , " external storage state: %s " , state_string ) ;
2015-06-21 17:33:46 +02:00
2023-02-09 20:44:46 +01:00
if ( SDL_strcmp ( state_string , " mounted " ) = = 0 ) {
2015-06-21 17:33:46 +02:00
stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ |
SDL_ANDROID_EXTERNAL_STORAGE_WRITE ;
2023-02-09 20:44:46 +01:00
} else if ( SDL_strcmp ( state_string , " mounted_ro " ) = = 0 ) {
2015-06-21 17:33:46 +02:00
stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ ;
} else {
stateFlags = 0 ;
}
2023-02-09 20:44:46 +01:00
( * env ) - > ReleaseStringUTFChars ( env , stateString , state_string ) ;
2015-06-21 17:33:46 +02:00
LocalReferenceHolder_Cleanup ( & refs ) ;
2024-07-16 21:15:56 -07:00
return stateFlags ;
2015-06-21 17:33:46 +02:00
}
2024-07-15 16:13:23 -07:00
const char * SDL_GetAndroidExternalStoragePath ( void )
2015-06-21 17:33:46 +02:00
{
static char * s_AndroidExternalFilesPath = NULL ;
2023-11-09 22:29:15 +01:00
if ( ! s_AndroidExternalFilesPath ) {
2015-06-21 17:33:46 +02:00
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
jmethodID mid ;
jobject context ;
jobject fileObject ;
jstring pathString ;
const char * path ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2017-08-14 14:14:45 -07:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
2015-06-21 17:33:46 +02:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// fileObj = context.getExternalFilesDir();
2015-06-21 17:33:46 +02:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , context ) ,
2022-11-30 12:51:59 -08:00
" getExternalFilesDir " , " (Ljava/lang/String;)Ljava/io/File; " ) ;
2015-06-21 17:33:46 +02:00
fileObject = ( * env ) - > CallObjectMethod ( env , context , mid , NULL ) ;
if ( ! fileObject ) {
SDL_SetError ( " Couldn't get external directory " ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// path = fileObject.getAbsolutePath();
2015-06-21 17:33:46 +02:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , fileObject ) ,
2022-11-30 12:51:59 -08:00
" getAbsolutePath " , " ()Ljava/lang/String; " ) ;
2015-06-21 17:33:46 +02:00
pathString = ( jstring ) ( * env ) - > CallObjectMethod ( env , fileObject , mid ) ;
path = ( * env ) - > GetStringUTFChars ( env , pathString , NULL ) ;
s_AndroidExternalFilesPath = SDL_strdup ( path ) ;
( * env ) - > ReleaseStringUTFChars ( env , pathString , path ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
}
2024-07-26 18:57:18 -07:00
return s_AndroidExternalFilesPath ;
2015-06-21 17:33:46 +02:00
}
2024-07-15 16:13:23 -07:00
const char * SDL_GetAndroidCachePath ( void )
2024-07-10 23:47:02 -04:00
{
2024-07-15 16:13:23 -07:00
// !!! FIXME: lots of duplication with SDL_GetAndroidExternalStoragePath and SDL_GetAndroidInternalStoragePath; consolidate these functions!
2024-07-10 23:47:02 -04:00
static char * s_AndroidCachePath = NULL ;
if ( ! s_AndroidCachePath ) {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup ( __FUNCTION__ ) ;
jmethodID mid ;
jobject context ;
jobject fileObject ;
jstring pathString ;
const char * path ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
if ( ! LocalReferenceHolder_Init ( & refs , env ) ) {
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// context = SDLActivity.getContext();
2024-07-10 23:47:02 -04:00
context = ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetContext ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// fileObj = context.getExternalFilesDir();
2024-07-10 23:47:02 -04:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , context ) ,
2024-10-22 18:03:34 +02:00
" getCacheDir " , " ()Ljava/io/File; " ) ;
2024-07-10 23:47:02 -04:00
fileObject = ( * env ) - > CallObjectMethod ( env , context , mid , NULL ) ;
if ( ! fileObject ) {
SDL_SetError ( " Couldn't get cache directory " ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
return NULL ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// path = fileObject.getAbsolutePath();
2024-07-10 23:47:02 -04:00
mid = ( * env ) - > GetMethodID ( env , ( * env ) - > GetObjectClass ( env , fileObject ) ,
" getAbsolutePath " , " ()Ljava/lang/String; " ) ;
pathString = ( jstring ) ( * env ) - > CallObjectMethod ( env , fileObject , mid ) ;
path = ( * env ) - > GetStringUTFChars ( env , pathString , NULL ) ;
s_AndroidCachePath = SDL_strdup ( path ) ;
( * env ) - > ReleaseStringUTFChars ( env , pathString , path ) ;
LocalReferenceHolder_Cleanup ( & refs ) ;
}
2024-07-26 18:57:18 -07:00
return s_AndroidCachePath ;
2024-07-10 23:47:02 -04:00
}
2024-09-18 07:52:28 -07:00
bool SDL_ShowAndroidToast ( const char * message , int duration , int gravity , int xOffset , int yOffset )
2021-02-19 12:54:57 +03:00
{
return Android_JNI_ShowToast ( message , duration , gravity , xOffset , yOffset ) ;
}
2017-11-04 09:37:29 -07:00
void Android_JNI_GetManifestEnvironmentVariables ( void )
2017-10-24 00:17:07 -07:00
{
2017-11-04 09:37:29 -07:00
if ( ! mActivityClass | | ! midGetManifestEnvironmentVariables ) {
__android_log_print ( ANDROID_LOG_WARN , " SDL " , " Request to get environment variables before JNI is ready " ) ;
return ;
2017-10-24 00:17:07 -07:00
}
2017-11-04 09:37:29 -07:00
if ( ! bHasEnvironmentVariables ) {
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2024-08-22 09:21:26 -07:00
bool ret = ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midGetManifestEnvironmentVariables ) ;
2017-11-04 22:03:28 -07:00
if ( ret ) {
2024-08-22 09:21:26 -07:00
bHasEnvironmentVariables = true ;
2017-11-04 22:03:28 -07:00
}
2017-10-24 00:17:07 -07:00
}
}
2018-03-15 18:22:48 -07:00
int Android_JNI_CreateCustomCursor ( SDL_Surface * surface , int hot_x , int hot_y )
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
2018-03-15 18:22:48 -07:00
int custom_cursor = 0 ;
2018-03-16 11:08:53 -07:00
jintArray pixels ;
2019-01-11 15:36:16 +01:00
pixels = ( * env ) - > NewIntArray ( env , surface - > w * surface - > h ) ;
2018-03-16 11:08:53 -07:00
if ( pixels ) {
2019-01-11 15:36:16 +01:00
( * env ) - > SetIntArrayRegion ( env , pixels , 0 , surface - > w * surface - > h , ( int * ) surface - > pixels ) ;
custom_cursor = ( * env ) - > CallStaticIntMethod ( env , mActivityClass , midCreateCustomCursor , pixels , surface - > w , surface - > h , hot_x , hot_y ) ;
( * env ) - > DeleteLocalRef ( env , pixels ) ;
2018-03-16 11:08:53 -07:00
} else {
SDL_OutOfMemory ( ) ;
2018-03-15 18:22:48 -07:00
}
return custom_cursor ;
}
2021-12-21 22:07:17 +01:00
void Android_JNI_DestroyCustomCursor ( int cursorID )
{
JNIEnv * env = Android_JNI_GetEnv ( ) ;
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midDestroyCustomCursor , cursorID ) ;
}
2018-03-15 18:22:48 -07:00
2024-08-22 09:21:26 -07:00
bool Android_JNI_SetCustomCursor ( int cursorID )
2018-03-15 18:22:48 -07:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSetCustomCursor , cursorID ) ;
2018-03-15 18:22:48 -07:00
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_SetSystemCursor ( int cursorID )
2018-03-15 18:22:48 -07:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSetSystemCursor , cursorID ) ;
2018-03-15 18:22:48 -07:00
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_SupportsRelativeMouse ( void )
2018-06-05 12:46:11 -07:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSupportsRelativeMouse ) ;
2018-06-05 12:46:11 -07:00
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_SetRelativeMouseEnabled ( bool enabled )
2018-06-05 12:46:11 -07:00
{
2019-01-11 15:36:16 +01:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
return ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midSetRelativeMouseEnabled , ( enabled = = 1 ) ) ;
2018-06-05 12:46:11 -07:00
}
2024-02-12 15:26:09 -05:00
typedef struct NativePermissionRequestInfo
2020-02-13 10:19:05 -08:00
{
2024-02-12 15:26:09 -05:00
int request_code ;
char * permission ;
2024-07-16 07:46:08 -07:00
SDL_RequestAndroidPermissionCallback callback ;
2024-02-12 15:26:09 -05:00
void * userdata ;
struct NativePermissionRequestInfo * next ;
} NativePermissionRequestInfo ;
2020-02-13 10:19:05 -08:00
2024-02-12 15:26:09 -05:00
static NativePermissionRequestInfo pending_permissions ;
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( nativePermissionResult ) (
JNIEnv * env , jclass cls ,
jint requestCode , jboolean result )
{
SDL_LockMutex ( Android_ActivityMutex ) ;
NativePermissionRequestInfo * prev = & pending_permissions ;
for ( NativePermissionRequestInfo * info = prev - > next ; info ! = NULL ; info = info - > next ) {
if ( info - > request_code = = ( int ) requestCode ) {
prev - > next = info - > next ;
SDL_UnlockMutex ( Android_ActivityMutex ) ;
2024-08-22 09:21:26 -07:00
info - > callback ( info - > userdata , info - > permission , result ? true : false ) ;
2024-02-12 15:26:09 -05:00
SDL_free ( info - > permission ) ;
SDL_free ( info ) ;
return ;
}
prev = info ;
}
SDL_UnlockMutex ( Android_ActivityMutex ) ;
}
2024-09-18 07:52:28 -07:00
bool SDL_RequestAndroidPermission ( const char * permission , SDL_RequestAndroidPermissionCallback cb , void * userdata )
2024-02-12 15:26:09 -05:00
{
if ( ! permission ) {
return SDL_InvalidParamError ( " permission " ) ;
} else if ( ! cb ) {
return SDL_InvalidParamError ( " cb " ) ;
2021-11-12 08:28:02 -08:00
}
2020-02-13 10:19:05 -08:00
2024-02-12 15:26:09 -05:00
NativePermissionRequestInfo * info = ( NativePermissionRequestInfo * ) SDL_calloc ( 1 , sizeof ( NativePermissionRequestInfo ) ) ;
if ( ! info ) {
2024-08-22 17:33:49 -07:00
return false ;
2024-02-12 15:26:09 -05:00
}
info - > permission = SDL_strdup ( permission ) ;
if ( ! info - > permission ) {
SDL_free ( info ) ;
2024-08-22 17:33:49 -07:00
return false ;
2024-02-12 15:26:09 -05:00
}
static SDL_AtomicInt next_request_code ;
2024-09-16 23:21:31 -07:00
info - > request_code = SDL_AddAtomicInt ( & next_request_code , 1 ) ;
2024-02-12 15:26:09 -05:00
info - > callback = cb ;
info - > userdata = userdata ;
SDL_LockMutex ( Android_ActivityMutex ) ;
info - > next = pending_permissions . next ;
pending_permissions . next = info ;
SDL_UnlockMutex ( Android_ActivityMutex ) ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jstring jpermission = ( * env ) - > NewStringUTF ( env , permission ) ;
( * env ) - > CallStaticVoidMethod ( env , mActivityClass , midRequestPermission , jpermission , info - > request_code ) ;
2020-02-13 10:19:05 -08:00
( * env ) - > DeleteLocalRef ( env , jpermission ) ;
2024-08-22 17:33:49 -07:00
return true ;
2024-02-12 15:26:09 -05:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Show toast notification
2024-08-22 17:33:49 -07:00
bool Android_JNI_ShowToast ( const char * message , int duration , int gravity , int xOffset , int yOffset )
2021-02-19 12:54:57 +03:00
{
2024-08-22 17:33:49 -07:00
bool result ;
2021-02-19 12:54:57 +03:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jstring jmessage = ( * env ) - > NewStringUTF ( env , message ) ;
2024-09-24 21:35:32 +01:00
result = ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midShowToast , jmessage , duration , gravity , xOffset , yOffset ) ;
2021-02-19 12:54:57 +03:00
( * env ) - > DeleteLocalRef ( env , jmessage ) ;
return result ;
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_GetLocale ( char * buf , size_t buflen )
2020-05-04 02:27:29 -04:00
{
2025-05-20 18:09:28 -04:00
bool result = false ;
if ( buf & & buflen > 0 ) {
* buf = ' \0 ' ;
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jstring string = ( jstring ) ( * env ) - > CallStaticObjectMethod ( env , mActivityClass , midGetPreferredLocales ) ;
if ( string ) {
const char * utf8string = ( * env ) - > GetStringUTFChars ( env , string , NULL ) ;
if ( utf8string ) {
result = true ;
SDL_strlcpy ( buf , utf8string , buflen ) ;
( * env ) - > ReleaseStringUTFChars ( env , string , utf8string ) ;
2020-05-04 02:27:29 -04:00
}
2025-05-20 18:09:28 -04:00
( * env ) - > DeleteLocalRef ( env , string ) ;
2020-05-04 02:27:29 -04:00
}
}
2025-05-20 18:09:28 -04:00
return result ;
2020-05-04 02:27:29 -04:00
}
2024-08-22 17:33:49 -07:00
bool Android_JNI_OpenURL ( const char * url )
2020-10-05 13:59:03 -04:00
{
2024-08-22 17:33:49 -07:00
bool result ;
2020-10-05 13:59:03 -04:00
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jstring jurl = ( * env ) - > NewStringUTF ( env , url ) ;
2024-09-24 21:35:32 +01:00
result = ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass , midOpenURL , jurl ) ;
2020-10-05 13:59:03 -04:00
( * env ) - > DeleteLocalRef ( env , jurl ) ;
2024-08-22 17:33:49 -07:00
return result ;
2020-10-05 13:59:03 -04:00
}
2024-05-07 00:05:49 +08:00
int Android_JNI_OpenFileDescriptor ( const char * uri , const char * mode )
{
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Get fopen-style modes
2024-05-07 00:05:49 +08:00
int moderead = 0 , modewrite = 0 , modeappend = 0 , modeupdate = 0 ;
for ( const char * cmode = mode ; * cmode ; cmode + + ) {
switch ( * cmode ) {
case ' a ' :
modeappend = 1 ;
break ;
case ' r ' :
moderead = 1 ;
break ;
case ' w ' :
modewrite = 1 ;
break ;
case ' + ' :
modeupdate = 1 ;
break ;
default :
break ;
}
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Translate fopen-style modes to ContentResolver modes.
// Android only allows "r", "w", "wt", "wa", "rw" or "rwt".
2024-05-07 00:05:49 +08:00
const char * contentResolverMode = " r " ;
if ( moderead ) {
if ( modewrite ) {
contentResolverMode = " rwt " ;
} else {
contentResolverMode = modeupdate ? " rw " : " r " ;
}
} else if ( modewrite ) {
contentResolverMode = modeupdate ? " rwt " : " wt " ;
} else if ( modeappend ) {
contentResolverMode = modeupdate ? " rw " : " wa " ;
}
JNIEnv * env = Android_JNI_GetEnv ( ) ;
jstring jstringUri = ( * env ) - > NewStringUTF ( env , uri ) ;
jstring jstringMode = ( * env ) - > NewStringUTF ( env , contentResolverMode ) ;
jint fd = ( * env ) - > CallStaticIntMethod ( env , mActivityClass , midOpenFileDescriptor , jstringUri , jstringMode ) ;
( * env ) - > DeleteLocalRef ( env , jstringUri ) ;
( * env ) - > DeleteLocalRef ( env , jstringMode ) ;
if ( fd = = - 1 ) {
SDL_SetError ( " Unspecified error in JNI " ) ;
}
return fd ;
}
2024-05-06 12:14:20 +08:00
static struct AndroidFileDialog
{
int request_code ;
SDL_DialogFileCallback callback ;
void * userdata ;
} mAndroidFileDialogData ;
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE ( onNativeFileDialog ) (
JNIEnv * env , jclass jcls ,
jint requestCode , jobjectArray fileList , jint filter )
{
if ( mAndroidFileDialogData . callback ! = NULL & & mAndroidFileDialogData . request_code = = requestCode ) {
if ( fileList = = NULL ) {
SDL_SetError ( " Unspecified error in JNI " ) ;
mAndroidFileDialogData . callback ( mAndroidFileDialogData . userdata , NULL , - 1 ) ;
mAndroidFileDialogData . callback = NULL ;
return ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Convert fileList to string
2024-05-06 12:14:20 +08:00
size_t count = ( * env ) - > GetArrayLength ( env , fileList ) ;
2025-06-18 09:26:51 -07:00
char * * charFileList = SDL_calloc ( count + 1 , sizeof ( char * ) ) ;
2024-05-06 12:14:20 +08:00
if ( charFileList = = NULL ) {
mAndroidFileDialogData . callback ( mAndroidFileDialogData . userdata , NULL , - 1 ) ;
mAndroidFileDialogData . callback = NULL ;
return ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Convert to UTF-8
// TODO: Fix modified UTF-8 to classic UTF-8
2024-05-06 12:14:20 +08:00
for ( int i = 0 ; i < count ; i + + ) {
jstring string = ( * env ) - > GetObjectArrayElement ( env , fileList , i ) ;
if ( ! string ) {
continue ;
}
const char * utf8string = ( * env ) - > GetStringUTFChars ( env , string , NULL ) ;
if ( ! utf8string ) {
( * env ) - > DeleteLocalRef ( env , string ) ;
continue ;
}
char * newFile = SDL_strdup ( utf8string ) ;
if ( ! newFile ) {
( * env ) - > ReleaseStringUTFChars ( env , string , utf8string ) ;
( * env ) - > DeleteLocalRef ( env , string ) ;
mAndroidFileDialogData . callback ( mAndroidFileDialogData . userdata , NULL , - 1 ) ;
mAndroidFileDialogData . callback = NULL ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Cleanup memory
2024-05-06 12:14:20 +08:00
for ( int j = 0 ; j < i ; j + + ) {
SDL_free ( charFileList [ j ] ) ;
}
SDL_free ( charFileList ) ;
return ;
}
charFileList [ i ] = newFile ;
( * env ) - > ReleaseStringUTFChars ( env , string , utf8string ) ;
( * env ) - > DeleteLocalRef ( env , string ) ;
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Call user-provided callback
2024-05-06 12:14:20 +08:00
SDL_ClearError ( ) ;
mAndroidFileDialogData . callback ( mAndroidFileDialogData . userdata , ( const char * const * ) charFileList , filter ) ;
mAndroidFileDialogData . callback = NULL ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Cleanup memory
2024-05-06 12:14:20 +08:00
for ( int i = 0 ; i < count ; i + + ) {
SDL_free ( charFileList [ i ] ) ;
}
SDL_free ( charFileList ) ;
}
}
2024-08-22 09:21:26 -07:00
bool Android_JNI_OpenFileDialog (
2025-06-18 09:26:51 -07:00
SDL_DialogFileCallback callback , void * userdata ,
2024-08-22 09:21:26 -07:00
const SDL_DialogFileFilter * filters , int nfilters , bool forwrite ,
bool multiple )
2024-05-06 12:14:20 +08:00
{
if ( mAndroidFileDialogData . callback ! = NULL ) {
SDL_SetError ( " Only one file dialog can be run at a time. " ) ;
2024-08-22 09:21:26 -07:00
return false ;
2024-05-06 12:14:20 +08:00
}
if ( forwrite ) {
2024-08-22 09:21:26 -07:00
multiple = false ;
2024-05-06 12:14:20 +08:00
}
JNIEnv * env = Android_JNI_GetEnv ( ) ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Setup filters
2024-05-06 12:14:20 +08:00
jobjectArray filtersArray = NULL ;
if ( filters ) {
jclass stringClass = ( * env ) - > FindClass ( env , " java/lang/String " ) ;
2024-05-22 19:20:40 -04:00
filtersArray = ( * env ) - > NewObjectArray ( env , nfilters , stringClass , NULL ) ;
2024-05-06 12:14:20 +08:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Convert to string
2024-05-22 19:20:40 -04:00
for ( int i = 0 ; i < nfilters ; i + + ) {
2024-05-06 12:14:20 +08:00
jstring str = ( * env ) - > NewStringUTF ( env , filters [ i ] . pattern ) ;
( * env ) - > SetObjectArrayElement ( env , filtersArray , i , str ) ;
( * env ) - > DeleteLocalRef ( env , str ) ;
}
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Setup data
2024-05-06 12:14:20 +08:00
static SDL_AtomicInt next_request_code ;
2024-09-16 23:21:31 -07:00
mAndroidFileDialogData . request_code = SDL_AddAtomicInt ( & next_request_code , 1 ) ;
2024-05-06 12:14:20 +08:00
mAndroidFileDialogData . userdata = userdata ;
mAndroidFileDialogData . callback = callback ;
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
// Invoke JNI
2024-05-06 12:14:20 +08:00
jboolean success = ( * env ) - > CallStaticBooleanMethod ( env , mActivityClass ,
midShowFileDialog , filtersArray , ( jboolean ) multiple , ( jboolean ) forwrite , mAndroidFileDialogData . request_code ) ;
( * env ) - > DeleteLocalRef ( env , filtersArray ) ;
if ( ! success ) {
mAndroidFileDialogData . callback = NULL ;
2024-09-16 23:21:31 -07:00
SDL_AddAtomicInt ( & next_request_code , - 1 ) ;
2024-05-06 12:14:20 +08:00
SDL_SetError ( " Unspecified error in JNI " ) ;
2024-08-22 09:21:26 -07:00
return false ;
2024-05-06 12:14:20 +08:00
}
2024-08-22 09:21:26 -07:00
return true ;
2024-05-06 12:14:20 +08:00
}
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
# endif // SDL_PLATFORM_ANDROID