initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
1833
thirdparty/sdl/events/SDL_events.c
vendored
Normal file
1833
thirdparty/sdl/events/SDL_events.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
59
thirdparty/sdl/events/SDL_events_c.h
vendored
Normal file
59
thirdparty/sdl/events/SDL_events_c.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 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.
|
||||
*/
|
||||
|
||||
#ifndef SDL_events_c_h_
|
||||
#define SDL_events_c_h_
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
// Useful functions and variables from SDL_events.c
|
||||
//#include "../video/SDL_sysvideo.h"
|
||||
|
||||
#include "SDL_mouse_c.h"
|
||||
|
||||
// Start and stop the event processing loop
|
||||
extern bool SDL_StartEventLoop(void);
|
||||
extern void SDL_StopEventLoop(void);
|
||||
extern void SDL_QuitInterrupt(void);
|
||||
|
||||
extern void SDL_SendAppEvent(SDL_EventType eventType);
|
||||
extern void SDL_SendKeymapChangedEvent(void);
|
||||
extern void SDL_SendLocaleChangedEvent(void);
|
||||
extern void SDL_SendSystemThemeChangedEvent(void);
|
||||
|
||||
extern void *SDL_AllocateTemporaryMemory(size_t size);
|
||||
extern const char *SDL_CreateTemporaryString(const char *string);
|
||||
extern void *SDL_ClaimTemporaryMemory(const void *mem);
|
||||
extern void SDL_FreeTemporaryMemory(void);
|
||||
|
||||
extern void SDL_PumpEventMaintenance(void);
|
||||
|
||||
extern void SDL_SendQuit(void);
|
||||
|
||||
extern bool SDL_InitEvents(void);
|
||||
extern void SDL_QuitEvents(void);
|
||||
|
||||
extern void SDL_SendPendingSignalEvents(void);
|
||||
|
||||
extern bool SDL_InitQuit(void);
|
||||
extern void SDL_QuitQuit(void);
|
||||
|
||||
#endif // SDL_events_c_h_
|
143
thirdparty/sdl/events/SDL_eventwatch.c
vendored
Normal file
143
thirdparty/sdl/events/SDL_eventwatch.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 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"
|
||||
|
||||
#include "SDL_eventwatch_c.h"
|
||||
|
||||
|
||||
bool SDL_InitEventWatchList(SDL_EventWatchList *list)
|
||||
{
|
||||
if (list->lock == NULL) {
|
||||
list->lock = SDL_CreateMutex();
|
||||
if (list->lock == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_QuitEventWatchList(SDL_EventWatchList *list)
|
||||
{
|
||||
if (list->lock) {
|
||||
SDL_DestroyMutex(list->lock);
|
||||
list->lock = NULL;
|
||||
}
|
||||
if (list->watchers) {
|
||||
SDL_free(list->watchers);
|
||||
list->watchers = NULL;
|
||||
list->count = 0;
|
||||
}
|
||||
SDL_zero(list->filter);
|
||||
}
|
||||
|
||||
bool SDL_DispatchEventWatchList(SDL_EventWatchList *list, SDL_Event *event)
|
||||
{
|
||||
SDL_EventWatcher *filter = &list->filter;
|
||||
|
||||
if (!filter->callback && list->count == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_LockMutex(list->lock);
|
||||
{
|
||||
// Make sure we only dispatch the current watcher list
|
||||
int i, count = list->count;
|
||||
|
||||
if (filter->callback && !filter->callback(filter->userdata, event)) {
|
||||
SDL_UnlockMutex(list->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
list->dispatching = true;
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (!list->watchers[i].removed) {
|
||||
list->watchers[i].callback(list->watchers[i].userdata, event);
|
||||
}
|
||||
}
|
||||
list->dispatching = false;
|
||||
|
||||
if (list->removed) {
|
||||
for (i = list->count; i--;) {
|
||||
if (list->watchers[i].removed) {
|
||||
--list->count;
|
||||
if (i < list->count) {
|
||||
SDL_memmove(&list->watchers[i], &list->watchers[i + 1], (list->count - i) * sizeof(list->watchers[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
list->removed = false;
|
||||
}
|
||||
}
|
||||
SDL_UnlockMutex(list->lock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDL_AddEventWatchList(SDL_EventWatchList *list, SDL_EventFilter filter, void *userdata)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
SDL_LockMutex(list->lock);
|
||||
{
|
||||
SDL_EventWatcher *watchers;
|
||||
|
||||
watchers = (SDL_EventWatcher *)SDL_realloc(list->watchers, (list->count + 1) * sizeof(*watchers));
|
||||
if (watchers) {
|
||||
SDL_EventWatcher *watcher;
|
||||
|
||||
list->watchers = watchers;
|
||||
watcher = &list->watchers[list->count];
|
||||
watcher->callback = filter;
|
||||
watcher->userdata = userdata;
|
||||
watcher->removed = false;
|
||||
++list->count;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
SDL_UnlockMutex(list->lock);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SDL_RemoveEventWatchList(SDL_EventWatchList *list, SDL_EventFilter filter, void *userdata)
|
||||
{
|
||||
SDL_LockMutex(list->lock);
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < list->count; ++i) {
|
||||
if (list->watchers[i].callback == filter && list->watchers[i].userdata == userdata) {
|
||||
if (list->dispatching) {
|
||||
list->watchers[i].removed = true;
|
||||
list->removed = true;
|
||||
} else {
|
||||
--list->count;
|
||||
if (i < list->count) {
|
||||
SDL_memmove(&list->watchers[i], &list->watchers[i + 1], (list->count - i) * sizeof(list->watchers[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_UnlockMutex(list->lock);
|
||||
}
|
45
thirdparty/sdl/events/SDL_eventwatch_c.h
vendored
Normal file
45
thirdparty/sdl/events/SDL_eventwatch_c.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 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"
|
||||
|
||||
typedef struct SDL_EventWatcher
|
||||
{
|
||||
SDL_EventFilter callback;
|
||||
void *userdata;
|
||||
bool removed;
|
||||
} SDL_EventWatcher;
|
||||
|
||||
typedef struct SDL_EventWatchList
|
||||
{
|
||||
SDL_Mutex *lock;
|
||||
SDL_EventWatcher filter;
|
||||
SDL_EventWatcher *watchers;
|
||||
int count;
|
||||
bool dispatching;
|
||||
bool removed;
|
||||
} SDL_EventWatchList;
|
||||
|
||||
|
||||
extern bool SDL_InitEventWatchList(SDL_EventWatchList *list);
|
||||
extern void SDL_QuitEventWatchList(SDL_EventWatchList *list);
|
||||
extern bool SDL_DispatchEventWatchList(SDL_EventWatchList *list, SDL_Event *event);
|
||||
extern bool SDL_AddEventWatchList(SDL_EventWatchList *list, SDL_EventFilter filter, void *userdata);
|
||||
extern void SDL_RemoveEventWatchList(SDL_EventWatchList *list, SDL_EventFilter filter, void *userdata);
|
215
thirdparty/sdl/events/SDL_mouse_c.h
vendored
Normal file
215
thirdparty/sdl/events/SDL_mouse_c.h
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 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_mouse_c_h_
|
||||
#define SDL_mouse_c_h_
|
||||
|
||||
// Mouse events not associated with a specific input device
|
||||
#define SDL_GLOBAL_MOUSE_ID 0
|
||||
|
||||
// The default mouse input device, for platforms that don't have multiple mice
|
||||
#define SDL_DEFAULT_MOUSE_ID 1
|
||||
|
||||
typedef struct SDL_CursorData SDL_CursorData;
|
||||
|
||||
struct SDL_Cursor
|
||||
{
|
||||
struct SDL_Cursor *next;
|
||||
SDL_CursorData *internal;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Uint64 last_timestamp;
|
||||
double click_motion_x;
|
||||
double click_motion_y;
|
||||
Uint8 click_count;
|
||||
} SDL_MouseClickState;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_MouseID mouseID;
|
||||
Uint32 buttonstate;
|
||||
|
||||
// Data for double-click tracking
|
||||
int num_clickstates;
|
||||
SDL_MouseClickState *clickstate;
|
||||
} SDL_MouseInputSource;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Create a cursor from a surface
|
||||
SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y);
|
||||
|
||||
// Create a system cursor
|
||||
SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id);
|
||||
|
||||
// Show the specified cursor, or hide if cursor is NULL
|
||||
bool (*ShowCursor)(SDL_Cursor *cursor);
|
||||
|
||||
// This is called when a mouse motion event occurs
|
||||
bool (*MoveCursor)(SDL_Cursor *cursor);
|
||||
|
||||
// Free a window manager cursor
|
||||
void (*FreeCursor)(SDL_Cursor *cursor);
|
||||
|
||||
// Warp the mouse to (x,y) within a window
|
||||
bool (*WarpMouse)(SDL_Window *window, float x, float y);
|
||||
|
||||
// Warp the mouse to (x,y) in screen space
|
||||
bool (*WarpMouseGlobal)(float x, float y);
|
||||
|
||||
// Set relative mode
|
||||
bool (*SetRelativeMouseMode)(bool enabled);
|
||||
|
||||
// Set mouse capture
|
||||
bool (*CaptureMouse)(SDL_Window *window);
|
||||
|
||||
// Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call.
|
||||
SDL_MouseButtonFlags (*GetGlobalMouseState)(float *x, float *y);
|
||||
|
||||
// Platform-specific system mouse transform
|
||||
void (*ApplySystemScale)(void *internal, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y);
|
||||
void *system_scale_data;
|
||||
|
||||
// integer mode data
|
||||
Uint8 integer_mode_flags; // 1 to enable mouse quantization, 2 to enable wheel quantization
|
||||
float integer_mode_residual_motion_x;
|
||||
float integer_mode_residual_motion_y;
|
||||
|
||||
// Data common to all mice
|
||||
SDL_Window *focus;
|
||||
float x;
|
||||
float y;
|
||||
float x_accu;
|
||||
float y_accu;
|
||||
float last_x, last_y; // the last reported x and y coordinates
|
||||
float residual_scroll_x;
|
||||
float residual_scroll_y;
|
||||
double click_motion_x;
|
||||
double click_motion_y;
|
||||
bool has_position;
|
||||
bool relative_mode;
|
||||
bool relative_mode_warp_motion;
|
||||
bool relative_mode_cursor_visible;
|
||||
bool relative_mode_center;
|
||||
bool warp_emulation_hint;
|
||||
bool warp_emulation_active;
|
||||
bool warp_emulation_prohibited;
|
||||
Uint64 last_center_warp_time_ns;
|
||||
bool enable_normal_speed_scale;
|
||||
float normal_speed_scale;
|
||||
bool enable_relative_speed_scale;
|
||||
float relative_speed_scale;
|
||||
bool enable_relative_system_scale;
|
||||
Uint32 double_click_time;
|
||||
int double_click_radius;
|
||||
bool touch_mouse_events;
|
||||
bool mouse_touch_events;
|
||||
bool pen_mouse_events;
|
||||
bool pen_touch_events;
|
||||
bool was_touch_mouse_events; // Was a touch-mouse event pending?
|
||||
bool added_mouse_touch_device; // did we SDL_AddTouch() a virtual touch device for the mouse?
|
||||
bool added_pen_touch_device; // did we SDL_AddTouch() a virtual touch device for pens?
|
||||
#ifdef SDL_PLATFORM_VITA
|
||||
Uint8 vita_touch_mouse_device;
|
||||
#endif
|
||||
bool auto_capture;
|
||||
bool capture_desired;
|
||||
SDL_Window *capture_window;
|
||||
|
||||
// Data for input source state
|
||||
int num_sources;
|
||||
SDL_MouseInputSource *sources;
|
||||
|
||||
SDL_Cursor *cursors;
|
||||
SDL_Cursor *def_cursor;
|
||||
SDL_Cursor *cur_cursor;
|
||||
bool cursor_shown;
|
||||
|
||||
// Driver-dependent data.
|
||||
void *internal;
|
||||
} SDL_Mouse;
|
||||
|
||||
// Initialize the mouse subsystem, called before the main video driver is initialized
|
||||
extern bool SDL_PreInitMouse(void);
|
||||
|
||||
// Finish initializing the mouse subsystem, called after the main video driver was initialized
|
||||
extern void SDL_PostInitMouse(void);
|
||||
|
||||
// Return whether a device is actually a mouse
|
||||
extern bool SDL_IsMouse(Uint16 vendor, Uint16 product);
|
||||
|
||||
// A mouse has been added to the system
|
||||
extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event);
|
||||
|
||||
// A mouse has been removed from the system
|
||||
extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event);
|
||||
|
||||
// Get the mouse state structure
|
||||
extern SDL_Mouse *SDL_GetMouse(void);
|
||||
|
||||
// Set the default mouse cursor
|
||||
extern void SDL_SetDefaultCursor(SDL_Cursor *cursor);
|
||||
|
||||
// Get the preferred default system cursor
|
||||
extern SDL_SystemCursor SDL_GetDefaultSystemCursor(void);
|
||||
|
||||
// Set the mouse focus window
|
||||
extern void SDL_SetMouseFocus(SDL_Window *window);
|
||||
|
||||
// Update the mouse capture window
|
||||
extern bool SDL_UpdateMouseCapture(bool force_release);
|
||||
|
||||
// Send a mouse motion event
|
||||
extern void SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y);
|
||||
|
||||
// Send a mouse button event
|
||||
extern void SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down);
|
||||
|
||||
// Send a mouse button event with a click count
|
||||
extern void SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks);
|
||||
|
||||
// Send a mouse wheel event
|
||||
extern void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);
|
||||
|
||||
// Warp the mouse within the window, potentially overriding relative mode
|
||||
extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode);
|
||||
|
||||
// Relative mouse mode
|
||||
extern bool SDL_SetRelativeMouseMode(bool enabled);
|
||||
extern bool SDL_GetRelativeMouseMode(void);
|
||||
extern void SDL_UpdateRelativeMouseMode(void);
|
||||
extern void SDL_DisableMouseWarpEmulation(void);
|
||||
|
||||
// TODO RECONNECT: Set mouse state to "zero"
|
||||
#if 0
|
||||
extern void SDL_ResetMouse(void);
|
||||
#endif // 0
|
||||
|
||||
// Check if mouse position is within window or captured by window
|
||||
extern bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y);
|
||||
|
||||
// Shutdown the mouse subsystem
|
||||
extern void SDL_QuitMouse(void);
|
||||
|
||||
#endif // SDL_mouse_c_h_
|
Reference in New Issue
Block a user