Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
235
external/sdl/SDL/src/core/SDL_core_unsupported.c
vendored
Normal file
235
external/sdl/SDL/src/core/SDL_core_unsupported.c
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_VIDEO_DRIVER_X11
|
||||
|
||||
DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __LINUX__
|
||||
|
||||
DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority);
|
||||
int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
|
||||
{
|
||||
(void)threadID;
|
||||
(void)priority;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
||||
int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
{
|
||||
(void)threadID;
|
||||
(void)sdlPriority;
|
||||
(void)schedPolicy;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __GDK__
|
||||
|
||||
DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
|
||||
void SDL_GDKSuspendComplete(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_GDKGetDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */
|
||||
int SDL_GDKGetDefaultUser(void *outUserHandle)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !(defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__))
|
||||
|
||||
DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
{
|
||||
(void)name;
|
||||
(void)style;
|
||||
(void)hInst;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); /* SDL_WindowsMessageHook callback */
|
||||
void SDL_SetWindowsMessageHook(void *callback, void *userdata)
|
||||
{
|
||||
(void)callback;
|
||||
(void)userdata;
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
void SDL_UnregisterApp(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __WINRT__
|
||||
|
||||
/* Returns SDL_WinRT_DeviceFamily enum */
|
||||
DECLSPEC int SDLCALL SDL_WinRTGetDeviceFamily(void);
|
||||
int SDL_WinRTGetDeviceFamily()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */
|
||||
}
|
||||
|
||||
DECLSPEC const wchar_t *SDLCALL SDL_WinRTGetFSPathUNICODE(int pathType); /* SDL_WinRT_Path pathType */
|
||||
const wchar_t *SDL_WinRTGetFSPathUNICODE(int pathType)
|
||||
{
|
||||
(void)pathType;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC const char *SDLCALL SDL_WinRTGetFSPathUTF8(int pathType); /* SDL_WinRT_Path pathType */
|
||||
const char *SDL_WinRTGetFSPathUTF8(int pathType)
|
||||
{
|
||||
(void)pathType;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __ANDROID__
|
||||
|
||||
DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
|
||||
void SDL_AndroidBackButton()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC void *SDLCALL SDL_AndroidGetActivity(void);
|
||||
void *SDL_AndroidGetActivity()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC const char *SDLCALL SDL_AndroidGetExternalStoragePath(void);
|
||||
const char* SDL_AndroidGetExternalStoragePath()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(Uint32 *state);
|
||||
int SDL_AndroidGetExternalStorageState(Uint32 *state)
|
||||
{
|
||||
(void)state;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
DECLSPEC const char *SDLCALL SDL_AndroidGetInternalStoragePath(void);
|
||||
const char *SDL_AndroidGetInternalStoragePath()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC void *SDLCALL SDL_AndroidGetJNIEnv(void);
|
||||
void *SDL_AndroidGetJNIEnv()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission);
|
||||
SDL_bool SDL_AndroidRequestPermission(const char *permission)
|
||||
{
|
||||
(void)permission;
|
||||
SDL_Unsupported();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
|
||||
int SDL_AndroidSendMessage(Uint32 command, int param)
|
||||
{
|
||||
(void)command;
|
||||
(void)param;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
|
||||
int SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
|
||||
{
|
||||
(void)message;
|
||||
(void)duration;
|
||||
(void)gravity;
|
||||
(void)xoffset;
|
||||
(void)yoffset;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
|
||||
int SDL_GetAndroidSDKVersion()
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
|
||||
SDL_bool SDL_IsAndroidTV()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
|
||||
SDL_bool SDL_IsChromebook()
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
||||
SDL_bool SDL_IsDeXMode(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
DECLSPEC Sint32 SDLCALL JNI_OnLoad(void *vm, void *reserved);
|
||||
Sint32 JNI_OnLoad(void *vm, void *reserved)
|
||||
{
|
||||
(void)vm;
|
||||
(void)reserved;
|
||||
SDL_Unsupported();
|
||||
return -1; /* JNI_ERR */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
char *SDL_GetUserFolder(SDL_Folder folder)
|
||||
{
|
||||
(void)folder;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
11
external/sdl/SDL/src/core/SDL_runapp.c
vendored
11
external/sdl/SDL/src/core/SDL_runapp.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -27,15 +27,14 @@
|
||||
DECLSPEC int
|
||||
SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
||||
{
|
||||
char empty[1] = {0};
|
||||
char* argvdummy[2] = { empty, NULL };
|
||||
|
||||
(void)reserved;
|
||||
|
||||
if(argv == NULL)
|
||||
if(!argv)
|
||||
{
|
||||
argc = 0;
|
||||
/* make sure argv isn't NULL, in case some user code doesn't like that */
|
||||
static char dummyargv0[] = { 'S', 'D', 'L', '_', 'a', 'p', 'p', '\0' };
|
||||
static char* argvdummy[2] = { dummyargv0, NULL };
|
||||
argc = 1;
|
||||
argv = argvdummy;
|
||||
}
|
||||
|
||||
|
72
external/sdl/SDL/src/core/android/SDL_android.c
vendored
72
external/sdl/SDL/src/core/android/SDL_android.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -434,12 +434,12 @@ JNIEnv *Android_JNI_GetEnv(void)
|
||||
{
|
||||
/* Get JNIEnv from the Thread local storage */
|
||||
JNIEnv *env = pthread_getspecific(mThreadKey);
|
||||
if (env == NULL) {
|
||||
if (!env) {
|
||||
/* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */
|
||||
int status;
|
||||
|
||||
/* There should be a JVM */
|
||||
if (mJavaVM == NULL) {
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
|
||||
return NULL;
|
||||
}
|
||||
@ -468,7 +468,7 @@ int Android_JNI_SetupThread(void)
|
||||
int status;
|
||||
|
||||
/* There should be a JVM */
|
||||
if (mJavaVM == NULL) {
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
|
||||
return 0;
|
||||
}
|
||||
@ -494,7 +494,7 @@ static void Android_JNI_ThreadDestroyed(void *value)
|
||||
{
|
||||
/* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
|
||||
JNIEnv *env = (JNIEnv *)value;
|
||||
if (env != NULL) {
|
||||
if (env) {
|
||||
(*mJavaVM)->DetachCurrentThread(mJavaVM);
|
||||
Android_JNI_SetEnv(NULL);
|
||||
}
|
||||
@ -520,7 +520,7 @@ static void Android_JNI_CreateKey_once(void)
|
||||
static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb)
|
||||
{
|
||||
jclass clazz = (*env)->FindClass(env, classname);
|
||||
if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) {
|
||||
if (!clazz || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to register methods of %s", classname);
|
||||
return;
|
||||
}
|
||||
@ -573,6 +573,9 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
|
||||
|
||||
/* Start with a clean slate */
|
||||
SDL_ClearError();
|
||||
|
||||
/*
|
||||
* 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
|
||||
@ -582,28 +585,28 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
/* Save JNIEnv of SDLActivity */
|
||||
Android_JNI_SetEnv(env);
|
||||
|
||||
if (mJavaVM == NULL) {
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to found a JavaVM");
|
||||
}
|
||||
|
||||
/* Use a mutex to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
|
||||
* (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
|
||||
*/
|
||||
if (Android_ActivityMutex == NULL) {
|
||||
if (!Android_ActivityMutex) {
|
||||
Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */
|
||||
}
|
||||
|
||||
if (Android_ActivityMutex == NULL) {
|
||||
if (!Android_ActivityMutex) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex");
|
||||
}
|
||||
|
||||
Android_PauseSem = SDL_CreateSemaphore(0);
|
||||
if (Android_PauseSem == NULL) {
|
||||
if (!Android_PauseSem) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore");
|
||||
}
|
||||
|
||||
Android_ResumeSem = SDL_CreateSemaphore(0);
|
||||
if (Android_ResumeSem == NULL) {
|
||||
if (!Android_ResumeSem) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ResumeSem semaphore");
|
||||
}
|
||||
|
||||
@ -878,7 +881,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
|
||||
jstring filename)
|
||||
{
|
||||
const char *path = (*env)->GetStringUTFChars(env, filename, NULL);
|
||||
SDL_SendDropFile(NULL, path);
|
||||
SDL_SendDropFile(NULL, NULL, path);
|
||||
(*env)->ReleaseStringUTFChars(env, filename, path);
|
||||
SDL_SendDropComplete(NULL);
|
||||
}
|
||||
@ -1006,24 +1009,28 @@ JNIEXPORT void JNICALL
|
||||
SDL_JAVA_AUDIO_INTERFACE(addAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_capture,
|
||||
jstring name, jint device_id)
|
||||
{
|
||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||
if (SDL_GetCurrentAudioDriver() != NULL) {
|
||||
void *handle = (void *)((size_t)device_id);
|
||||
if (!SDL_FindPhysicalAudioDeviceByHandle(handle)) {
|
||||
const char *utf8name = (*env)->GetStringUTFChars(env, name, NULL);
|
||||
SDL_AddAudioDevice(is_capture ? SDL_TRUE : SDL_FALSE, SDL_strdup(utf8name), NULL, handle);
|
||||
SDL_AddAudioDevice(is_capture, SDL_strdup(utf8name), NULL, handle);
|
||||
(*env)->ReleaseStringUTFChars(env, name, utf8name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_capture,
|
||||
jint device_id)
|
||||
{
|
||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||
if (SDL_GetCurrentAudioDriver() != NULL) {
|
||||
SDL_Log("Removing device with handle %d, capture %d", device_id, is_capture);
|
||||
SDL_AudioDeviceDisconnected(SDL_FindPhysicalAudioDeviceByHandle((void *)((size_t)device_id)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Paddown */
|
||||
@ -1068,7 +1075,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
|
||||
const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL);
|
||||
|
||||
retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer ? SDL_TRUE : SDL_FALSE, button_mask, naxes, axis_mask, nhats);
|
||||
retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer, button_mask, naxes, axis_mask, nhats);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, device_name, name);
|
||||
(*env)->ReleaseStringUTFChars(env, device_desc, desc);
|
||||
@ -1610,7 +1617,7 @@ int Android_JNI_OpenAudioDevice(SDL_AudioDevice *device)
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output");
|
||||
result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, device->sample_frames, device_id);
|
||||
}
|
||||
if (result == NULL) {
|
||||
if (!result) {
|
||||
/* Error during audio initialization, error printed from Java */
|
||||
return SDL_SetError("Java-side initialization failed");
|
||||
}
|
||||
@ -1671,7 +1678,7 @@ int Android_JNI_OpenAudioDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat);
|
||||
}
|
||||
|
||||
if (jbufobj == NULL) {
|
||||
if (!jbufobj) {
|
||||
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer");
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@ -1942,7 +1949,7 @@ static void Internal_Android_Create_AssetManager()
|
||||
javaAssetManagerRef = (*env)->NewGlobalRef(env, javaAssetManager);
|
||||
asset_manager = AAssetManager_fromJava(env, javaAssetManagerRef);
|
||||
|
||||
if (asset_manager == NULL) {
|
||||
if (!asset_manager) {
|
||||
(*env)->DeleteGlobalRef(env, javaAssetManagerRef);
|
||||
Android_JNI_ExceptionOccurred(SDL_TRUE);
|
||||
}
|
||||
@ -1966,17 +1973,17 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
|
||||
AAsset *asset = NULL;
|
||||
ctx->hidden.androidio.asset = NULL;
|
||||
|
||||
if (asset_manager == NULL) {
|
||||
if (!asset_manager) {
|
||||
Internal_Android_Create_AssetManager();
|
||||
}
|
||||
|
||||
if (asset_manager == NULL) {
|
||||
return -1;
|
||||
if (!asset_manager) {
|
||||
return SDL_SetError("Couldn't create asset manager");
|
||||
}
|
||||
|
||||
asset = AAssetManager_open(asset_manager, fileName, AASSET_MODE_UNKNOWN);
|
||||
if (asset == NULL) {
|
||||
return -1;
|
||||
if (!asset) {
|
||||
return SDL_SetError("Couldn't open asset '%s'", fileName);
|
||||
}
|
||||
|
||||
ctx->hidden.androidio.asset = (void *)asset;
|
||||
@ -2047,14 +2054,13 @@ char *Android_JNI_GetClipboardText(void)
|
||||
(*env)->DeleteLocalRef(env, string);
|
||||
}
|
||||
|
||||
return (text == NULL) ? SDL_strdup("") : text;
|
||||
return (!text) ? SDL_strdup("") : text;
|
||||
}
|
||||
|
||||
SDL_bool Android_JNI_HasClipboardText(void)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jboolean retval = (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
|
||||
return (retval == JNI_TRUE) ? SDL_TRUE : SDL_FALSE;
|
||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
|
||||
}
|
||||
|
||||
/* returns 0 on success or -1 on error (others undefined then)
|
||||
@ -2233,7 +2239,7 @@ int Android_JNI_SuspendScreenSaver(SDL_bool suspend)
|
||||
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
|
||||
}
|
||||
|
||||
void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
|
||||
void Android_JNI_ShowScreenKeyboard(SDL_Rect *inputRect)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
(*env)->CallStaticBooleanMethod(env, mActivityClass, midShowTextInput,
|
||||
@ -2243,7 +2249,7 @@ void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
|
||||
inputRect->h);
|
||||
}
|
||||
|
||||
void Android_JNI_HideTextInput(void)
|
||||
void Android_JNI_HideScreenKeyboard(void)
|
||||
{
|
||||
/* has to match Activity constant */
|
||||
const int COMMAND_TEXTEDIT_HIDE = 3;
|
||||
@ -2368,7 +2374,7 @@ void *SDL_AndroidGetActivity(void)
|
||||
/* See SDL_system.h for caveats on using this function. */
|
||||
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (env == NULL) {
|
||||
if (!env) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2422,7 +2428,7 @@ const char *SDL_AndroidGetInternalStoragePath(void)
|
||||
{
|
||||
static char *s_AndroidInternalFilesPath = NULL;
|
||||
|
||||
if (s_AndroidInternalFilesPath == NULL) {
|
||||
if (!s_AndroidInternalFilesPath) {
|
||||
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
|
||||
jmethodID mid;
|
||||
jobject context;
|
||||
@ -2521,7 +2527,7 @@ const char *SDL_AndroidGetExternalStoragePath(void)
|
||||
{
|
||||
static char *s_AndroidExternalFilesPath = NULL;
|
||||
|
||||
if (s_AndroidExternalFilesPath == NULL) {
|
||||
if (!s_AndroidExternalFilesPath) {
|
||||
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
|
||||
jmethodID mid;
|
||||
jobject context;
|
||||
@ -2677,16 +2683,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
/* Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED) */
|
||||
Internal_Android_Destroy_AssetManager();
|
||||
|
||||
if (asset_manager == NULL) {
|
||||
if (!asset_manager) {
|
||||
Internal_Android_Create_AssetManager();
|
||||
}
|
||||
|
||||
if (asset_manager == NULL) {
|
||||
if (!asset_manager) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cfg = AConfiguration_new();
|
||||
if (cfg == NULL) {
|
||||
if (!cfg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -32,6 +32,9 @@ extern "C" {
|
||||
|
||||
#include "../../audio/SDL_sysaudio.h"
|
||||
|
||||
// this appears to be broken right now (on Android, not SDL, I think...?).
|
||||
#define ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES 0
|
||||
|
||||
/* Interface from the SDL library into the Android Java activity */
|
||||
extern void Android_JNI_SetActivityTitle(const char *title);
|
||||
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
|
||||
@ -40,8 +43,8 @@ extern void Android_JNI_MinizeWindow(void);
|
||||
extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
|
||||
|
||||
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
|
||||
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
|
||||
extern void Android_JNI_HideTextInput(void);
|
||||
extern void Android_JNI_ShowScreenKeyboard(SDL_Rect *inputRect);
|
||||
extern void Android_JNI_HideScreenKeyboard(void);
|
||||
extern SDL_bool Android_JNI_IsScreenKeyboardShown(void);
|
||||
extern ANativeWindow *Android_JNI_GetNativeWindow(void);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -87,7 +87,7 @@ static void kbd_cleanup(void)
|
||||
{
|
||||
struct mouse_info mData;
|
||||
SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state;
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return;
|
||||
}
|
||||
kbd_cleanup_state = NULL;
|
||||
@ -178,7 +178,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||
{
|
||||
int tabidx;
|
||||
|
||||
if (kbd_cleanup_state != NULL) {
|
||||
if (kbd_cleanup_state) {
|
||||
return;
|
||||
}
|
||||
kbd_cleanup_state = kbd;
|
||||
@ -230,7 +230,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
SDL_zero(mData);
|
||||
mData.operation = MOUSE_HIDE;
|
||||
kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(SDL_EVDEV_keyboard_state));
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
|
||||
{
|
||||
struct mouse_info mData;
|
||||
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return;
|
||||
}
|
||||
SDL_zero(mData);
|
||||
@ -320,6 +320,18 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
|
||||
SDL_free(kbd);
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper Functions.
|
||||
*/
|
||||
@ -474,7 +486,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
unsigned int final_key_state;
|
||||
unsigned int map_from_key_sym;
|
||||
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
2
external/sdl/SDL/src/core/gdk/SDL_gdk.cpp
vendored
2
external/sdl/SDL/src/core/gdk/SDL_gdk.cpp
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/gdk/SDL_gdk.h
vendored
2
external/sdl/SDL/src/core/gdk/SDL_gdk.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/haiku/SDL_BApp.h
vendored
2
external/sdl/SDL/src/core/haiku/SDL_BApp.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
10
external/sdl/SDL/src/core/haiku/SDL_BeApp.cc
vendored
10
external/sdl/SDL/src/core/haiku/SDL_BeApp.cc
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -69,7 +69,7 @@ public:
|
||||
entry_ref entryRef;
|
||||
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
|
||||
BPath referencePath = BPath(&entryRef);
|
||||
SDL_SendDropFile(NULL, referencePath.Path());
|
||||
SDL_SendDropFile(NULL, NULL, referencePath.Path());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -108,13 +108,13 @@ static int StartBeLooper()
|
||||
{
|
||||
if (!be_app) {
|
||||
SDL_AppThread = SDL_CreateThreadInternal(StartBeApp, "SDLApplication", 0, NULL);
|
||||
if (SDL_AppThread == NULL) {
|
||||
if (!SDL_AppThread) {
|
||||
return SDL_SetError("Couldn't create BApplication thread");
|
||||
}
|
||||
|
||||
do {
|
||||
SDL_Delay(10);
|
||||
} while ((be_app == NULL) || be_app->IsLaunching());
|
||||
} while ((!be_app) || be_app->IsLaunching());
|
||||
}
|
||||
|
||||
/* Change working directory to that of executable */
|
||||
@ -167,7 +167,7 @@ void SDL_QuitBeApp(void)
|
||||
SDL_Looper->Lock();
|
||||
SDL_Looper->Quit();
|
||||
SDL_Looper = NULL;
|
||||
if (SDL_AppThread != NULL) {
|
||||
if (SDL_AppThread) {
|
||||
if (be_app != NULL) { /* Not tested */
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
|
2
external/sdl/SDL/src/core/haiku/SDL_BeApp.h
vendored
2
external/sdl/SDL/src/core/haiku/SDL_BeApp.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
37
external/sdl/SDL/src/core/linux/SDL_dbus.c
vendored
37
external/sdl/SDL/src/core/linux/SDL_dbus.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -96,7 +96,7 @@ static int LoadDBUSSyms(void)
|
||||
|
||||
static void UnloadDBUSLibrary(void)
|
||||
{
|
||||
if (dbus_handle != NULL) {
|
||||
if (dbus_handle) {
|
||||
SDL_UnloadObject(dbus_handle);
|
||||
dbus_handle = NULL;
|
||||
}
|
||||
@ -105,9 +105,9 @@ static void UnloadDBUSLibrary(void)
|
||||
static int LoadDBUSLibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
if (dbus_handle == NULL) {
|
||||
if (!dbus_handle) {
|
||||
dbus_handle = SDL_LoadObject(dbus_library);
|
||||
if (dbus_handle == NULL) {
|
||||
if (!dbus_handle) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
} else {
|
||||
@ -183,14 +183,13 @@ void SDL_DBus_Quit(void)
|
||||
dbus.connection_close(dbus.session_conn);
|
||||
dbus.connection_unref(dbus.session_conn);
|
||||
}
|
||||
/* Don't do this - bug 3950
|
||||
dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it.
|
||||
*/
|
||||
#if 0
|
||||
if (dbus.shutdown) {
|
||||
dbus.shutdown();
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, SDL_FALSE)) {
|
||||
if (dbus.shutdown) {
|
||||
dbus.shutdown();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_zero(dbus);
|
||||
UnloadDBUSLibrary();
|
||||
SDL_free(inhibit_handle);
|
||||
@ -199,7 +198,7 @@ void SDL_DBus_Quit(void)
|
||||
|
||||
SDL_DBusContext *SDL_DBus_GetContext(void)
|
||||
{
|
||||
if (dbus_handle == NULL || !dbus.session_conn) {
|
||||
if (!dbus_handle || !dbus.session_conn) {
|
||||
SDL_DBus_Init();
|
||||
}
|
||||
|
||||
@ -360,7 +359,7 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *
|
||||
|
||||
void SDL_DBus_ScreensaverTickle(void)
|
||||
{
|
||||
if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */
|
||||
if (screensaver_cookie == 0 && !inhibit_handle) { /* no need to tickle if we're inhibiting. */
|
||||
/* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */
|
||||
SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
|
||||
SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
|
||||
@ -428,7 +427,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
{
|
||||
const char *default_inhibit_reason = "Playing a game";
|
||||
|
||||
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) {
|
||||
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
@ -452,12 +451,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
const char *key = "reason";
|
||||
const char *reply = NULL;
|
||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||
if (reason == NULL || !reason[0]) {
|
||||
if (!reason || !reason[0]) {
|
||||
reason = default_inhibit_reason;
|
||||
}
|
||||
|
||||
msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit");
|
||||
if (msg == NULL) {
|
||||
if (!msg) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@ -496,10 +495,10 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
if (inhibit) {
|
||||
const char *app = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||
if (app == NULL || !app[0]) {
|
||||
if (!app || !app[0]) {
|
||||
app = "My SDL application";
|
||||
}
|
||||
if (reason == NULL || !reason[0]) {
|
||||
if (!reason || !reason[0]) {
|
||||
reason = default_inhibit_reason;
|
||||
}
|
||||
|
||||
@ -508,7 +507,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return (screensaver_cookie != 0) ? SDL_TRUE : SDL_FALSE;
|
||||
return (screensaver_cookie != 0);
|
||||
} else {
|
||||
if (!SDL_DBus_CallVoidMethod(bus_name, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||
return SDL_FALSE;
|
||||
|
2
external/sdl/SDL/src/core/linux/SDL_dbus.h
vendored
2
external/sdl/SDL/src/core/linux/SDL_dbus.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
90
external/sdl/SDL/src/core/linux/SDL_evdev.c
vendored
90
external/sdl/SDL/src/core/linux/SDL_evdev.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -73,6 +73,7 @@ typedef struct SDL_evdevlist_item
|
||||
{
|
||||
char *path;
|
||||
int fd;
|
||||
int udev_class;
|
||||
|
||||
/* TODO: use this for every device, not just touchscreen */
|
||||
SDL_bool out_of_sync;
|
||||
@ -155,12 +156,21 @@ static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_UpdateKeyboardMute(void)
|
||||
{
|
||||
if (SDL_EVDEV_GetDeviceCount(SDL_UDEV_DEVICE_KEYBOARD) > 0) {
|
||||
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_TRUE);
|
||||
} else {
|
||||
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_EVDEV_Init(void)
|
||||
{
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
_this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
|
||||
if (_this == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!_this) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
@ -208,6 +218,8 @@ int SDL_EVDEV_Init(void)
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
_this->kbd = SDL_EVDEV_kbd_init();
|
||||
|
||||
SDL_EVDEV_UpdateKeyboardMute();
|
||||
}
|
||||
|
||||
SDL_GetMouse()->SetRelativeMouseMode = SDL_EVDEV_SetRelativeMouseMode;
|
||||
@ -219,7 +231,7 @@ int SDL_EVDEV_Init(void)
|
||||
|
||||
void SDL_EVDEV_Quit(void)
|
||||
{
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -231,13 +243,13 @@ void SDL_EVDEV_Quit(void)
|
||||
SDL_UDEV_Quit();
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
SDL_EVDEV_kbd_quit(_this->kbd);
|
||||
|
||||
/* Remove existing devices */
|
||||
while (_this->first != NULL) {
|
||||
while (_this->first) {
|
||||
SDL_EVDEV_device_removed(_this->first->path);
|
||||
}
|
||||
|
||||
SDL_EVDEV_kbd_quit(_this->kbd);
|
||||
|
||||
SDL_assert(_this->first == NULL);
|
||||
SDL_assert(_this->last == NULL);
|
||||
SDL_assert(_this->num_devices == 0);
|
||||
@ -251,7 +263,7 @@ void SDL_EVDEV_Quit(void)
|
||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class,
|
||||
const char *dev_path)
|
||||
{
|
||||
if (dev_path == NULL) {
|
||||
if (!dev_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -276,6 +288,27 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
|
||||
}
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
||||
void (*acquire_callback)(void*), void *acquire_callback_data)
|
||||
{
|
||||
SDL_EVDEV_kbd_set_vt_switch_callbacks(_this->kbd,
|
||||
release_callback, release_callback_data,
|
||||
acquire_callback, acquire_callback_data);
|
||||
}
|
||||
|
||||
int SDL_EVDEV_GetDeviceCount(int device_class)
|
||||
{
|
||||
SDL_evdevlist_item *item;
|
||||
int count = 0;
|
||||
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
if ((item->udev_class & device_class) == device_class) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_Poll(void)
|
||||
{
|
||||
struct input_event events[32];
|
||||
@ -294,9 +327,11 @@ void SDL_EVDEV_Poll(void)
|
||||
SDL_UDEV_Poll();
|
||||
#endif
|
||||
|
||||
SDL_EVDEV_kbd_update(_this->kbd);
|
||||
|
||||
mouse = SDL_GetMouse();
|
||||
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
while ((len = read(item->fd, events, sizeof(events))) > 0) {
|
||||
len /= sizeof(events[0]);
|
||||
for (i = 0; i < len; ++i) {
|
||||
@ -608,8 +643,8 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
}
|
||||
|
||||
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
|
||||
if (item->touchscreen_data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!item->touchscreen_data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
||||
@ -619,9 +654,9 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
}
|
||||
|
||||
item->touchscreen_data->name = SDL_strdup(name);
|
||||
if (item->touchscreen_data->name == NULL) {
|
||||
if (!item->touchscreen_data->name) {
|
||||
SDL_free(item->touchscreen_data);
|
||||
return SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info);
|
||||
@ -674,10 +709,10 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
item->touchscreen_data->slots = SDL_calloc(
|
||||
item->touchscreen_data->max_slots,
|
||||
sizeof(*item->touchscreen_data->slots));
|
||||
if (item->touchscreen_data->slots == NULL) {
|
||||
if (!item->touchscreen_data->slots) {
|
||||
SDL_free(item->touchscreen_data->name);
|
||||
SDL_free(item->touchscreen_data);
|
||||
return SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
|
||||
@ -735,7 +770,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
||||
sizeof(*mt_req_values) * item->touchscreen_data->max_slots;
|
||||
|
||||
mt_req_code = SDL_calloc(1, mt_req_size);
|
||||
if (mt_req_code == NULL) {
|
||||
if (!mt_req_code) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -840,15 +875,15 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
||||
|
||||
/* Check to make sure it's not already in list. */
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
if (SDL_strcmp(dev_path, item->path) == 0) {
|
||||
return -1; /* already have this one */
|
||||
}
|
||||
}
|
||||
|
||||
item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
|
||||
if (item == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!item) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
item->fd = open(dev_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
@ -858,12 +893,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
}
|
||||
|
||||
item->path = SDL_strdup(dev_path);
|
||||
if (item->path == NULL) {
|
||||
if (!item->path) {
|
||||
close(item->fd);
|
||||
SDL_free(item);
|
||||
return SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
item->udev_class = udev_class;
|
||||
|
||||
if (ioctl(item->fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0) {
|
||||
item->relative_mouse = test_bit(REL_X, relbit) && test_bit(REL_Y, relbit);
|
||||
item->high_res_wheel = test_bit(REL_WHEEL_HI_RES, relbit);
|
||||
@ -891,7 +928,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->last == NULL) {
|
||||
if (!_this->last) {
|
||||
_this->first = _this->last = item;
|
||||
} else {
|
||||
_this->last->next = item;
|
||||
@ -900,6 +937,8 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
|
||||
SDL_EVDEV_sync_device(item);
|
||||
|
||||
SDL_EVDEV_UpdateKeyboardMute();
|
||||
|
||||
return _this->num_devices++;
|
||||
}
|
||||
|
||||
@ -908,10 +947,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
|
||||
SDL_evdevlist_item *item;
|
||||
SDL_evdevlist_item *prev = NULL;
|
||||
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
/* found it, remove it. */
|
||||
if (SDL_strcmp(dev_path, item->path) == 0) {
|
||||
if (prev != NULL) {
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
} else {
|
||||
SDL_assert(_this->first == item);
|
||||
@ -926,6 +965,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
SDL_free(item);
|
||||
SDL_EVDEV_UpdateKeyboardMute();
|
||||
_this->num_devices--;
|
||||
return 0;
|
||||
}
|
||||
|
5
external/sdl/SDL/src/core/linux/SDL_evdev.h
vendored
5
external/sdl/SDL/src/core/linux/SDL_evdev.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -30,6 +30,9 @@ struct input_event;
|
||||
|
||||
extern int SDL_EVDEV_Init(void);
|
||||
extern void SDL_EVDEV_Quit(void);
|
||||
extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
||||
void (*acquire_callback)(void*), void *acquire_callback_data);
|
||||
extern int SDL_EVDEV_GetDeviceCount(int device_class);
|
||||
extern void SDL_EVDEV_Poll(void);
|
||||
extern Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2020 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2020 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@ -53,6 +53,7 @@ typedef enum
|
||||
SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020,
|
||||
SDL_UDEV_DEVICE_TOUCHPAD = 0x0040,
|
||||
SDL_UDEV_DEVICE_HAS_KEYS = 0x0080,
|
||||
SDL_UDEV_DEVICE_VIDEO_CAPTURE = 0x0100,
|
||||
} SDL_UDEV_deviceclass;
|
||||
|
||||
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
|
||||
|
225
external/sdl/SDL/src/core/linux/SDL_evdev_kbd.c
vendored
225
external/sdl/SDL/src/core/linux/SDL_evdev_kbd.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -84,6 +84,7 @@ static fn_handler_fn *fn_handler[] = {
|
||||
struct SDL_EVDEV_keyboard_state
|
||||
{
|
||||
int console_fd;
|
||||
SDL_bool muted;
|
||||
int old_kbd_mode;
|
||||
unsigned short **key_maps;
|
||||
unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
|
||||
@ -98,6 +99,10 @@ struct SDL_EVDEV_keyboard_state
|
||||
char shift_state;
|
||||
char text[128];
|
||||
unsigned int text_len;
|
||||
void (*vt_release_callback)(void *);
|
||||
void *vt_release_callback_data;
|
||||
void (*vt_acquire_callback)(void *);
|
||||
void *vt_acquire_callback_data;
|
||||
};
|
||||
|
||||
#ifdef DUMP_ACCENTS
|
||||
@ -168,7 +173,7 @@ static int fatal_signals[] = {
|
||||
static void kbd_cleanup(void)
|
||||
{
|
||||
SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state;
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return;
|
||||
}
|
||||
kbd_cleanup_state = NULL;
|
||||
@ -253,7 +258,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||
{
|
||||
int tabidx;
|
||||
|
||||
if (kbd_cleanup_state != NULL) {
|
||||
if (kbd_cleanup_state) {
|
||||
return;
|
||||
}
|
||||
kbd_cleanup_state = kbd;
|
||||
@ -295,6 +300,126 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
VT_SIGNAL_NONE,
|
||||
VT_SIGNAL_RELEASE,
|
||||
VT_SIGNAL_ACQUIRE,
|
||||
};
|
||||
static int vt_release_signal;
|
||||
static int vt_acquire_signal;
|
||||
static SDL_AtomicInt vt_signal_pending;
|
||||
|
||||
typedef void (*signal_handler)(int signum);
|
||||
|
||||
static void kbd_vt_release_signal_action(int signum)
|
||||
{
|
||||
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_RELEASE);
|
||||
}
|
||||
|
||||
static void kbd_vt_acquire_signal_action(int signum)
|
||||
{
|
||||
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
|
||||
}
|
||||
|
||||
static SDL_bool setup_vt_signal(int signum, signal_handler handler)
|
||||
{
|
||||
struct sigaction *old_action_p;
|
||||
struct sigaction new_action;
|
||||
old_action_p = &(old_sigaction[signum]);
|
||||
SDL_zero(new_action);
|
||||
new_action.sa_handler = handler;
|
||||
new_action.sa_flags = SA_RESTART;
|
||||
if (sigaction(signum, &new_action, old_action_p) < 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (old_action_p->sa_handler != SIG_DFL) {
|
||||
/* This signal is already in use */
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static int find_free_signal(signal_handler handler)
|
||||
{
|
||||
#ifdef SIGRTMIN
|
||||
int i;
|
||||
|
||||
for (i = SIGRTMIN + 2; i <= SIGRTMAX; ++i) {
|
||||
if (setup_vt_signal(i, handler)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (setup_vt_signal(SIGUSR1, handler)) {
|
||||
return SIGUSR1;
|
||||
}
|
||||
if (setup_vt_signal(SIGUSR2, handler)) {
|
||||
return SIGUSR2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kbd_vt_quit(int console_fd)
|
||||
{
|
||||
struct vt_mode mode;
|
||||
|
||||
if (vt_release_signal) {
|
||||
sigaction(vt_release_signal, &old_sigaction[vt_release_signal], NULL);
|
||||
vt_release_signal = 0;
|
||||
}
|
||||
if (vt_acquire_signal) {
|
||||
sigaction(vt_acquire_signal, &old_sigaction[vt_acquire_signal], NULL);
|
||||
vt_acquire_signal = 0;
|
||||
}
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.mode = VT_AUTO;
|
||||
ioctl(console_fd, VT_SETMODE, &mode);
|
||||
}
|
||||
|
||||
static int kbd_vt_init(int console_fd)
|
||||
{
|
||||
struct vt_mode mode;
|
||||
|
||||
vt_release_signal = find_free_signal(kbd_vt_release_signal_action);
|
||||
vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action);
|
||||
if (!vt_release_signal || !vt_acquire_signal ) {
|
||||
kbd_vt_quit(console_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.mode = VT_PROCESS;
|
||||
mode.relsig = vt_release_signal;
|
||||
mode.acqsig = vt_acquire_signal;
|
||||
mode.frsig = SIGIO;
|
||||
if (ioctl(console_fd, VT_SETMODE, &mode) < 0) {
|
||||
kbd_vt_quit(console_fd);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kbd_vt_update(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
int signal_pending = SDL_AtomicGet(&vt_signal_pending);
|
||||
if (signal_pending != VT_SIGNAL_NONE) {
|
||||
if (signal_pending == VT_SIGNAL_RELEASE) {
|
||||
if (state->vt_release_callback) {
|
||||
state->vt_release_callback(state->vt_release_callback_data);
|
||||
}
|
||||
ioctl(state->console_fd, VT_RELDISP, 1);
|
||||
} else {
|
||||
if (state->vt_acquire_callback) {
|
||||
state->vt_acquire_callback(state->vt_acquire_callback_data);
|
||||
}
|
||||
ioctl(state->console_fd, VT_RELDISP, VT_ACKACQ);
|
||||
}
|
||||
SDL_AtomicCAS(&vt_signal_pending, signal_pending, VT_SIGNAL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
{
|
||||
SDL_EVDEV_keyboard_state *kbd;
|
||||
@ -303,7 +428,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
char shift_state[sizeof(long)] = { TIOCL_GETSHIFTSTATE, 0 };
|
||||
|
||||
kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd));
|
||||
if (kbd == NULL) {
|
||||
if (!kbd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -332,35 +457,77 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE);
|
||||
}
|
||||
|
||||
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
|
||||
if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
|
||||
/* Mute the keyboard so keystrokes only generate evdev events
|
||||
* and do not leak through to the console
|
||||
*/
|
||||
ioctl(kbd->console_fd, KDSKBMODE, K_OFF);
|
||||
kbd_vt_init(kbd->console_fd);
|
||||
|
||||
/* Make sure to restore keyboard if application fails to call
|
||||
* SDL_Quit before exit or fatal signal is raised.
|
||||
*/
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
||||
kbd_register_emerg_cleanup(kbd);
|
||||
}
|
||||
}
|
||||
return kbd;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||
{
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (muted == state->muted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (muted) {
|
||||
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
|
||||
if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
|
||||
/* Mute the keyboard so keystrokes only generate evdev events
|
||||
* and do not leak through to the console
|
||||
*/
|
||||
ioctl(state->console_fd, KDSKBMODE, K_OFF);
|
||||
|
||||
/* Make sure to restore keyboard if application fails to call
|
||||
* SDL_Quit before exit or fatal signal is raised.
|
||||
*/
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
||||
kbd_register_emerg_cleanup(state);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kbd_unregister_emerg_cleanup();
|
||||
|
||||
/* Restore the original keyboard mode */
|
||||
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
|
||||
}
|
||||
state->muted = muted;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
||||
{
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
state->vt_release_callback = release_callback;
|
||||
state->vt_release_callback_data = release_callback_data;
|
||||
state->vt_acquire_callback = acquire_callback;
|
||||
state->vt_acquire_callback_data = acquire_callback_data;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_vt_update(state);
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_unregister_emerg_cleanup();
|
||||
SDL_EVDEV_kbd_set_muted(state, SDL_FALSE);
|
||||
|
||||
kbd_vt_quit(state->console_fd);
|
||||
|
||||
if (state->console_fd >= 0) {
|
||||
/* Restore the original keyboard mode */
|
||||
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
|
||||
|
||||
close(state->console_fd);
|
||||
state->console_fd = -1;
|
||||
}
|
||||
@ -725,7 +892,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
|
||||
unsigned short *key_map;
|
||||
unsigned short keysym;
|
||||
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -733,7 +900,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
|
||||
|
||||
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
|
||||
key_map = state->key_maps[shift_final];
|
||||
if (key_map == NULL) {
|
||||
if (!key_map) {
|
||||
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
|
||||
state->shift_state = 0;
|
||||
state->slockstate = 0;
|
||||
@ -808,6 +975,18 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down)
|
||||
{
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -26,6 +26,9 @@ struct SDL_EVDEV_keyboard_state;
|
||||
typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
|
||||
|
||||
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
|
||||
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted);
|
||||
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data);
|
||||
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
||||
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
||||
extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
46
external/sdl/SDL/src/core/linux/SDL_fcitx.c
vendored
46
external/sdl/SDL/src/core/linux/SDL_fcitx.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -29,7 +29,6 @@
|
||||
#ifdef SDL_VIDEO_DRIVER_X11
|
||||
#include "../../video/x11/SDL_x11video.h"
|
||||
#endif
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#define FCITX_DBUS_SERVICE "org.freedesktop.portal.Fcitx"
|
||||
|
||||
@ -212,26 +211,11 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
Sint32 start_pos, end_pos;
|
||||
size_t text_bytes = Fcitx_GetPreeditString(dbus, msg, &text, &start_pos, &end_pos);
|
||||
if (text_bytes) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE)) {
|
||||
if (start_pos == -1) {
|
||||
Sint32 byte_pos = Fcitx_GetPreeditCursorByte(dbus, msg);
|
||||
start_pos = byte_pos >= 0 ? SDL_utf8strnlen(text, byte_pos) : -1;
|
||||
}
|
||||
SDL_SendEditingText(text, start_pos, end_pos >= 0 ? end_pos - start_pos : -1);
|
||||
} else {
|
||||
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
size_t i = 0;
|
||||
size_t cursor = 0;
|
||||
while (i < text_bytes) {
|
||||
const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
|
||||
const size_t chars = SDL_utf8strlen(buf);
|
||||
|
||||
SDL_SendEditingText(buf, cursor, chars);
|
||||
|
||||
i += sz;
|
||||
cursor += chars;
|
||||
}
|
||||
if (start_pos == -1) {
|
||||
Sint32 byte_pos = Fcitx_GetPreeditCursorByte(dbus, msg);
|
||||
start_pos = byte_pos >= 0 ? SDL_utf8strnlen(text, byte_pos) : -1;
|
||||
}
|
||||
SDL_SendEditingText(text, start_pos, end_pos >= 0 ? end_pos - start_pos : -1);
|
||||
SDL_free(text);
|
||||
} else {
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
@ -427,7 +411,6 @@ SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect)
|
||||
{
|
||||
SDL_Window *focused_win = NULL;
|
||||
SDL_SysWMinfo info;
|
||||
int x = 0, y = 0;
|
||||
SDL_Rect *cursor = &fcitx_client.cursor_rect;
|
||||
|
||||
@ -436,23 +419,24 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect)
|
||||
}
|
||||
|
||||
focused_win = SDL_GetKeyboardFocus();
|
||||
if (focused_win == NULL) {
|
||||
if (!focused_win) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GetWindowPosition(focused_win, &x, &y);
|
||||
|
||||
if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) {
|
||||
#ifdef SDL_ENABLE_SYSWM_X11
|
||||
if (info.subsystem == SDL_SYSWM_X11) {
|
||||
Display *x_disp = info.info.x11.display;
|
||||
int x_screen = info.info.x11.screen;
|
||||
Window x_win = info.info.x11.window;
|
||||
Window unused;
|
||||
#ifdef SDL_VIDEO_DRIVER_X11
|
||||
{
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(focused_win);
|
||||
Display *x_disp = (Display *)SDL_GetProperty(props, SDL_PROPERTY_WINDOW_X11_DISPLAY_POINTER, NULL);
|
||||
int x_screen = SDL_GetNumberProperty(props, SDL_PROPERTY_WINDOW_X11_SCREEN_NUMBER, 0);
|
||||
Window x_win = SDL_GetNumberProperty(props, SDL_PROPERTY_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
Window unused;
|
||||
if (x_disp && x_win) {
|
||||
X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) {
|
||||
/* move to bottom left */
|
||||
|
2
external/sdl/SDL/src/core/linux/SDL_fcitx.h
vendored
2
external/sdl/SDL/src/core/linux/SDL_fcitx.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
102
external/sdl/SDL/src/core/linux/SDL_ibus.c
vendored
102
external/sdl/SDL/src/core/linux/SDL_ibus.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -32,7 +32,6 @@
|
||||
#ifdef SDL_VIDEO_DRIVER_X11
|
||||
#include "../../video/x11/SDL_x11video.h"
|
||||
#endif
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#include <sys/inotify.h>
|
||||
#include <unistd.h>
|
||||
@ -113,7 +112,7 @@ static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, S
|
||||
}
|
||||
|
||||
dbus->message_iter_get_basic(inside, &struct_id);
|
||||
if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
|
||||
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
@ -252,38 +251,23 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
|
||||
text = IBus_GetVariantText(conn, &iter, dbus);
|
||||
|
||||
if (text) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE)) {
|
||||
Uint32 pos, start_pos, end_pos;
|
||||
SDL_bool has_pos = SDL_FALSE;
|
||||
SDL_bool has_dec_pos = SDL_FALSE;
|
||||
Uint32 pos, start_pos, end_pos;
|
||||
SDL_bool has_pos = SDL_FALSE;
|
||||
SDL_bool has_dec_pos = SDL_FALSE;
|
||||
|
||||
dbus->message_iter_init(msg, &iter);
|
||||
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
|
||||
if (!has_dec_pos) {
|
||||
dbus->message_iter_init(msg, &iter);
|
||||
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
|
||||
if (!has_dec_pos) {
|
||||
dbus->message_iter_init(msg, &iter);
|
||||
has_pos = IBus_GetVariantCursorPos(conn, &iter, dbus, &pos);
|
||||
}
|
||||
has_pos = IBus_GetVariantCursorPos(conn, &iter, dbus, &pos);
|
||||
}
|
||||
|
||||
if (has_dec_pos) {
|
||||
SDL_SendEditingText(text, start_pos, end_pos - start_pos);
|
||||
} else if (has_pos) {
|
||||
SDL_SendEditingText(text, pos, -1);
|
||||
} else {
|
||||
SDL_SendEditingText(text, -1, -1);
|
||||
}
|
||||
if (has_dec_pos) {
|
||||
SDL_SendEditingText(text, start_pos, end_pos - start_pos);
|
||||
} else if (has_pos) {
|
||||
SDL_SendEditingText(text, pos, -1);
|
||||
} else {
|
||||
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
size_t text_bytes = SDL_strlen(text), i = 0;
|
||||
size_t cursor = 0;
|
||||
|
||||
do {
|
||||
const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
|
||||
const size_t chars = SDL_utf8strlen(buf);
|
||||
|
||||
SDL_SendEditingText(buf, cursor, chars);
|
||||
i += sz;
|
||||
cursor += chars;
|
||||
} while (i < text_bytes);
|
||||
SDL_SendEditingText(text, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +291,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
|
||||
FILE *addr_file;
|
||||
|
||||
addr_file = fopen(file_path, "r");
|
||||
if (addr_file == NULL) {
|
||||
if (!addr_file) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -352,7 +336,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
}
|
||||
|
||||
dbus = SDL_DBus_GetContext();
|
||||
if (dbus == NULL) {
|
||||
if (!dbus) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -366,7 +350,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
and look up the address from a filepath using all those bits, eek. */
|
||||
disp_env = SDL_getenv("DISPLAY");
|
||||
|
||||
if (disp_env == NULL || !*disp_env) {
|
||||
if (!disp_env || !*disp_env) {
|
||||
display = SDL_strdup(":0.0");
|
||||
} else {
|
||||
display = SDL_strdup(disp_env);
|
||||
@ -376,7 +360,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
disp_num = SDL_strrchr(display, ':');
|
||||
screen_num = SDL_strrchr(display, '.');
|
||||
|
||||
if (disp_num == NULL) {
|
||||
if (!disp_num) {
|
||||
SDL_free(display);
|
||||
return NULL;
|
||||
}
|
||||
@ -390,7 +374,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
|
||||
if (!*host) {
|
||||
const char *session = SDL_getenv("XDG_SESSION_TYPE");
|
||||
if (session != NULL && SDL_strcmp(session, "wayland") == 0) {
|
||||
if (session && SDL_strcmp(session, "wayland") == 0) {
|
||||
host = "unix-wayland";
|
||||
} else {
|
||||
host = "unix";
|
||||
@ -404,7 +388,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
SDL_strlcpy(config_dir, conf_env, sizeof(config_dir));
|
||||
} else {
|
||||
const char *home_env = SDL_getenv("HOME");
|
||||
if (home_env == NULL || !*home_env) {
|
||||
if (!home_env || !*home_env) {
|
||||
SDL_free(display);
|
||||
return NULL;
|
||||
}
|
||||
@ -413,7 +397,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
|
||||
key = SDL_DBus_GetLocalMachineId();
|
||||
|
||||
if (key == NULL) {
|
||||
if (!key) {
|
||||
SDL_free(display);
|
||||
return NULL;
|
||||
}
|
||||
@ -474,7 +458,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||
ibus_input_interface = IBUS_INPUT_INTERFACE;
|
||||
ibus_conn = dbus->connection_open_private(addr, NULL);
|
||||
|
||||
if (ibus_conn == NULL) {
|
||||
if (!ibus_conn) {
|
||||
return SDL_FALSE; /* oh well. */
|
||||
}
|
||||
|
||||
@ -514,7 +498,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||
|
||||
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||
{
|
||||
if (dbus == NULL) {
|
||||
if (!dbus) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@ -534,7 +518,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||
struct inotify_event *event = (struct inotify_event *)p;
|
||||
if (event->len > 0) {
|
||||
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
|
||||
if (addr_file_no_path == NULL) {
|
||||
if (!addr_file_no_path) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@ -571,19 +555,21 @@ SDL_bool SDL_IBus_Init(void)
|
||||
char *addr;
|
||||
char *addr_file_dir;
|
||||
|
||||
if (addr_file == NULL) {
|
||||
if (!addr_file) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* !!! FIXME: if ibus_addr_file != NULL, this will overwrite it and leak (twice!) */
|
||||
ibus_addr_file = SDL_strdup(addr_file);
|
||||
|
||||
addr = IBus_ReadAddressFromFile(addr_file);
|
||||
if (addr == NULL) {
|
||||
if (!addr) {
|
||||
SDL_free(addr_file);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (ibus_addr_file) {
|
||||
SDL_free(ibus_addr_file);
|
||||
}
|
||||
ibus_addr_file = SDL_strdup(addr_file);
|
||||
|
||||
if (inotify_fd < 0) {
|
||||
inotify_fd = inotify_init();
|
||||
fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
|
||||
@ -660,7 +646,7 @@ static void IBus_SimpleMessage(const char *method)
|
||||
{
|
||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||
|
||||
if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) {
|
||||
if ((input_ctx_path) && (IBus_CheckConnection(dbus))) {
|
||||
SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, method, DBUS_TYPE_INVALID);
|
||||
}
|
||||
}
|
||||
@ -696,13 +682,12 @@ SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
|
||||
SDL_IBus_UpdateTextRect(NULL);
|
||||
|
||||
return result ? SDL_TRUE : SDL_FALSE;
|
||||
return (result != 0);
|
||||
}
|
||||
|
||||
void SDL_IBus_UpdateTextRect(const SDL_Rect *rect)
|
||||
{
|
||||
SDL_Window *focused_win;
|
||||
SDL_SysWMinfo info;
|
||||
int x = 0, y = 0;
|
||||
SDL_DBusContext *dbus;
|
||||
|
||||
@ -711,24 +696,25 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect)
|
||||
}
|
||||
|
||||
focused_win = SDL_GetKeyboardFocus();
|
||||
if (focused_win == NULL) {
|
||||
if (!focused_win) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GetWindowPosition(focused_win, &x, &y);
|
||||
|
||||
if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) {
|
||||
#ifdef SDL_ENABLE_SYSWM_X11
|
||||
if (info.subsystem == SDL_SYSWM_X11) {
|
||||
Display *x_disp = info.info.x11.display;
|
||||
int x_screen = info.info.x11.screen;
|
||||
Window x_win = info.info.x11.window;
|
||||
Window unused;
|
||||
#ifdef SDL_VIDEO_DRIVER_X11
|
||||
{
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(focused_win);
|
||||
Display *x_disp = (Display *)SDL_GetProperty(props, SDL_PROPERTY_WINDOW_X11_DISPLAY_POINTER, NULL);
|
||||
int x_screen = SDL_GetNumberProperty(props, SDL_PROPERTY_WINDOW_X11_SCREEN_NUMBER, 0);
|
||||
Window x_win = SDL_GetNumberProperty(props, SDL_PROPERTY_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
Window unused;
|
||||
|
||||
if (x_disp && x_win) {
|
||||
X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
x += ibus_cursor_rect.x;
|
||||
y += ibus_cursor_rect.y;
|
||||
|
2
external/sdl/SDL/src/core/linux/SDL_ibus.h
vendored
2
external/sdl/SDL/src/core/linux/SDL_ibus.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
8
external/sdl/SDL/src/core/linux/SDL_ime.c
vendored
8
external/sdl/SDL/src/core/linux/SDL_ime.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -56,9 +56,9 @@ static void InitIME(void)
|
||||
|
||||
/* See if fcitx IME support is being requested */
|
||||
#ifdef HAVE_FCITX
|
||||
if (SDL_IME_Init_Real == NULL &&
|
||||
if (!SDL_IME_Init_Real &&
|
||||
((im_module && SDL_strcmp(im_module, "fcitx") == 0) ||
|
||||
(im_module == NULL && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) {
|
||||
(!im_module && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) {
|
||||
SDL_IME_Init_Real = SDL_Fcitx_Init;
|
||||
SDL_IME_Quit_Real = SDL_Fcitx_Quit;
|
||||
SDL_IME_SetFocus_Real = SDL_Fcitx_SetFocus;
|
||||
@ -71,7 +71,7 @@ static void InitIME(void)
|
||||
|
||||
/* default to IBus */
|
||||
#ifdef HAVE_IBUS_IBUS_H
|
||||
if (SDL_IME_Init_Real == NULL) {
|
||||
if (!SDL_IME_Init_Real) {
|
||||
SDL_IME_Init_Real = SDL_IBus_Init;
|
||||
SDL_IME_Quit_Real = SDL_IBus_Quit;
|
||||
SDL_IME_SetFocus_Real = SDL_IBus_SetFocus;
|
||||
|
2
external/sdl/SDL/src/core/linux/SDL_ime.h
vendored
2
external/sdl/SDL/src/core/linux/SDL_ime.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2022 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2022 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -115,12 +115,12 @@ SDL_bool SDL_SystemTheme_Init(void)
|
||||
|
||||
system_theme_data.theme = SDL_SYSTEM_THEME_UNKNOWN;
|
||||
system_theme_data.dbus = dbus;
|
||||
if (dbus == NULL) {
|
||||
if (!dbus) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, PORTAL_METHOD);
|
||||
if (msg != NULL) {
|
||||
if (msg) {
|
||||
if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &namespace, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) {
|
||||
DBusMessage *reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
|
||||
if (reply) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
12
external/sdl/SDL/src/core/linux/SDL_threadprio.c
vendored
12
external/sdl/SDL/src/core/linux/SDL_threadprio.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -111,19 +111,19 @@ static void rtkit_initialize(void)
|
||||
dbus_conn = get_rtkit_dbus_connection();
|
||||
|
||||
/* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
|
||||
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
|
||||
DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
|
||||
rtkit_min_nice_level = -20;
|
||||
}
|
||||
|
||||
/* Try getting maximum realtime priority: this can be less than the POSIX default (99). */
|
||||
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
|
||||
DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) {
|
||||
rtkit_max_realtime_priority = 99;
|
||||
}
|
||||
|
||||
/* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */
|
||||
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
|
||||
DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) {
|
||||
rtkit_max_rttime_usec = 200000;
|
||||
}
|
||||
@ -202,7 +202,7 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
|
||||
nice = rtkit_min_nice_level;
|
||||
}
|
||||
|
||||
if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
|
||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
@ -233,7 +233,7 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||
// go through to determine whether it really needs to fail or not.
|
||||
rtkit_initialize_realtime_thread();
|
||||
|
||||
if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
|
||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
|
148
external/sdl/SDL/src/core/linux/SDL_udev.c
vendored
148
external/sdl/SDL/src/core/linux/SDL_udev.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -42,12 +42,15 @@ static SDL_UDEV_PrivateData *_this = NULL;
|
||||
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
|
||||
static int SDL_UDEV_load_syms(void);
|
||||
static SDL_bool SDL_UDEV_hotplug_update_available(void);
|
||||
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len);
|
||||
static int guess_device_class(struct udev_device *dev);
|
||||
static int device_class(struct udev_device *dev);
|
||||
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
|
||||
|
||||
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(_this->udev_handle, fn);
|
||||
if (*addr == NULL) {
|
||||
if (!*addr) {
|
||||
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@ -96,7 +99,7 @@ static int SDL_UDEV_load_syms(void)
|
||||
|
||||
static SDL_bool SDL_UDEV_hotplug_update_available(void)
|
||||
{
|
||||
if (_this->udev_mon != NULL) {
|
||||
if (_this->udev_mon) {
|
||||
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
|
||||
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
|
||||
return SDL_TRUE;
|
||||
@ -109,10 +112,10 @@ int SDL_UDEV_Init(void)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
_this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
|
||||
if (_this == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!_this) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = SDL_UDEV_LoadLibrary();
|
||||
@ -126,19 +129,20 @@ int SDL_UDEV_Init(void)
|
||||
*/
|
||||
|
||||
_this->udev = _this->syms.udev_new();
|
||||
if (_this->udev == NULL) {
|
||||
if (!_this->udev) {
|
||||
SDL_UDEV_Quit();
|
||||
return SDL_SetError("udev_new() failed");
|
||||
}
|
||||
|
||||
_this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev");
|
||||
if (_this->udev_mon == NULL) {
|
||||
if (!_this->udev_mon) {
|
||||
SDL_UDEV_Quit();
|
||||
return SDL_SetError("udev_monitor_new_from_netlink() failed");
|
||||
}
|
||||
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL);
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "video4linux", NULL);
|
||||
_this->syms.udev_monitor_enable_receiving(_this->udev_mon);
|
||||
|
||||
/* Do an initial scan of existing devices */
|
||||
@ -152,7 +156,7 @@ int SDL_UDEV_Init(void)
|
||||
|
||||
void SDL_UDEV_Quit(void)
|
||||
{
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,17 +164,17 @@ void SDL_UDEV_Quit(void)
|
||||
|
||||
if (_this->ref_count < 1) {
|
||||
|
||||
if (_this->udev_mon != NULL) {
|
||||
if (_this->udev_mon) {
|
||||
_this->syms.udev_monitor_unref(_this->udev_mon);
|
||||
_this->udev_mon = NULL;
|
||||
}
|
||||
if (_this->udev != NULL) {
|
||||
if (_this->udev) {
|
||||
_this->syms.udev_unref(_this->udev);
|
||||
_this->udev = NULL;
|
||||
}
|
||||
|
||||
/* Remove existing devices */
|
||||
while (_this->first != NULL) {
|
||||
while (_this->first) {
|
||||
SDL_UDEV_CallbackList *item = _this->first;
|
||||
_this->first = _this->first->next;
|
||||
SDL_free(item);
|
||||
@ -188,25 +192,26 @@ int SDL_UDEV_Scan(void)
|
||||
struct udev_list_entry *devs = NULL;
|
||||
struct udev_list_entry *item = NULL;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
enumerate = _this->syms.udev_enumerate_new(_this->udev);
|
||||
if (enumerate == NULL) {
|
||||
if (!enumerate) {
|
||||
SDL_UDEV_Quit();
|
||||
return SDL_SetError("udev_enumerate_new() failed");
|
||||
}
|
||||
|
||||
_this->syms.udev_enumerate_add_match_subsystem(enumerate, "input");
|
||||
_this->syms.udev_enumerate_add_match_subsystem(enumerate, "sound");
|
||||
_this->syms.udev_enumerate_add_match_subsystem(enumerate, "video4linux");
|
||||
|
||||
_this->syms.udev_enumerate_scan_devices(enumerate);
|
||||
devs = _this->syms.udev_enumerate_get_list_entry(enumerate);
|
||||
for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) {
|
||||
const char *path = _this->syms.udev_list_entry_get_name(item);
|
||||
struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
|
||||
if (dev != NULL) {
|
||||
if (dev) {
|
||||
device_event(SDL_UDEV_DEVICEADDED, dev);
|
||||
_this->syms.udev_device_unref(dev);
|
||||
}
|
||||
@ -216,19 +221,19 @@ int SDL_UDEV_Scan(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version)
|
||||
SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
|
||||
{
|
||||
struct udev_enumerate *enumerate = NULL;
|
||||
struct udev_list_entry *devs = NULL;
|
||||
struct udev_list_entry *item = NULL;
|
||||
SDL_bool found = SDL_FALSE;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
enumerate = _this->syms.udev_enumerate_new(_this->udev);
|
||||
if (enumerate == NULL) {
|
||||
if (!enumerate) {
|
||||
SDL_SetError("udev_enumerate_new() failed");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@ -238,28 +243,34 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
|
||||
for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) {
|
||||
const char *path = _this->syms.udev_list_entry_get_name(item);
|
||||
struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
|
||||
if (dev != NULL) {
|
||||
if (dev) {
|
||||
const char *val = NULL;
|
||||
const char *existing_path;
|
||||
|
||||
existing_path = _this->syms.udev_device_get_devnode(dev);
|
||||
if (existing_path && SDL_strcmp(device_path, existing_path) == 0) {
|
||||
int class_temp;
|
||||
found = SDL_TRUE;
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
|
||||
if (val != NULL) {
|
||||
if (val) {
|
||||
*vendor = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID");
|
||||
if (val != NULL) {
|
||||
if (val) {
|
||||
*product = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION");
|
||||
if (val != NULL) {
|
||||
if (val) {
|
||||
*version = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
|
||||
class_temp = device_class(dev);
|
||||
if (class_temp) {
|
||||
*class = class_temp;
|
||||
}
|
||||
}
|
||||
_this->syms.udev_device_unref(dev);
|
||||
}
|
||||
@ -271,11 +282,11 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
|
||||
|
||||
void SDL_UDEV_UnloadLibrary(void)
|
||||
{
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_this->udev_handle != NULL) {
|
||||
if (_this->udev_handle) {
|
||||
SDL_UnloadObject(_this->udev_handle);
|
||||
_this->udev_handle = NULL;
|
||||
}
|
||||
@ -285,7 +296,7 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
{
|
||||
int retval = 0, i;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return SDL_SetError("UDEV not initialized");
|
||||
}
|
||||
|
||||
@ -296,9 +307,9 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
|
||||
#ifdef SDL_UDEV_DYNAMIC
|
||||
/* Check for the build environment's libudev first */
|
||||
if (_this->udev_handle == NULL) {
|
||||
if (!_this->udev_handle) {
|
||||
_this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
|
||||
if (_this->udev_handle != NULL) {
|
||||
if (_this->udev_handle) {
|
||||
retval = SDL_UDEV_load_syms();
|
||||
if (retval < 0) {
|
||||
SDL_UDEV_UnloadLibrary();
|
||||
@ -307,10 +318,10 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_this->udev_handle == NULL) {
|
||||
if (!_this->udev_handle) {
|
||||
for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
|
||||
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
|
||||
if (_this->udev_handle != NULL) {
|
||||
if (_this->udev_handle) {
|
||||
retval = SDL_UDEV_load_syms();
|
||||
if (retval < 0) {
|
||||
SDL_UDEV_UnloadLibrary();
|
||||
@ -320,7 +331,7 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->udev_handle == NULL) {
|
||||
if (!_this->udev_handle) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
}
|
||||
@ -339,7 +350,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch
|
||||
|
||||
SDL_memset(bitmask, 0, bitmask_len * sizeof(*bitmask));
|
||||
value = _this->syms.udev_device_get_sysattr_value(pdev, attr);
|
||||
if (value == NULL) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -374,7 +385,7 @@ static int guess_device_class(struct udev_device *dev)
|
||||
while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
|
||||
pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
|
||||
}
|
||||
if (pdev == NULL) {
|
||||
if (!pdev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -391,43 +402,45 @@ static int guess_device_class(struct udev_device *dev)
|
||||
&bitmask_rel[0]);
|
||||
}
|
||||
|
||||
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
static int device_class(struct udev_device *dev)
|
||||
{
|
||||
const char *subsystem;
|
||||
const char *val = NULL;
|
||||
int devclass = 0;
|
||||
const char *path;
|
||||
SDL_UDEV_CallbackList *item;
|
||||
|
||||
path = _this->syms.udev_device_get_devnode(dev);
|
||||
if (path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
subsystem = _this->syms.udev_device_get_subsystem(dev);
|
||||
if (!subsystem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(subsystem, "sound") == 0) {
|
||||
devclass = SDL_UDEV_DEVICE_SOUND;
|
||||
} else if (SDL_strcmp(subsystem, "video4linux") == 0) {
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_V4L_CAPABILITIES");
|
||||
if (val && SDL_strcasestr(val, "capture")) {
|
||||
devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE;
|
||||
}
|
||||
} else if (SDL_strcmp(subsystem, "input") == 0) {
|
||||
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
|
||||
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
|
||||
val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE;
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN;
|
||||
}
|
||||
|
||||
@ -438,39 +451,54 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
|
||||
*/
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_HAS_KEYS;
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0) {
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_KEYBOARD;
|
||||
}
|
||||
|
||||
if (devclass == 0) {
|
||||
/* Fall back to old style input classes */
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS");
|
||||
if (val != NULL) {
|
||||
if (val) {
|
||||
if (SDL_strcmp(val, "joystick") == 0) {
|
||||
devclass = SDL_UDEV_DEVICE_JOYSTICK;
|
||||
} else if (SDL_strcmp(val, "mouse") == 0) {
|
||||
devclass = SDL_UDEV_DEVICE_MOUSE;
|
||||
} else if (SDL_strcmp(val, "kbd") == 0) {
|
||||
devclass = SDL_UDEV_DEVICE_HAS_KEYS | SDL_UDEV_DEVICE_KEYBOARD;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* We could be linked with libudev on a system that doesn't have udev running */
|
||||
devclass = guess_device_class(dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return devclass;
|
||||
}
|
||||
|
||||
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
{
|
||||
int devclass = 0;
|
||||
const char *path;
|
||||
SDL_UDEV_CallbackList *item;
|
||||
|
||||
path = _this->syms.udev_device_get_devnode(dev);
|
||||
if (!path) {
|
||||
return;
|
||||
}
|
||||
|
||||
devclass = device_class(dev);
|
||||
if (!devclass) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Process callbacks */
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
item->callback(type, devclass, path);
|
||||
}
|
||||
}
|
||||
@ -480,13 +508,13 @@ void SDL_UDEV_Poll(void)
|
||||
struct udev_device *dev = NULL;
|
||||
const char *action = NULL;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (SDL_UDEV_hotplug_update_available()) {
|
||||
dev = _this->syms.udev_monitor_receive_device(_this->udev_mon);
|
||||
if (dev == NULL) {
|
||||
if (!dev) {
|
||||
break;
|
||||
}
|
||||
action = _this->syms.udev_device_get_action(dev);
|
||||
@ -507,20 +535,20 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList));
|
||||
if (item == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!item) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
item->callback = cb;
|
||||
|
||||
if (_this->last == NULL) {
|
||||
if (!_this->last) {
|
||||
_this->first = _this->last = item;
|
||||
} else {
|
||||
_this->last->next = item;
|
||||
_this->last = item;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
@ -528,14 +556,14 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
SDL_UDEV_CallbackList *item;
|
||||
SDL_UDEV_CallbackList *prev = NULL;
|
||||
|
||||
if (_this == NULL) {
|
||||
if (!_this) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
/* found it, remove it. */
|
||||
if (item->callback == cb) {
|
||||
if (prev != NULL) {
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
} else {
|
||||
SDL_assert(_this->first == item);
|
||||
|
6
external/sdl/SDL/src/core/linux/SDL_udev.h
vendored
6
external/sdl/SDL/src/core/linux/SDL_udev.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -35,7 +35,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* \brief Device type
|
||||
* Device type
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
@ -102,7 +102,7 @@ extern void SDL_UDEV_UnloadLibrary(void);
|
||||
extern int SDL_UDEV_LoadLibrary(void);
|
||||
extern void SDL_UDEV_Poll(void);
|
||||
extern int SDL_UDEV_Scan(void);
|
||||
extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version);
|
||||
extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);
|
||||
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
|
||||
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
||||
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
||||
|
2
external/sdl/SDL/src/core/n3ds/SDL_n3ds.c
vendored
2
external/sdl/SDL/src/core/n3ds/SDL_n3ds.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -57,7 +57,7 @@ SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * reserved
|
||||
|
||||
newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy);
|
||||
|
||||
if (newHeap == NULL) {
|
||||
if (!newHeap) {
|
||||
ret = 3;
|
||||
goto cleanup;
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -419,7 +419,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
|
||||
#endif
|
||||
SDL_WSCONS_input_data *input = (SDL_WSCONS_input_data *)SDL_calloc(1, sizeof(SDL_WSCONS_input_data));
|
||||
|
||||
if (input == NULL) {
|
||||
if (!input) {
|
||||
return input;
|
||||
}
|
||||
input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
@ -429,7 +429,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
|
||||
return NULL;
|
||||
}
|
||||
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
|
||||
if (input->keymap.map == NULL) {
|
||||
if (!input->keymap.map) {
|
||||
SDL_free(input);
|
||||
return NULL;
|
||||
}
|
||||
@ -579,7 +579,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
|
||||
keysym_t *group;
|
||||
keysym_t ksym, result;
|
||||
|
||||
if (input == NULL) {
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
if ((n = read(input->fd, events, sizeof(events))) > 0) {
|
||||
@ -923,7 +923,7 @@ void SDL_WSCONS_PumpEvents()
|
||||
for (i = 0; i < 4; i++) {
|
||||
updateKeyboard(inputs[i]);
|
||||
}
|
||||
if (mouseInputData != NULL) {
|
||||
if (mouseInputData) {
|
||||
updateMouse(mouseInputData);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -41,7 +41,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse()
|
||||
#endif
|
||||
SDL_WSCONS_mouse_input_data *mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data));
|
||||
|
||||
if (mouseInputData == NULL) {
|
||||
if (!mouseInputData) {
|
||||
return NULL;
|
||||
}
|
||||
mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
@ -125,7 +125,7 @@ void updateMouse(SDL_WSCONS_mouse_input_data *inputData)
|
||||
|
||||
void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData)
|
||||
{
|
||||
if (inputData == NULL) {
|
||||
if (!inputData) {
|
||||
return;
|
||||
}
|
||||
close(inputData->fd);
|
||||
|
2
external/sdl/SDL/src/core/ps2/SDL_ps2.c
vendored
2
external/sdl/SDL/src/core/ps2/SDL_ps2.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/psp/SDL_psp.c
vendored
2
external/sdl/SDL/src/core/psp/SDL_psp.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/unix/SDL_appid.c
vendored
2
external/sdl/SDL/src/core/unix/SDL_appid.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/unix/SDL_appid.h
vendored
2
external/sdl/SDL/src/core/unix/SDL_appid.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/unix/SDL_poll.c
vendored
2
external/sdl/SDL/src/core/unix/SDL_poll.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/unix/SDL_poll.h
vendored
2
external/sdl/SDL/src/core/unix/SDL_poll.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
8
external/sdl/SDL/src/core/windows/SDL_hid.c
vendored
8
external/sdl/SDL/src/core/windows/SDL_hid.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -58,9 +58,9 @@ int WIN_LoadHIDDLL(void)
|
||||
SDL_HidP_GetValueCaps = (HidP_GetValueCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetValueCaps");
|
||||
SDL_HidP_MaxDataListLength = (HidP_MaxDataListLength_t)GetProcAddress(s_pHIDDLL, "HidP_MaxDataListLength");
|
||||
SDL_HidP_GetData = (HidP_GetData_t)GetProcAddress(s_pHIDDLL, "HidP_GetData");
|
||||
if (SDL_HidD_GetManufacturerString == NULL || SDL_HidD_GetProductString == NULL ||
|
||||
SDL_HidP_GetCaps == NULL || SDL_HidP_GetButtonCaps == NULL ||
|
||||
SDL_HidP_GetValueCaps == NULL || SDL_HidP_MaxDataListLength == NULL || SDL_HidP_GetData == NULL) {
|
||||
if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString ||
|
||||
!SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
|
||||
!SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) {
|
||||
WIN_UnloadHIDDLL();
|
||||
return -1;
|
||||
}
|
||||
|
2
external/sdl/SDL/src/core/windows/SDL_hid.h
vendored
2
external/sdl/SDL/src/core/windows/SDL_hid.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -37,6 +37,7 @@ static const ERole SDL_IMMDevice_role = eConsole; /* !!! FIXME: should this be e
|
||||
|
||||
/* This is global to the WASAPI target, to handle hotplug and default device lookup. */
|
||||
static IMMDeviceEnumerator *enumerator = NULL;
|
||||
static SDL_IMMDevice_callbacks immcallbacks;
|
||||
|
||||
/* PropVariantInit() is an inline function/macro in PropIdl.h that calls the C runtime's memset() directly. Use ours instead, to avoid dependency. */
|
||||
#ifdef PropVariantInit
|
||||
@ -102,7 +103,7 @@ static void GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSI
|
||||
}
|
||||
PropVariantClear(&var);
|
||||
if (SUCCEEDED(IPropertyStore_GetValue(props, &SDL_PKEY_AudioEndpoint_GUID, &var))) {
|
||||
CLSIDFromString(var.pwszVal, guid);
|
||||
(void)CLSIDFromString(var.pwszVal, guid);
|
||||
}
|
||||
PropVariantClear(&var);
|
||||
IPropertyStore_Release(props);
|
||||
@ -132,16 +133,26 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool iscapture, const char *
|
||||
|
||||
// see if we already have this one first.
|
||||
SDL_AudioDevice *device = SDL_IMMDevice_FindByDevID(devid);
|
||||
if (device) {
|
||||
if (SDL_AtomicGet(&device->zombie)) {
|
||||
// whoa, it came back! This can happen if you unplug and replug USB headphones while we're still keeping the SDL object alive.
|
||||
// Kill this device's IMMDevice id; the device will go away when the app closes it, or maybe a new default device is chosen
|
||||
// (possibly this reconnected device), so we just want to make sure IMMDevice doesn't try to find the old device by the existing ID string.
|
||||
SDL_IMMDevice_HandleData *handle = (SDL_IMMDevice_HandleData *) device->handle;
|
||||
SDL_free(handle->immdevice_id);
|
||||
handle->immdevice_id = NULL;
|
||||
device = NULL; // add a new device, below.
|
||||
}
|
||||
}
|
||||
|
||||
if (!device) {
|
||||
// handle is freed by SDL_IMMDevice_FreeDeviceHandle!
|
||||
SDL_IMMDevice_HandleData *handle = SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
|
||||
if (!handle) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
handle->immdevice_id = SDL_wcsdup(devid);
|
||||
if (!handle->immdevice_id) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(handle);
|
||||
return NULL;
|
||||
}
|
||||
@ -154,6 +165,10 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool iscapture, const char *
|
||||
spec.format = SDL_WaveFormatExToSDLFormat((WAVEFORMATEX *)fmt);
|
||||
|
||||
device = SDL_AddAudioDevice(iscapture, devname, &spec, handle);
|
||||
if (!device) {
|
||||
SDL_free(handle->immdevice_id);
|
||||
SDL_free(handle);
|
||||
}
|
||||
}
|
||||
|
||||
return device;
|
||||
@ -204,7 +219,7 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationCl
|
||||
static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *iclient, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId)
|
||||
{
|
||||
if (role == SDL_IMMDevice_role) {
|
||||
SDL_DefaultAudioDeviceChanged(SDL_IMMDevice_FindByDevID(pwstrDeviceId));
|
||||
immcallbacks.default_audio_device_changed(SDL_IMMDevice_FindByDevID(pwstrDeviceId));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@ -244,7 +259,7 @@ static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IM
|
||||
SDL_free(utf8dev);
|
||||
}
|
||||
} else {
|
||||
SDL_AudioDeviceDisconnected(SDL_IMMDevice_FindByDevID(pwstrDeviceId));
|
||||
immcallbacks.audio_device_disconnected(SDL_IMMDevice_FindByDevID(pwstrDeviceId));
|
||||
}
|
||||
}
|
||||
IMMEndpoint_Release(endpoint);
|
||||
@ -273,7 +288,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = {
|
||||
|
||||
static SDLMMNotificationClient notification_client = { ¬ification_client_vtbl, { 1 } };
|
||||
|
||||
int SDL_IMMDevice_Init(void)
|
||||
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
|
||||
{
|
||||
HRESULT ret;
|
||||
|
||||
@ -291,6 +306,20 @@ int SDL_IMMDevice_Init(void)
|
||||
WIN_CoUninitialize();
|
||||
return WIN_SetErrorFromHRESULT("IMMDevice CoCreateInstance(MMDeviceEnumerator)", ret);
|
||||
}
|
||||
|
||||
if (callbacks) {
|
||||
SDL_copyp(&immcallbacks, callbacks);
|
||||
} else {
|
||||
SDL_zero(immcallbacks);
|
||||
}
|
||||
|
||||
if (!immcallbacks.audio_device_disconnected) {
|
||||
immcallbacks.audio_device_disconnected = SDL_AudioDeviceDisconnected;
|
||||
}
|
||||
if (!immcallbacks.default_audio_device_changed) {
|
||||
immcallbacks.default_audio_device_changed = SDL_DefaultAudioDeviceChanged;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -302,6 +331,8 @@ void SDL_IMMDevice_Quit(void)
|
||||
enumerator = NULL;
|
||||
}
|
||||
|
||||
SDL_zero(immcallbacks);
|
||||
|
||||
WIN_CoUninitialize();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -28,7 +28,13 @@
|
||||
|
||||
typedef struct SDL_AudioDevice SDL_AudioDevice; // this is defined in src/audio/SDL_sysaudio.h
|
||||
|
||||
int SDL_IMMDevice_Init(void);
|
||||
typedef struct SDL_IMMDevice_callbacks
|
||||
{
|
||||
void (*audio_device_disconnected)(SDL_AudioDevice *device);
|
||||
void (*default_audio_device_changed)(SDL_AudioDevice *new_default_device);
|
||||
} SDL_IMMDevice_callbacks;
|
||||
|
||||
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
|
||||
void SDL_IMMDevice_Quit(void);
|
||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool iscapture);
|
||||
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture);
|
||||
|
10
external/sdl/SDL/src/core/windows/SDL_windows.c
vendored
10
external/sdl/SDL/src/core/windows/SDL_windows.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -283,7 +283,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
}
|
||||
|
||||
strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR));
|
||||
if (strw == NULL) {
|
||||
if (!strw) {
|
||||
RegCloseKey(hkey);
|
||||
return WIN_StringToUTF8(name); /* oh well. */
|
||||
}
|
||||
@ -388,7 +388,7 @@ DECLSPEC int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_fu
|
||||
(void)_argc; (void)_argv; (void)reserved;
|
||||
|
||||
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argvw == NULL) {
|
||||
if (!argvw) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
|
||||
@ -399,13 +399,13 @@ DECLSPEC int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_fu
|
||||
|
||||
/* Parse it into argv and argc */
|
||||
argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv));
|
||||
if (argv == NULL) {
|
||||
if (!argv) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < argc; ++i) {
|
||||
DWORD len;
|
||||
char *arg = WIN_StringToUTF8W(argvw[i]);
|
||||
if (arg == NULL) {
|
||||
if (!arg) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
len = (DWORD)SDL_strlen(arg);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -30,6 +30,7 @@ extern "C" {
|
||||
XInputGetState_t SDL_XInputGetState = NULL;
|
||||
XInputSetState_t SDL_XInputSetState = NULL;
|
||||
XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL;
|
||||
XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx = NULL;
|
||||
XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL;
|
||||
DWORD SDL_XInputVersion = 0;
|
||||
|
||||
@ -106,13 +107,15 @@ int WIN_LoadXInputDLL(void)
|
||||
|
||||
/* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
|
||||
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100);
|
||||
if (SDL_XInputGetState == NULL) {
|
||||
if (!SDL_XInputGetState) {
|
||||
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState");
|
||||
}
|
||||
SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState");
|
||||
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities");
|
||||
/* 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller. */
|
||||
SDL_XInputGetCapabilitiesEx = (XInputGetCapabilitiesEx_t)GetProcAddress(s_pXInputDLL, (LPCSTR)108);
|
||||
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation");
|
||||
if (SDL_XInputGetState == NULL || SDL_XInputSetState == NULL || SDL_XInputGetCapabilities == NULL) {
|
||||
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
|
||||
WIN_UnloadXInputDLL();
|
||||
return -1;
|
||||
}
|
||||
|
57
external/sdl/SDL/src/core/windows/SDL_xinput.h
vendored
57
external/sdl/SDL/src/core/windows/SDL_xinput.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -28,6 +28,7 @@
|
||||
#ifdef HAVE_XINPUT_H
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
/* Xbox supports an XInput wrapper which is a C++-only header... */
|
||||
#include <math.h> /* Required to compile with recent MSVC... */
|
||||
#include <XInputOnGameInput.h>
|
||||
using namespace XInputOnGameInput;
|
||||
#else
|
||||
@ -44,6 +45,9 @@ using namespace XInputOnGameInput;
|
||||
#ifndef XINPUT_CAPS_FFB_SUPPORTED
|
||||
#define XINPUT_CAPS_FFB_SUPPORTED 0x0001
|
||||
#endif
|
||||
#ifndef XINPUT_CAPS_WIRELESS
|
||||
#define XINPUT_CAPS_WIRELESS 0x0002
|
||||
#endif
|
||||
|
||||
#ifndef XINPUT_DEVSUBTYPE_UNKNOWN
|
||||
#define XINPUT_DEVSUBTYPE_UNKNOWN 0x00
|
||||
@ -163,28 +167,8 @@ extern "C" {
|
||||
|
||||
/* typedef's for XInput structs we use */
|
||||
|
||||
#ifndef HAVE_XINPUT_GAMEPAD_EX
|
||||
typedef struct
|
||||
{
|
||||
WORD wButtons;
|
||||
BYTE bLeftTrigger;
|
||||
BYTE bRightTrigger;
|
||||
SHORT sThumbLX;
|
||||
SHORT sThumbLY;
|
||||
SHORT sThumbRX;
|
||||
SHORT sThumbRY;
|
||||
DWORD dwPaddingReserved;
|
||||
} XINPUT_GAMEPAD_EX;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_XINPUT_STATE_EX
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwPacketNumber;
|
||||
XINPUT_GAMEPAD_EX Gamepad;
|
||||
} XINPUT_STATE_EX;
|
||||
#endif
|
||||
|
||||
/* This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 */
|
||||
typedef struct
|
||||
{
|
||||
BYTE BatteryType;
|
||||
@ -204,6 +188,12 @@ typedef struct
|
||||
SHORT sThumbRY;
|
||||
} XINPUT_GAMEPAD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwPacketNumber;
|
||||
XINPUT_GAMEPAD Gamepad;
|
||||
} XINPUT_STATE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wLeftMotorSpeed;
|
||||
@ -221,10 +211,21 @@ typedef struct
|
||||
|
||||
#endif /* HAVE_XINPUT_H */
|
||||
|
||||
/* This struct is not defined in XInput headers. */
|
||||
typedef struct _XINPUT_CAPABILITIES_EX
|
||||
{
|
||||
XINPUT_CAPABILITIES Capabilities;
|
||||
WORD VendorId;
|
||||
WORD ProductId;
|
||||
WORD ProductVersion;
|
||||
WORD unk1;
|
||||
DWORD unk2;
|
||||
} XINPUT_CAPABILITIES_EX, *PXINPUT_CAPABILITIES_EX;
|
||||
|
||||
/* Forward decl's for XInput API's we load dynamically and use if available */
|
||||
typedef DWORD(WINAPI *XInputGetState_t)(
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
XINPUT_STATE_EX *pState /* [out] Receives the current state */
|
||||
XINPUT_STATE *pState /* [out] Receives the current state */
|
||||
);
|
||||
|
||||
typedef DWORD(WINAPI *XInputSetState_t)(
|
||||
@ -238,6 +239,14 @@ typedef DWORD(WINAPI *XInputGetCapabilities_t)(
|
||||
XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */
|
||||
);
|
||||
|
||||
/* Only available in XInput 1.4 that is shipped with Windows 8 and newer. */
|
||||
typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)(
|
||||
DWORD dwReserved, /* [in] Must be 1 */
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
DWORD dwFlags, /* [in] Input flags that identify the device type */
|
||||
XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
|
||||
);
|
||||
|
||||
typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
|
||||
DWORD dwUserIndex,
|
||||
BYTE devType,
|
||||
@ -249,6 +258,7 @@ extern void WIN_UnloadXInputDLL(void);
|
||||
extern XInputGetState_t SDL_XInputGetState;
|
||||
extern XInputSetState_t SDL_XInputSetState;
|
||||
extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
|
||||
extern XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx;
|
||||
extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation;
|
||||
extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
|
||||
|
||||
@ -260,6 +270,7 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
|
||||
#define XINPUTGETSTATE SDL_XInputGetState
|
||||
#define XINPUTSETSTATE SDL_XInputSetState
|
||||
#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities
|
||||
#define XINPUTGETCAPABILITIESEX SDL_XInputGetCapabilitiesEx
|
||||
#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation
|
||||
|
||||
#endif /* SDL_xinput_h_ */
|
||||
|
2
external/sdl/SDL/src/core/windows/pch.c
vendored
2
external/sdl/SDL/src/core/windows/pch.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
external/sdl/SDL/src/core/windows/version.rc
vendored
2
external/sdl/SDL/src/core/windows/version.rc
vendored
@ -25,7 +25,7 @@ BEGIN
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "3, 0, 0, 0\0"
|
||||
VALUE "InternalName", "SDL\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0"
|
||||
VALUE "OriginalFilename", "SDL3.dll\0"
|
||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||
VALUE "ProductVersion", "3, 0, 0, 0\0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -296,11 +296,8 @@ void SDL_WinRTApp::SetWindow(CoreWindow ^ window)
|
||||
ref new TypedEventHandler<MouseDevice ^, MouseEventArgs ^>(this, &SDL_WinRTApp::OnMouseMoved);
|
||||
#endif
|
||||
|
||||
window->KeyDown +=
|
||||
ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &SDL_WinRTApp::OnKeyDown);
|
||||
|
||||
window->KeyUp +=
|
||||
ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &SDL_WinRTApp::OnKeyUp);
|
||||
window->Dispatcher->AcceleratorKeyActivated +=
|
||||
ref new TypedEventHandler<CoreDispatcher ^, AcceleratorKeyEventArgs ^>(this, &SDL_WinRTApp::OnAcceleratorKeyActivated);
|
||||
|
||||
window->CharacterReceived +=
|
||||
ref new TypedEventHandler<CoreWindow ^, CharacterReceivedEventArgs ^>(this, &SDL_WinRTApp::OnCharacterReceived);
|
||||
@ -343,7 +340,7 @@ void SDL_WinRTApp::Run()
|
||||
// representation of command line arguments.
|
||||
int argc = 1;
|
||||
char **argv = (char **)SDL_malloc(2 * sizeof(*argv));
|
||||
if (argv == NULL) {
|
||||
if (!argv) {
|
||||
return;
|
||||
}
|
||||
argv[0] = SDL_strdup("WinRTApp");
|
||||
@ -720,19 +717,14 @@ void SDL_WinRTApp::OnMouseMoved(MouseDevice ^ mouseDevice, MouseEventArgs ^ args
|
||||
WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||
void SDL_WinRTApp::OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^ sender, Windows::UI::Core::AcceleratorKeyEventArgs ^ args)
|
||||
{
|
||||
WINRT_ProcessKeyDownEvent(args);
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||
{
|
||||
WINRT_ProcessKeyUpEvent(args);
|
||||
WINRT_ProcessAcceleratorKeyActivated(args);
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args)
|
||||
{
|
||||
WINRT_ProcessCharacterReceivedEvent(args);
|
||||
WINRT_ProcessCharacterReceivedEvent(WINRT_GlobalSDLWindow, args);
|
||||
}
|
||||
|
||||
template <typename BackButtonEventArgs>
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -71,8 +71,7 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
|
||||
void OnPointerEntered(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args);
|
||||
void OnPointerExited(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args);
|
||||
void OnMouseMoved(Windows::Devices::Input::MouseDevice ^ mouseDevice, Windows::Devices::Input::MouseEventArgs ^ args);
|
||||
void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
|
||||
void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
|
||||
void OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^ sender, Windows::UI::Core::AcceleratorKeyEventArgs ^ args);
|
||||
void OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args);
|
||||
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
Reference in New Issue
Block a user