Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'

This commit is contained in:
2024-01-17 17:02:59 +01:00
1244 changed files with 50102 additions and 28146 deletions

View File

@ -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

View File

@ -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

View File

@ -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,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
{
int posted;
if (display == NULL || display->id == 0) {
if (!display || display->id == 0) {
return 0;
}
switch (displayevent) {
@ -54,8 +54,8 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
}
switch (displayevent) {
case SDL_EVENT_DISPLAY_CONNECTED:
SDL_OnDisplayConnected(display);
case SDL_EVENT_DISPLAY_ADDED:
SDL_OnDisplayAdded(display);
break;
default:
break;

View File

@ -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

View File

@ -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,7 +27,7 @@
#include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data, float x, float y)
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *source, const char *data, float x, float y)
{
static SDL_bool app_is_dropping = SDL_FALSE;
static float last_drop_x = 0;
@ -58,7 +58,18 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
SDL_zero(event);
event.type = evtype;
event.common.timestamp = 0;
event.drop.file = data ? SDL_strdup(data) : NULL;
if (source) {
event.drop.source = SDL_strdup(source);
}
if (data) {
size_t size = SDL_strlen(data) + 1;
event.drop.data = (char *)SDL_AllocateEventMemory(size);
if (!event.drop.data) {
SDL_free(event.drop.source);
return 0;
}
SDL_memcpy(event.drop.data, data, size);
}
event.drop.windowID = window ? window->id : 0;
if (evtype == SDL_EVENT_DROP_POSITION) {
@ -83,23 +94,22 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
return posted;
}
int SDL_SendDropFile(SDL_Window *window, const char *file)
int SDL_SendDropFile(SDL_Window *window, const char *source, const char *file)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_FILE, file, 0, 0);
return SDL_SendDrop(window, SDL_EVENT_DROP_FILE, source, file, 0, 0);
}
int SDL_SendDropPosition(SDL_Window *window, const char *file, float x, float y)
int SDL_SendDropPosition(SDL_Window *window, float x, float y)
{
/* Don't send 'file' since this is an malloc per position, which may be forgotten to be freed */
return SDL_SendDrop(window, SDL_EVENT_DROP_POSITION, NULL, x, y);
return SDL_SendDrop(window, SDL_EVENT_DROP_POSITION, NULL, NULL, x, y);
}
int SDL_SendDropText(SDL_Window *window, const char *text)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_TEXT, text, 0, 0);
return SDL_SendDrop(window, SDL_EVENT_DROP_TEXT, NULL, text, 0, 0);
}
int SDL_SendDropComplete(SDL_Window *window)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_COMPLETE, NULL, 0, 0);
return SDL_SendDrop(window, SDL_EVENT_DROP_COMPLETE, NULL, NULL, 0, 0);
}

View File

@ -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
@ -23,8 +23,8 @@
#ifndef SDL_dropevents_c_h_
#define SDL_dropevents_c_h_
extern int SDL_SendDropFile(SDL_Window *window, const char *file);
extern int SDL_SendDropPosition(SDL_Window *window, const char *file, float x, float y);
extern int SDL_SendDropFile(SDL_Window *window, const char *source, const char *file);
extern int SDL_SendDropPosition(SDL_Window *window, float x, float y);
extern int SDL_SendDropText(SDL_Window *window, const char *text);
extern int SDL_SendDropComplete(SDL_Window *window);

View File

@ -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
@ -24,6 +24,7 @@
#include "SDL_events_c.h"
#include "../SDL_hints_c.h"
#include "../audio/SDL_audio_c.h"
#include "../timer/SDL_timer_c.h"
#ifndef SDL_JOYSTICK_DISABLED
#include "../joystick/SDL_joystick_c.h"
@ -32,7 +33,6 @@
#include "../sensor/SDL_sensor_c.h"
#endif
#include "../video/SDL_sysvideo.h"
#include <SDL3/SDL_syswm.h>
#undef SDL_PRIs64
#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__)
@ -61,6 +61,7 @@ static int SDL_event_watchers_count = 0;
static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE;
static SDL_bool SDL_event_watchers_removed = SDL_FALSE;
static SDL_AtomicInt SDL_sentinel_pending;
static Uint32 SDL_last_event_id = 0;
typedef struct
{
@ -74,17 +75,10 @@ static Uint32 SDL_userevents = SDL_EVENT_USER;
typedef struct SDL_EventEntry
{
SDL_Event event;
SDL_SysWMmsg msg;
struct SDL_EventEntry *prev;
struct SDL_EventEntry *next;
} SDL_EventEntry;
typedef struct SDL_SysWMEntry
{
SDL_SysWMmsg msg;
struct SDL_SysWMEntry *next;
} SDL_SysWMEntry;
static struct
{
SDL_Mutex *lock;
@ -94,9 +88,76 @@ static struct
SDL_EventEntry *head;
SDL_EventEntry *tail;
SDL_EventEntry *free;
SDL_SysWMEntry *wmmsg_used;
SDL_SysWMEntry *wmmsg_free;
} SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL, NULL, NULL };
} SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL };
typedef struct SDL_EventMemory
{
Uint32 eventID;
void *memory;
struct SDL_EventMemory *next;
} SDL_EventMemory;
static SDL_Mutex *SDL_event_memory_lock;
static SDL_EventMemory *SDL_event_memory_head;
static SDL_EventMemory *SDL_event_memory_tail;
void *SDL_AllocateEventMemory(size_t size)
{
void *memory = SDL_malloc(size);
if (!memory) {
return NULL;
}
SDL_LockMutex(SDL_event_memory_lock);
{
SDL_EventMemory *entry = (SDL_EventMemory *)SDL_malloc(sizeof(*entry));
if (entry) {
entry->eventID = SDL_last_event_id;
entry->memory = memory;
entry->next = NULL;
if (SDL_event_memory_tail) {
SDL_event_memory_tail->next = entry;
} else {
SDL_event_memory_head = entry;
}
SDL_event_memory_tail = entry;
} else {
SDL_free(memory);
memory = NULL;
}
}
SDL_UnlockMutex(SDL_event_memory_lock);
return memory;
}
static void SDL_FlushEventMemory(Uint32 eventID)
{
SDL_LockMutex(SDL_event_memory_lock);
{
if (SDL_event_memory_head) {
while (SDL_event_memory_head) {
SDL_EventMemory *entry = SDL_event_memory_head;
if (eventID && (Sint32)(eventID - entry->eventID) < 0) {
break;
}
/* If you crash here, your application has memory corruption
* or freed memory in an event, which is no longer necessary.
*/
SDL_event_memory_head = entry->next;
SDL_free(entry->memory);
SDL_free(entry);
}
if (!SDL_event_memory_head) {
SDL_event_memory_tail = NULL;
}
}
}
SDL_UnlockMutex(SDL_event_memory_lock);
}
#ifndef SDL_JOYSTICK_DISABLED
@ -129,8 +190,7 @@ static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, co
* Verbosity of logged events as defined in SDL_HINT_EVENT_LOGGING:
* - 0: (default) no logging
* - 1: logging of most events
* - 2: as above, plus mouse and finger motion
* - 3: as above, plus SDL_SysWMEvents
* - 2: as above, plus mouse, pen, and finger motion
*/
static int SDL_EventLoggingVerbosity = 0;
@ -144,21 +204,17 @@ static void SDL_LogEvent(const SDL_Event *event)
char name[64];
char details[128];
/* sensor/mouse/finger motion are spammy, ignore these if they aren't demanded. */
/* sensor/mouse/pen/finger motion are spammy, ignore these if they aren't demanded. */
if ((SDL_EventLoggingVerbosity < 2) &&
((event->type == SDL_EVENT_MOUSE_MOTION) ||
(event->type == SDL_EVENT_FINGER_MOTION) ||
(event->type == SDL_EVENT_PEN_MOTION) ||
(event->type == SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION) ||
(event->type == SDL_EVENT_GAMEPAD_SENSOR_UPDATE) ||
(event->type == SDL_EVENT_SENSOR_UPDATE))) {
return;
}
/* window manager events are even more spammy, and don't provide much useful info. */
if ((SDL_EventLoggingVerbosity < 3) && (event->type == SDL_EVENT_SYSWM)) {
return;
}
/* this is to make (void)SDL_snprintf() calls cleaner. */
#define uint unsigned int
@ -222,8 +278,8 @@ static void SDL_LogEvent(const SDL_Event *event)
(uint)event->display.timestamp, (uint)event->display.displayID, name, (int)event->display.data1); \
break
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_ORIENTATION);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_CONNECTED);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_DISCONNECTED);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_ADDED);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_REMOVED);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_MOVED);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED);
#undef SDL_DISPLAYEVENT_CASE
@ -245,6 +301,8 @@ static void SDL_LogEvent(const SDL_Event *event)
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_RESTORED);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_MOUSE_ENTER);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_MOUSE_LEAVE);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_PEN_ENTER);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_PEN_LEAVE);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_FOCUS_GAINED);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_FOCUS_LOST);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_CLOSE_REQUESTED);
@ -254,14 +312,11 @@ static void SDL_LogEvent(const SDL_Event *event)
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_DISPLAY_CHANGED);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_OCCLUDED);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_ENTER_FULLSCREEN);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_LEAVE_FULLSCREEN);
SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_DESTROYED);
#undef SDL_WINDOWEVENT_CASE
SDL_EVENT_CASE(SDL_EVENT_SYSWM)
/* !!! FIXME: we don't delve further at the moment. */
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->syswm.timestamp);
break;
#define PRINT_KEY_EVENT(event) \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \
(uint)event->key.timestamp, (uint)event->key.windowID, \
@ -378,6 +433,9 @@ static void SDL_LogEvent(const SDL_Event *event)
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_REMAPPED)
PRINT_GAMEPADDEV_EVENT(event);
break;
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED)
PRINT_GAMEPADDEV_EVENT(event);
break;
#undef PRINT_GAMEPADDEV_EVENT
#define PRINT_CTOUCHPAD_EVENT(event) \
@ -418,7 +476,54 @@ static void SDL_LogEvent(const SDL_Event *event)
break;
#undef PRINT_FINGER_EVENT
#define PRINT_DROP_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u x=%f y=%f)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID, event->drop.x, event->drop.y)
#define PRINT_PTIP_EVENT(event) \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u tip=%u state=%s x=%g y=%g)", \
(uint)event->ptip.timestamp, (uint)event->ptip.windowID, \
(uint)event->ptip.which, (uint)event->ptip.tip, \
event->ptip.state == SDL_PRESSED ? "down" : "up", \
event->ptip.x, event->ptip.y)
SDL_EVENT_CASE(SDL_EVENT_PEN_DOWN)
PRINT_PTIP_EVENT(event);
break;
SDL_EVENT_CASE(SDL_EVENT_PEN_UP)
PRINT_PTIP_EVENT(event);
break;
#undef PRINT_PTIP_EVENT
SDL_EVENT_CASE(SDL_EVENT_PEN_MOTION)
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%08x x=%g y=%g [%g, %g, %g, %g, %g, %g])",
(uint)event->pmotion.timestamp, (uint)event->pmotion.windowID,
(uint)event->pmotion.which, (uint)event->pmotion.pen_state,
event->pmotion.x, event->pmotion.y,
event->pmotion.axes[SDL_PEN_AXIS_PRESSURE],
event->pmotion.axes[SDL_PEN_AXIS_XTILT],
event->pmotion.axes[SDL_PEN_AXIS_YTILT],
event->pmotion.axes[SDL_PEN_AXIS_DISTANCE],
event->pmotion.axes[SDL_PEN_AXIS_ROTATION],
event->pmotion.axes[SDL_PEN_AXIS_SLIDER]);
break;
#define PRINT_PBUTTON_EVENT(event) \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u tip=%u state=%s x=%g y=%g axes=[%g, %g, %g, %g, %g, %g])", \
(uint)event->pbutton.timestamp, (uint)event->pbutton.windowID, \
(uint)event->pbutton.which, (uint)event->pbutton.button, \
event->pbutton.state == SDL_PRESSED ? "pressed" : "released", \
event->pbutton.x, event->pbutton.y, \
event->pbutton.axes[SDL_PEN_AXIS_PRESSURE], \
event->pbutton.axes[SDL_PEN_AXIS_XTILT], \
event->pbutton.axes[SDL_PEN_AXIS_YTILT], \
event->pbutton.axes[SDL_PEN_AXIS_DISTANCE], \
event->pbutton.axes[SDL_PEN_AXIS_ROTATION], \
event->pbutton.axes[SDL_PEN_AXIS_SLIDER])
SDL_EVENT_CASE(SDL_EVENT_PEN_BUTTON_DOWN)
PRINT_PBUTTON_EVENT(event);
break;
SDL_EVENT_CASE(SDL_EVENT_PEN_BUTTON_UP)
PRINT_PBUTTON_EVENT(event);
break;
#undef PRINT_PBUTTON_EVENT
#define PRINT_DROP_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (data='%s' timestamp=%u windowid=%u x=%f y=%f)", event->drop.data, (uint)event->drop.timestamp, (uint)event->drop.windowID, event->drop.x, event->drop.y)
SDL_EVENT_CASE(SDL_EVENT_DROP_FILE)
PRINT_DROP_EVENT(event);
break;
@ -476,14 +581,11 @@ static void SDL_LogEvent(const SDL_Event *event)
#undef uint
}
/* Public functions */
void SDL_StopEventLoop(void)
{
const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS");
int i;
SDL_EventEntry *entry;
SDL_SysWMEntry *wmmsg;
SDL_LockMutex(SDL_EventQ.lock);
@ -505,32 +607,26 @@ void SDL_StopEventLoop(void)
SDL_free(entry);
entry = next;
}
for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg;) {
SDL_SysWMEntry *next = wmmsg->next;
SDL_free(wmmsg);
wmmsg = next;
}
for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg;) {
SDL_SysWMEntry *next = wmmsg->next;
SDL_free(wmmsg);
wmmsg = next;
}
SDL_AtomicSet(&SDL_EventQ.count, 0);
SDL_EventQ.max_events_seen = 0;
SDL_EventQ.head = NULL;
SDL_EventQ.tail = NULL;
SDL_EventQ.free = NULL;
SDL_EventQ.wmmsg_used = NULL;
SDL_EventQ.wmmsg_free = NULL;
SDL_AtomicSet(&SDL_sentinel_pending, 0);
SDL_FlushEventMemory(0);
/* Clear disabled event state */
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
SDL_free(SDL_disabled_events[i]);
SDL_disabled_events[i] = NULL;
}
if (SDL_event_memory_lock) {
SDL_DestroyMutex(SDL_event_memory_lock);
SDL_event_memory_lock = NULL;
}
if (SDL_event_watchers_lock) {
SDL_DestroyMutex(SDL_event_watchers_lock);
SDL_event_watchers_lock = NULL;
@ -576,12 +672,19 @@ int SDL_StartEventLoop(void)
return -1;
}
}
if (SDL_event_memory_lock == NULL) {
SDL_event_memory_lock = SDL_CreateMutex();
if (SDL_event_memory_lock == NULL) {
SDL_UnlockMutex(SDL_EventQ.lock);
return -1;
}
}
#endif /* !SDL_THREADS_DISABLED */
/* Process most event types */
SDL_SetEventEnabled(SDL_EVENT_TEXT_INPUT, SDL_FALSE);
SDL_SetEventEnabled(SDL_EVENT_TEXT_EDITING, SDL_FALSE);
SDL_SetEventEnabled(SDL_EVENT_SYSWM, SDL_FALSE);
#if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_FALSE);
SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, SDL_FALSE);
@ -618,12 +721,9 @@ static int SDL_AddEvent(SDL_Event *event)
SDL_LogEvent(event);
}
entry->event = *event;
SDL_copyp(&entry->event, event);
if (event->type == SDL_EVENT_POLL_SENTINEL) {
SDL_AtomicAdd(&SDL_sentinel_pending, 1);
} else if (event->type == SDL_EVENT_SYSWM) {
entry->msg = *event->syswm.msg;
entry->event.syswm.msg = &entry->msg;
}
if (SDL_EventQ.tail) {
@ -644,6 +744,8 @@ static int SDL_AddEvent(SDL_Event *event)
SDL_EventQ.max_events_seen = final_count;
}
++SDL_last_event_id;
return 1;
}
@ -723,43 +825,14 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_eventact
}
} else {
SDL_EventEntry *entry, *next;
SDL_SysWMEntry *wmmsg, *wmmsg_next;
Uint32 type;
if (action == SDL_GETEVENT) {
/* Clean out any used wmmsg data
FIXME: Do we want to retain the data for some period of time?
*/
for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; wmmsg = wmmsg_next) {
wmmsg_next = wmmsg->next;
wmmsg->next = SDL_EventQ.wmmsg_free;
SDL_EventQ.wmmsg_free = wmmsg;
}
SDL_EventQ.wmmsg_used = NULL;
}
for (entry = SDL_EventQ.head; entry && (events == NULL || used < numevents); entry = next) {
next = entry->next;
type = entry->event.type;
if (minType <= type && type <= maxType) {
if (events) {
events[used] = entry->event;
if (entry->event.type == SDL_EVENT_SYSWM) {
/* We need to copy the wmmsg somewhere safe.
For now we'll guarantee it's valid at least until
the next call to SDL_PeepEvents()
*/
if (SDL_EventQ.wmmsg_free) {
wmmsg = SDL_EventQ.wmmsg_free;
SDL_EventQ.wmmsg_free = wmmsg->next;
} else {
wmmsg = (SDL_SysWMEntry *)SDL_malloc(sizeof(*wmmsg));
}
wmmsg->msg = *entry->event.syswm.msg;
wmmsg->next = SDL_EventQ.wmmsg_used;
SDL_EventQ.wmmsg_used = wmmsg;
events[used].syswm.msg = &wmmsg->msg;
}
SDL_copyp(&events[used], &entry->event);
if (action == SDL_GETEVENT) {
SDL_CutEvent(entry);
@ -817,9 +890,6 @@ void SDL_FlushEvents(Uint32 minType, Uint32 maxType)
{
SDL_EventEntry *entry, *next;
Uint32 type;
/* !!! FIXME: we need to manually SDL_free() the strings in TEXTINPUT and
drag'n'drop events if we're flushing them without passing them to the
app, but I don't know if this is the right place to do that. */
/* Make sure the events are current */
#if 0
@ -853,6 +923,12 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
/* Free old event memory */
/*SDL_FlushEventMemory(SDL_last_event_id - SDL_MAX_QUEUED_EVENTS);*/
if (SDL_AtomicGet(&SDL_EventQ.count) == 0) {
SDL_FlushEventMemory(SDL_last_event_id);
}
/* Release any keys held down from last frame */
SDL_ReleaseAutoReleaseKeys();
@ -861,6 +937,10 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel)
_this->PumpEvents(_this);
}
#ifndef SDL_AUDIO_DISABLED
SDL_UpdateAudio();
#endif
#ifndef SDL_SENSOR_DISABLED
/* Check for sensor state change */
if (SDL_update_sensors) {
@ -898,7 +978,7 @@ void SDL_PumpEvents(void)
/* Public functions */
int SDL_PollEvent(SDL_Event *event)
SDL_bool SDL_PollEvent(SDL_Event *event)
{
return SDL_WaitEventTimeoutNS(event, 0);
}
@ -1009,14 +1089,14 @@ static SDL_Window *SDL_find_active_window(SDL_VideoDevice *_this)
return NULL;
}
int SDL_WaitEvent(SDL_Event *event)
SDL_bool SDL_WaitEvent(SDL_Event *event)
{
return SDL_WaitEventTimeoutNS(event, -1);
}
int SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS)
SDL_bool SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS)
{
Uint64 timeoutNS;
Sint64 timeoutNS;
if (timeoutMS > 0) {
timeoutNS = SDL_MS_TO_NS(timeoutMS);
@ -1026,54 +1106,14 @@ int SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS)
return SDL_WaitEventTimeoutNS(event, timeoutNS);
}
int SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_Window *wakeup_window;
Uint64 start, expiration;
SDL_bool include_sentinel = (timeoutNS == 0) ? SDL_TRUE : SDL_FALSE;
SDL_bool include_sentinel = (timeoutNS == 0);
int result;
/* If there isn't a poll sentinel event pending, pump events and add one */
if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) {
SDL_PumpEventsInternal(SDL_TRUE);
}
/* First check for existing events */
result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, include_sentinel);
if (result < 0) {
return 0;
}
if (include_sentinel) {
if (event) {
if (event->type == SDL_EVENT_POLL_SENTINEL) {
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
} else {
/* Need to peek the next event to check for sentinel */
SDL_Event dummy;
if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, SDL_TRUE) &&
dummy.type == SDL_EVENT_POLL_SENTINEL) {
SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE);
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
}
}
if (result == 0) {
if (timeoutNS == 0) {
/* No events available, and not willing to wait */
return 0;
}
} else {
/* Has existing events */
return 1;
}
/* We should have completely handled timeoutNS == 0 above */
SDL_assert(timeoutNS != 0);
if (timeoutNS > 0) {
start = SDL_GetTicksNS();
expiration = start + timeoutNS;
@ -1082,36 +1122,80 @@ int SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
expiration = 0;
}
/* If there isn't a poll sentinel event pending, pump events and add one */
if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) {
SDL_PumpEventsInternal(SDL_TRUE);
}
/* First check for existing events */
result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, include_sentinel);
if (result < 0) {
return SDL_FALSE;
}
if (include_sentinel) {
if (event) {
if (event->type == SDL_EVENT_POLL_SENTINEL) {
/* Reached the end of a poll cycle, and not willing to wait */
return SDL_FALSE;
}
} else {
/* Need to peek the next event to check for sentinel */
SDL_Event dummy;
if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, SDL_TRUE) &&
dummy.type == SDL_EVENT_POLL_SENTINEL) {
SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE);
/* Reached the end of a poll cycle, and not willing to wait */
return SDL_FALSE;
}
}
}
if (result == 0) {
if (timeoutNS == 0) {
/* No events available, and not willing to wait */
return SDL_FALSE;
}
} else {
/* Has existing events */
return SDL_TRUE;
}
/* We should have completely handled timeoutNS == 0 above */
SDL_assert(timeoutNS != 0);
if (_this && _this->WaitEventTimeout && _this->SendWakeupEvent && !SDL_events_need_polling()) {
/* Look if a shown window is available to send the wakeup event. */
wakeup_window = SDL_find_active_window(_this);
if (wakeup_window) {
int status = SDL_WaitEventTimeout_Device(_this, wakeup_window, event, start, timeoutNS);
/* There may be implementation-defined conditions where the backend cannot
reliably wait for the next event. If that happens, fall back to polling. */
if (status >= 0) {
return status;
result = SDL_WaitEventTimeout_Device(_this, wakeup_window, event, start, timeoutNS);
if (result > 0) {
return SDL_TRUE;
} else if (result == 0) {
return SDL_FALSE;
} else {
/* There may be implementation-defined conditions where the backend cannot
* reliably wait for the next event. If that happens, fall back to polling.
*/
}
}
}
for (;;) {
SDL_PumpEventsInternal(SDL_TRUE);
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST)) {
case -1:
return 0;
case 0:
if (timeoutNS > 0 && SDL_GetTicksNS() >= expiration) {
/* Timeout expired and no events */
return 0;
}
SDL_Delay(1);
break;
default:
/* Has events */
return 1;
if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) > 0) {
return SDL_TRUE;
}
Uint64 delay = SDL_MS_TO_NS(1);
if (timeoutNS > 0) {
Uint64 now = SDL_GetTicksNS();
if (now >= expiration) {
/* Timeout expired and no events */
return SDL_FALSE;
}
delay = SDL_min((expiration - now), delay);
}
SDL_DelayNS(delay);
}
}
@ -1195,8 +1279,10 @@ SDL_bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
return event_ok.callback ? SDL_TRUE : SDL_FALSE;
}
void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
{
int result = 0;
SDL_LockMutex(SDL_event_watchers_lock);
{
SDL_EventWatcher *event_watchers;
@ -1211,9 +1297,13 @@ void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
watcher->userdata = userdata;
watcher->removed = SDL_FALSE;
++SDL_event_watchers_count;
} else {
result = -1;
}
}
SDL_UnlockMutex(SDL_event_watchers_lock);
return result;
}
void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
@ -1270,7 +1360,14 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled)
if (enabled != current_state) {
if (enabled) {
#ifdef _MSC_VER /* Visual Studio analyzer can't tell that SDL_disabled_events[hi] isn't NULL if enabled is true */
#pragma warning(push)
#pragma warning(disable : 6011)
#endif
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/* Gamepad events depend on joystick events */
switch (type) {
@ -1354,23 +1451,6 @@ int SDL_SendAppEvent(SDL_EventType eventType)
return posted;
}
int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
{
int posted;
posted = 0;
if (SDL_EventEnabled(SDL_EVENT_SYSWM)) {
SDL_Event event;
SDL_memset(&event, 0, sizeof(event));
event.type = SDL_EVENT_SYSWM;
event.common.timestamp = 0;
event.syswm.msg = message;
posted = (SDL_PushEvent(&event) > 0);
}
/* Update internal event state */
return posted;
}
int SDL_SendKeymapChangedEvent(void)
{
return SDL_SendAppEvent(SDL_EVENT_KEYMAP_CHANGED);

View File

@ -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,6 @@ extern void SDL_StopEventLoop(void);
extern void SDL_QuitInterrupt(void);
extern int SDL_SendAppEvent(SDL_EventType eventType);
extern int SDL_SendSysWMEvent(SDL_SysWMmsg *message);
extern int SDL_SendKeymapChangedEvent(void);
extern int SDL_SendLocaleChangedEvent(void);
extern int SDL_SendSystemThemeChangedEvent(void);

View File

@ -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
@ -778,7 +778,7 @@ int SDL_SetKeyboardFocus(SDL_Window *window)
}
}
if (keyboard->focus && window == NULL) {
if (keyboard->focus && !window) {
/* We won't get anymore keyboard messages, so reset keyboard state */
SDL_ResetKeyboard();
}
@ -1063,7 +1063,7 @@ int SDL_SendKeyboardText(const char *text)
int posted;
/* Don't post text events for unprintable characters */
if ((unsigned char)*text < ' ' || *text == 127) {
if (SDL_iscntrl((unsigned char)*text)) {
return 0;
}
@ -1071,19 +1071,18 @@ int SDL_SendKeyboardText(const char *text)
posted = 0;
if (SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
SDL_Event event;
size_t pos = 0, advance, length = SDL_strlen(text);
event.type = SDL_EVENT_TEXT_INPUT;
event.common.timestamp = 0;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
while (pos < length) {
advance = SDL_utf8strlcpy(event.text.text, text + pos, SDL_arraysize(event.text.text));
if (!advance) {
break;
}
pos += advance;
posted |= (SDL_PushEvent(&event) > 0);
size_t size = SDL_strlen(text) + 1;
event.text.text = (char *)SDL_AllocateEventMemory(size);
if (!event.text.text) {
return 0;
}
SDL_memcpy(event.text.text, text, size);
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
@ -1098,22 +1097,18 @@ int SDL_SendEditingText(const char *text, int start, int length)
if (SDL_EventEnabled(SDL_EVENT_TEXT_EDITING)) {
SDL_Event event;
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
SDL_strlen(text) >= SDL_arraysize(event.text.text)) {
event.type = SDL_EVENT_TEXT_EDITING_EXT;
event.common.timestamp = 0;
event.editExt.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.editExt.text = text ? SDL_strdup(text) : NULL;
event.editExt.start = start;
event.editExt.length = length;
} else {
event.type = SDL_EVENT_TEXT_EDITING;
event.common.timestamp = 0;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
event.type = SDL_EVENT_TEXT_EDITING;
event.common.timestamp = 0;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.edit.start = start;
event.edit.length = length;
size_t size = SDL_strlen(text) + 1;
event.edit.text = (char *)SDL_AllocateEventMemory(size);
if (!event.edit.text) {
return 0;
}
SDL_memcpy(event.edit.text, text, size);
posted = (SDL_PushEvent(&event) > 0);
}
@ -1204,7 +1199,7 @@ const char *SDL_GetScancodeName(SDL_Scancode scancode)
}
name = SDL_scancode_names[scancode];
if (name != NULL) {
if (name) {
return name;
}
@ -1215,7 +1210,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name)
{
int i;
if (name == NULL || !*name) {
if (!name || !*name) {
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
}
@ -1275,7 +1270,7 @@ SDL_Keycode SDL_GetKeyFromName(const char *name)
SDL_Keycode key;
/* Check input */
if (name == NULL) {
if (!name) {
return SDLK_UNKNOWN;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -22,9 +22,11 @@
/* General mouse handling code for SDL */
#include "SDL_events_c.h"
#include "../SDL_hints_c.h"
#include "../video/SDL_sysvideo.h"
#include "SDL_events_c.h"
#include "SDL_mouse_c.h"
#include "SDL_pen_c.h"
#if defined(__WIN32__) || defined(__GDK__)
#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime()
#endif
@ -221,6 +223,8 @@ void SDL_PostInitMouse(void)
SDL_DestroySurface(surface);
}
}
SDL_PenInit();
}
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
@ -351,17 +355,25 @@ void SDL_SetMouseFocus(SDL_Window *window)
SDL_SetCursor(NULL);
}
SDL_bool SDL_MousePositionInWindow(SDL_Window *window, SDL_MouseID mouseID, float x, float y)
{
if (!window) {
return SDL_FALSE;
}
if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
if (x < 0.0f || y < 0.0f || x >= (float)window->w || y >= (float)window->h) {
return SDL_FALSE;
}
}
return SDL_TRUE;
}
/* Check to see if we need to synthesize focus events */
static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint32 buttonstate, SDL_bool send_mouse_motion)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_bool inWindow = SDL_TRUE;
if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
if (x < 0.0f || y < 0.0f || x >= (float)window->w || y >= (float)window->h) {
inWindow = SDL_FALSE;
}
}
SDL_bool inWindow = SDL_MousePositionInWindow(window, mouse->mouseID, x, y);
if (!inWindow) {
if (window == mouse->focus) {
@ -392,7 +404,7 @@ int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseI
{
if (window && !relative) {
SDL_Mouse *mouse = SDL_GetMouse();
if (!SDL_UpdateMouseFocus(window, x, y, GetButtonState(mouse, SDL_TRUE), (mouseID == SDL_TOUCH_MOUSEID) ? SDL_FALSE : SDL_TRUE)) {
if (!SDL_UpdateMouseFocus(window, x, y, GetButtonState(mouse, SDL_TRUE), (mouseID != SDL_TOUCH_MOUSEID))) {
return 0;
}
}
@ -476,8 +488,8 @@ int SDL_SetMouseSystemScale(int num_values, const float *values)
}
v = (float *)SDL_realloc(mouse->system_scale_values, num_values * sizeof(*values));
if (v == NULL) {
return SDL_OutOfMemory();
if (!v) {
return -1;
}
SDL_memcpy(v, values, num_values * sizeof(*values));
@ -656,7 +668,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
event.motion.which = mouseID;
/* Set us pending (or clear during a normal mouse movement event) as having triggered */
mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID) ? SDL_TRUE : SDL_FALSE;
mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID);
event.motion.state = GetButtonState(mouse, SDL_TRUE);
event.motion.x = mouse->x;
event.motion.y = mouse->y;
@ -704,7 +716,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button)
if (button >= mouse->num_clickstates) {
int i, count = button + 1;
SDL_MouseClickState *clickstate = (SDL_MouseClickState *)SDL_realloc(mouse->clickstate, count * sizeof(*mouse->clickstate));
if (clickstate == NULL) {
if (!clickstate) {
return NULL;
}
mouse->clickstate = clickstate;
@ -726,7 +738,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_
SDL_MouseInputSource *source;
source = GetMouseInputSource(mouse, mouseID);
if (source == NULL) {
if (!source) {
return 0;
}
buttonstate = source->buttonstate;
@ -787,8 +799,8 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_
Uint64 now = SDL_GetTicks();
if (now >= (clickstate->last_timestamp + mouse->double_click_time) ||
SDL_fabs(mouse->x - clickstate->last_x) > mouse->double_click_radius ||
SDL_fabs(mouse->y - clickstate->last_y) > mouse->double_click_radius) {
SDL_fabs((double)mouse->x - clickstate->last_x) > mouse->double_click_radius ||
SDL_fabs((double)mouse->y - clickstate->last_y) > mouse->double_click_radius) {
clickstate->click_count = 0;
}
clickstate->last_timestamp = now;
@ -886,6 +898,7 @@ void SDL_QuitMouse(void)
}
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_ShowCursor();
SDL_PenQuit();
if (mouse->def_cursor) {
SDL_SetDefaultCursor(NULL);
@ -982,10 +995,10 @@ Uint32 SDL_GetGlobalMouseState(float *x, float *y)
float tmpx, tmpy;
/* make sure these are never NULL for the backend implementations... */
if (x == NULL) {
if (!x) {
x = &tmpx;
}
if (y == NULL) {
if (!y) {
y = &tmpy;
}
@ -1001,11 +1014,11 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool
{
SDL_Mouse *mouse = SDL_GetMouse();
if (window == NULL) {
if (!window) {
window = mouse->focus;
}
if (window == NULL) {
if (!window) {
return;
}
@ -1225,13 +1238,19 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h,
const Uint32 black = 0xFF000000;
const Uint32 white = 0xFFFFFFFF;
const Uint32 transparent = 0x00000000;
#if defined(__WIN32__)
/* Only Windows backend supports inverted pixels in mono cursors. */
const Uint32 inverted = 0x00FFFFFF;
#else
const Uint32 inverted = 0xFF000000;
#endif /* defined(__WIN32__) */
/* Make sure the width is a multiple of 8 */
w = ((w + 7) & ~7);
/* Create the surface from a bitmap */
surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888);
if (surface == NULL) {
if (!surface) {
return NULL;
}
for (y = 0; y < h; ++y) {
@ -1244,7 +1263,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h,
if (maskb & 0x80) {
*pixel++ = (datab & 0x80) ? black : white;
} else {
*pixel++ = (datab & 0x80) ? black : transparent;
*pixel++ = (datab & 0x80) ? inverted : transparent;
}
datab <<= 1;
maskb <<= 1;
@ -1264,7 +1283,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
SDL_Surface *temp = NULL;
SDL_Cursor *cursor;
if (surface == NULL) {
if (!surface) {
SDL_InvalidParamError("surface");
return NULL;
}
@ -1278,7 +1297,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
if (temp == NULL) {
if (!temp) {
return NULL;
}
surface = temp;
@ -1288,9 +1307,6 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
} else {
cursor = SDL_calloc(1, sizeof(*cursor));
if (!cursor) {
SDL_OutOfMemory();
}
}
if (cursor) {
cursor->next = mouse->cursors;
@ -1344,7 +1360,7 @@ int SDL_SetCursor(SDL_Cursor *cursor)
break;
}
}
if (found == NULL) {
if (!found) {
return SDL_SetError("Cursor not associated with the current mouse");
}
}
@ -1373,7 +1389,7 @@ SDL_Cursor *SDL_GetCursor(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse == NULL) {
if (!mouse) {
return NULL;
}
return mouse->cur_cursor;
@ -1383,7 +1399,7 @@ SDL_Cursor *SDL_GetDefaultCursor(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse == NULL) {
if (!mouse) {
return NULL;
}
return mouse->def_cursor;
@ -1394,7 +1410,7 @@ void SDL_DestroyCursor(SDL_Cursor *cursor)
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Cursor *curr, *prev;
if (cursor == NULL) {
if (!cursor) {
return;
}

View File

@ -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
@ -163,6 +163,9 @@ extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, S
extern void SDL_ResetMouse(void);
#endif /* 0 */
/* Check if mouse position is within window or captured by window */
extern SDL_bool SDL_MousePositionInWindow(SDL_Window *window, SDL_MouseID mouseID, float x, float y);
/* Shutdown the mouse subsystem */
extern void SDL_QuitMouse(void);

1099
external/sdl/SDL/src/events/SDL_pen.c vendored Normal file

File diff suppressed because it is too large Load Diff

341
external/sdl/SDL/src/events/SDL_pen_c.h vendored Normal file
View File

@ -0,0 +1,341 @@
/*
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_pen_c_h_
#define SDL_pen_c_h_
#include "../../include/SDL3/SDL_pen.h"
#include "SDL_mouse_c.h"
/* For testing alternate code paths: */
#define SDL_PEN_DEBUG_NOID 0 /* Pretend that pen device does not supply ID / ID is some default value \
affects: SDL_x11pen.c \
SDL_waylandevents.c */
#define SDL_PEN_DEBUG_NONWACOM 0 /* Pretend that no attached device is a Wacom device \
affects: SDL_x11pen.c \
SDL_waylandevents.c */
#define SDL_PEN_DEBUG_UNKNOWN_WACOM 0 /* Pretend that any attached Wacom device is of an unknown make \
affects: SDL_PenModifyFromWacomID() */
#define SDL_PEN_DEBUG_NOSERIAL_WACOM 0 /* Pretend that any attached Wacom device has serial number 0 \
affects: SDL_x11pen.c \
SDL_waylandevents.c */
#define SDL_PEN_TYPE_NONE 0 /**< Pen type for non-pens (use to cancel pen registration) */
#define SDL_PEN_MAX_NAME 64
#define SDL_PEN_FLAG_ERROR (1ul << 28) /* Printed an internal API usage error about this pen (used to prevent spamming) */
#define SDL_PEN_FLAG_NEW (1ul << 29) /* Pen was registered in most recent call to SDL_PenRegisterBegin() */
#define SDL_PEN_FLAG_DETACHED (1ul << 30) /* Detached (not re-registered before last SDL_PenGCSweep()) */
#define SDL_PEN_FLAG_STALE (1ul << 31) /* Not re-registered since last SDL_PenGCMark() */
typedef struct SDL_PenStatusInfo
{
float x, y;
float axes[SDL_PEN_NUM_AXES];
Uint16 buttons; /* SDL_BUTTON(1) | SDL_BUTTON(2) | ... | SDL_PEN_DOWN_MASK */
} SDL_PenStatusInfo;
/**
* Internal (backend driver-independent) pen representation
*
* Implementation-specific backend drivers may read and write most of this structure, and
* are expected to initialise parts of it when registering a new pen. They must not write
* to the "header" section.
*/
typedef struct SDL_Pen
{
/* Backend driver MUST NOT not write to: */
struct SDL_Pen_header
{
SDL_PenID id; /* id determines sort order unless SDL_PEN_FLAG_DETACHED is set */
Uint32 flags; /* SDL_PEN_FLAG_* | SDK_PEN_DOWN_MASK | SDL_PEN_INK_MASK | SDL_PEN_ERASER_MASK | SDL_PEN_AXIS_* */
SDL_Window *window; /* Current SDL window for this pen, or NULL */
} header;
SDL_PenStatusInfo last; /* Last reported status, normally read-only for backend */
/* Backend: MUST initialise this block when pen is first registered: */
SDL_GUID guid; /* GUID, MUST be set by backend.
MUST be unique (no other pen ID with same GUID).
SHOULD be persistent across sessions. */
/* Backend: SHOULD initialise this block when pen is first registered if it can
Otherwise: Set to sane default values during SDL_PenModifyEnd() */
SDL_PenCapabilityInfo info; /* Detail information about the pen (buttons, tilt) */
SDL_PenSubtype type;
Uint8 last_mouse_button; /* For mouse button emulation: last emulated button */
char *name; /* Preallocated; set via SDL_strlcpy(pen->name, src, SDL_PEN_MAX_NAME) */
/* We hand this exact pointer to client code, so it must not be modified after
creation. */
void *deviceinfo; /* implementation-specific information */
} SDL_Pen;
/* ---- API for backend driver only ---- */
/**
* (Only for backend driver) Look up a pen by pen ID
*
* \param instance_id A Uint32 pen identifier (driver-dependent meaning). Must not be 0 = SDL_PEN_INVALID.
* The same ID is exposed to clients as SDL_PenID.
*
* The pen pointer is only valid until the next call to SDL_PenModifyEnd() or SDL_PenGCSweep()
*
* \return pen, if it exists, or NULL
*/
extern SDL_Pen *SDL_GetPenPtr(Uint32 instance_id);
/**
* (Only for backend driver) Start registering a new pen or updating an existing pen.
*
* Acquires the pen mutex, which is held until the next call to SDL_PenModifyEnd() .
*
* If the PenID already exists, returns the existing entry. Otherwise initialise fresh SDL_Pen.
* For new pens, sets SDL_PEN_FLAG_NEW.
*
* Usage:
* - SDL_PenModifyStart()
* - update pen object, in any order:
* - SDL_PenModifyAddCapabilities()
* - pen->guid (MUST be set for new pens, e.g. via ::SDL_PenUpdateGUIDForGeneric and related operations)
* - pen->info.num_buttons
* - pen->info.max_tilt
* - pen->type
* - pen->name
* - pen->deviceinfo (backend-specific)
* - SDL_PenModifyEnd()
*
* For new pens, sets defaults for:
* - num_buttons (SDL_PEN_INFO_UNKNOWN)
* - max_tilt (SDL_PEN_INFO_UNKNOWN)
* - pen_type (SDL_PEN_TYPE_PEN)
* - Zeroes all other (non-header) fields
*
* \param instance_id Pen ID to allocate (must not be 0 = SDL_PEN_ID_INVALID)
* \returns SDL_Pen pointer; only valid until the call to SDL_PenModifyEnd()
*/
extern SDL_Pen *SDL_PenModifyBegin(Uint32 instance_id);
/**
* (Only for backend driver) Add capabilities to a pen (cf. SDL_PenModifyBegin()).
*
* Adds capabilities to a pen obtained via SDL_PenModifyBegin(). Can be called more than once.
*
* \param pen The pen to update
* \param capabilities Capabilities flags, out of: SDL_PEN_AXIS_*, SDL_PEN_ERASER_MASK, SDL_PEN_INK_MASK
* Setting SDL_PEN_ERASER_MASK will clear SDL_PEN_INK_MASK, and vice versa.
*/
extern void SDL_PenModifyAddCapabilities(SDL_Pen *pen, Uint32 capabilities);
/**
* Set up a pen structure for a Wacom device.
*
* Some backends (e.g., XInput2, Wayland) can only partially identify the capabilities of a given
* pen but can identify Wacom pens and obtain their Wacom-specific device type identifiers.
* This function partly automates device setup in those cases.
*
* This function does NOT set up the pen's GUID. Use ::SD_PenModifyGUIDForWacom instead.
*
* This function does NOT call SDL_PenModifyAddCapabilities() ifself, since some backends may
* not have access to all pen axes (e.g., Xinput2).
*
* \param pen The pen to initialise
* \param wacom_devicetype_id The Wacom-specific device type identifier
* \param[out] axis_flags The set of physically supported axes for this pen, suitable for passing to
* SDL_PenModifyAddCapabilities()
*
* \returns SDL_TRUE if the device ID could be identified, otherwise SDL_FALSE
*/
extern int SDL_PenModifyForWacomID(SDL_Pen *pen, Uint32 wacom_devicetype_id, Uint32 *axis_flags);
/**
* Updates a GUID for a generic pen device.
*
* Assumes that the GUID has been pre-initialised (typically to 0).
* Idempotent, and commutative with ::SDL_PenUpdateGUIDForWacom and ::SDL_PenUpdateGUIDForType
*
* \param[out] guid The GUID to update
* \param upper Upper half of the device ID (assume lower entropy than "lower"; pass 0 if not available)
* \param lower Lower half of the device ID (assume higher entropy than "upper")
*/
extern void SDL_PenUpdateGUIDForGeneric(SDL_GUID *guid, Uint32 upper, Uint32 lower);
/**
* Updates a GUID based on a pen type
*
* Assumes that the GUID has been pre-initialised (typically to 0).
* Idempotent, and commutative with ::SDL_PenUpdateGUIDForWacom and ::SDL_PenUpdateGUIDForGeneric
*
* \param[out] guid The GUID to update
* \param pentype The pen type to insert
*/
extern void SDL_PenUpdateGUIDForType(SDL_GUID *guid, SDL_PenSubtype pentype);
/**
* Updates a GUID for a Wacom pen device.
*
* Assumes that the GUID has been pre-initialised (typically to 0).
* Idempotent, and commutative with ::SDL_PenUpdateGUIDForType and ::SDL_PenUpdateGUIDForGeneric
*
* This update is identical to the one written by ::SDL_PenModifyFromWacomID .
*
* \param[out] guid The GUID to update
* \param wacom_devicetype_id The Wacom-specific device type identifier
* \param wacom_serial_id The Wacom-specific serial number
*/
extern void SDL_PenUpdateGUIDForWacom(SDL_GUID *guid, Uint32 wacom_devicetype_id, Uint32 wacom_serial_id);
/**
* (Only for backend driver) Finish updating a pen.
*
* Releases the pen mutex acquired by SDL_PenModifyBegin() .
*
* If pen->type == SDL_PEN_TYPE_NONE, removes the pen entirely (only
* for new pens). This allows backends to start registering a
* potential pen device and to abort if the device turns out to not be
* a pen.
*
* For new pens, this call will also set the following:
* - name (default name, if not yet set)
*
* \param pen The pen to register. That pointer is no longer valid after this call.
* \param attach Whether the pen should be attached (SDL_TRUE) or detached (SDL_FALSE).
*
* If the pen is detached or removed, it is the caller's responsibility to free
* and null "deviceinfo".
*/
extern void SDL_PenModifyEnd(SDL_Pen *pen, SDL_bool attach);
/**
* (Only for backend driver) Mark all current pens for garbage collection.
*
* Must not be called while the pen mutex is held (by SDL_PenModifyBegin() ).
*
* SDL_PenGCMark() / SDL_PenGCSweep() provide a simple mechanism for
* detaching all known pens that are not discoverable. This allows
* backends to use the same code for pen discovery and for
* hotplugging:
*
* - SDL_PenGCMark() and start backend-specific discovery
* - for each discovered pen: SDL_PenModifyBegin() + SDL_PenModifyEnd() (this will retain existing state)
* - SDL_PenGCSweep() (will now detach all pens that were not re-registered).
*/
extern void SDL_PenGCMark(void);
/**
* (Only for backend driver) Detach pens that haven't been reported attached since the last call to SDL_PenGCMark().
*
* Must not be called while the pen mutex is held (by SDL_PenModifyBegin() ).
*
* See SDL_PenGCMark() for details.
*
* \param context Extra parameter to pass through to "free_deviceinfo"
* \param free_deviceinfo Operation to call on any non-NULL "backend.deviceinfo".
*
* \sa SDL_PenGCMark()
*/
extern void SDL_PenGCSweep(void *context, void (*free_deviceinfo)(Uint32 instance_id, void *deviceinfo, void *context));
/**
* (Only for backend driver) Send a pen motion event.
*
* Suppresses pen motion events that do not change the current pen state.
* May also send a mouse motion event, if mouse emulation is enabled and the pen position has
* changed sufficiently for the motion to be visible to mouse event listeners.
*
* \param timestamp Event timestamp in nanoseconds, or 0 to ask SDL to use SDL_GetTicksNS() .
* While 0 is safe to report, your backends may be able to report more precise
* timing information.
* Keep in mind that you should never report timestamps that are greater than
* SDL_GetTicksNS() . In particular, SDL_GetTicksNS() reports nanoseconds since the start
* of the SDL session, and your backend may use a different starting point as "timestamp zero".
* \param instance_id Pen
* \param window_relative Coordinates are already window-relative
* \param status Coordinates and axes (buttons are ignored)
*
* \returns SDL_TRUE if at least one event was sent
*/
extern int SDL_SendPenMotion(Uint64 timestamp, SDL_PenID instance_id, SDL_bool window_relative, const SDL_PenStatusInfo *status);
/**
* (Only for backend driver) Send a pen button event
*
* \param timestamp Event timestamp in nanoseconds, or 0 to ask SDL to use SDL_GetTicksNS() .
* See SDL_SendPenMotion() for a discussion about how to handle timestamps.
* \param instance_id Pen
* \param state SDL_PRESSED or SDL_RELEASED
* \param button Button number: 1 (first physical button) etc.
*
* \returns SDL_TRUE if at least one event was sent
*/
extern int SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, Uint8 state, Uint8 button);
/**
* (Only for backend driver) Send a pen tip event (touching or no longer touching the surface)
*
* Note: the backend should perform hit testing on window decoration elements to allow the pen
* to e.g. resize/move the window, just as for mouse events, unless ::SDL_SendPenTipEvent is false.
*
* \param timestamp Event timestamp in nanoseconds, or 0 to ask SDL to use SDL_GetTicksNS() .
* See SDL_SendPenMotion() for a discussion about how to handle timestamps.
* \param instance_id Pen
* \param state SDL_PRESSED (for PEN_DOWN) or SDL_RELEASED (for PEN_UP)
*
* \returns SDL_TRUE if at least one event was sent
*/
extern int SDL_SendPenTipEvent(Uint64 timestamp, SDL_PenID instance_id, Uint8 state);
/**
* (Only for backend driver) Check if a PEN_DOWN event should perform hit box testing.
*
* \returns SDL_TRUE if and only if the backend should perform hit testing
*/
extern SDL_bool SDL_PenPerformHitTest(void);
/**
* (Only for backend driver) Send a pen window event.
*
* Tracks when a pen has entered/left a window.
* Don't call this when reporting new pens or removing known pens; those cases are handled automatically.
*
* \param timestamp Event timestamp in nanoseconds, or 0 to ask SDL to use SDL_GetTicksNS() .
* See SDL_SendPenMotion() for a discussion about how to handle timestamps.
* \param instance_id Pen
* \param window Window to enter, or NULL to exit
*/
extern int SDL_SendPenWindowEvent(Uint64 timestamp, SDL_PenID instance_id, SDL_Window *window);
/**
* Initialises the pen subsystem.
*/
extern void SDL_PenInit(void);
/**
* De-initialises the pen subsystem.
*/
extern void SDL_PenQuit(void);
#endif /* SDL_pen_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -44,27 +44,30 @@ int SDL_InitTouch(void)
return 0;
}
int SDL_GetNumTouchDevices(void)
SDL_bool SDL_TouchDevicesAvailable(void)
{
return SDL_num_touch;
return SDL_num_touch > 0;
}
SDL_TouchID SDL_GetTouchDevice(int index)
SDL_TouchID *SDL_GetTouchDevices(int *count)
{
if (index < 0 || index >= SDL_num_touch) {
SDL_SetError("Unknown touch device index %d", index);
return 0;
if (count) {
*count = 0;
}
return SDL_touchDevices[index]->id;
}
const char *SDL_GetTouchName(int index)
{
if (index < 0 || index >= SDL_num_touch) {
SDL_SetError("Unknown touch device");
return NULL;
const int total = SDL_num_touch;
SDL_TouchID *retval = (SDL_TouchID *) SDL_malloc(sizeof (SDL_TouchID) * (total + 1));
if (retval) {
for (int i = 0; i < total; i++) {
retval[i] = SDL_touchDevices[i]->id;
}
retval[total] = 0;
if (count) {
*count = SDL_num_touch;
}
}
return SDL_touchDevices[index]->name;
return retval;
}
static int SDL_GetTouchIndex(SDL_TouchID id)
@ -96,13 +99,16 @@ SDL_Touch *SDL_GetTouch(SDL_TouchID id)
return SDL_touchDevices[index];
}
const char *SDL_GetTouchDeviceName(SDL_TouchID id)
{
SDL_Touch *touch = SDL_GetTouch(id);
return touch ? touch->name : NULL;
}
SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID id)
{
SDL_Touch *touch = SDL_GetTouch(id);
if (touch) {
return touch->type;
}
return SDL_TOUCH_DEVICE_INVALID;
return touch ? touch->type : SDL_TOUCH_DEVICE_INVALID;
}
static int SDL_GetFingerIndex(const SDL_Touch *touch, SDL_FingerID fingerid)
@ -137,7 +143,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
SDL_Finger *SDL_GetTouchFinger(SDL_TouchID touchID, int index)
{
SDL_Touch *touch = SDL_GetTouch(touchID);
if (touch == NULL) {
if (!touch) {
return NULL;
}
if (index < 0 || index >= touch->num_fingers) {
@ -160,8 +166,8 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
/* Add the touch to the list of touch */
touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices,
(SDL_num_touch + 1) * sizeof(*touchDevices));
if (touchDevices == NULL) {
return SDL_OutOfMemory();
if (!touchDevices) {
return -1;
}
SDL_touchDevices = touchDevices;
@ -169,7 +175,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
SDL_touchDevices[index] = (SDL_Touch *)SDL_malloc(sizeof(*SDL_touchDevices[index]));
if (!SDL_touchDevices[index]) {
return SDL_OutOfMemory();
return -1;
}
/* Added touch to list */
@ -193,13 +199,13 @@ static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float
if (touch->num_fingers == touch->max_fingers) {
SDL_Finger **new_fingers;
new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers));
if (new_fingers == NULL) {
return SDL_OutOfMemory();
if (!new_fingers) {
return -1;
}
touch->fingers = new_fingers;
touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
if (!touch->fingers[touch->max_fingers]) {
return SDL_OutOfMemory();
return -1;
}
touch->max_fingers++;
}
@ -235,7 +241,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W
SDL_Mouse *mouse;
SDL_Touch *touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return -1;
}
@ -329,7 +335,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W
posted = (SDL_PushEvent(&event) > 0);
}
} else {
if (finger == NULL) {
if (!finger) {
/* This finger is already up */
return 0;
}
@ -366,7 +372,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid,
float xrel, yrel, prel;
touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return -1;
}
@ -409,7 +415,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid,
}
finger = SDL_GetFinger(touch, fingerid);
if (finger == NULL) {
if (!finger) {
return SDL_SendTouch(timestamp, id, fingerid, window, SDL_TRUE, x, y, pressure);
}
@ -461,7 +467,7 @@ void SDL_DelTouch(SDL_TouchID id)
index = SDL_GetTouchIndex(id);
touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return;
}

View File

@ -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
@ -36,6 +36,9 @@ typedef struct SDL_Touch
/* Initialize the touch subsystem */
extern int SDL_InitTouch(void);
/* Returns SDL_TRUE if _any_ connected touch devices are known to SDL */
extern SDL_bool SDL_TouchDevicesAvailable(void);
/* Add a touch, returning the index of the touch, or -1 if there was an error. */
extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name);

View File

@ -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
@ -43,7 +43,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
{
int posted;
if (window == NULL) {
if (!window) {
return 0;
}
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
@ -71,6 +71,11 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.x = data1;
window->windowed.y = data2;
if (!(window->flags & SDL_WINDOW_MAXIMIZED) && !window->state_not_floating) {
window->floating.x = data1;
window->floating.y = data2;
}
}
if (data1 == window->x && data2 == window->y) {
return 0;
@ -82,6 +87,11 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.w = data1;
window->windowed.h = data2;
if (!(window->flags & SDL_WINDOW_MAXIMIZED) && !window->state_not_floating) {
window->floating.w = data1;
window->floating.h = data2;
}
}
if (data1 == window->w && data2 == window->h) {
SDL_CheckWindowPixelSizeChanged(window);
@ -153,6 +163,18 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
}
window->flags |= SDL_WINDOW_OCCLUDED;
break;
case SDL_EVENT_WINDOW_ENTER_FULLSCREEN:
if (window->flags & SDL_WINDOW_FULLSCREEN) {
return 0;
}
window->flags |= SDL_WINDOW_FULLSCREEN;
break;
case SDL_EVENT_WINDOW_LEAVE_FULLSCREEN:
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
return 0;
}
window->flags &= ~SDL_WINDOW_FULLSCREEN;
break;
default:
break;
}
@ -222,11 +244,11 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
break;
}
if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && window->parent == NULL) {
if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && !window->parent) {
int toplevel_count = 0;
SDL_Window *n;
for (n = SDL_GetVideoDevice()->windows; n != NULL; n = n->next) {
if (n->parent == NULL) {
for (n = SDL_GetVideoDevice()->windows; n; n = n->next) {
if (!n->parent) {
++toplevel_count;
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -20,36 +20,267 @@
*/
#include "SDL_internal.h"
/* Windows scancode to SDL scancode mapping table */
/* derived from Microsoft scan code document, http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc */
/*
* Windows scancode to SDL scancode mapping table
* https://learn.microsoft.com/windows/win32/inputdev/about-keyboard-input#scan-codes */
/* *INDENT-OFF* */ /* clang-format off */
static const SDL_Scancode windows_scancode_table[] =
{
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, /* 0 */
SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, /* 1 */
SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, /* 1 */
SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, /* 2 */
SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, /* 2 */
SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,/* 3 */
SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, /* 3 */
SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, /* 4 */
SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, /* 4 */
SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, /* 5 */
SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 5 */
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, /* 6 */
SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 6 */
SDL_SCANCODE_INTERNATIONAL2, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL1, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL4, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL5, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL3, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */
static const SDL_Scancode windows_scancode_table[] = {
/*0x00*/ SDL_SCANCODE_UNKNOWN,
/*0x01*/ SDL_SCANCODE_ESCAPE,
/*0x02*/ SDL_SCANCODE_1,
/*0x03*/ SDL_SCANCODE_2,
/*0x04*/ SDL_SCANCODE_3,
/*0x05*/ SDL_SCANCODE_4,
/*0x06*/ SDL_SCANCODE_5,
/*0x07*/ SDL_SCANCODE_6,
/*0x08*/ SDL_SCANCODE_7,
/*0x09*/ SDL_SCANCODE_8,
/*0x0a*/ SDL_SCANCODE_9,
/*0x0b*/ SDL_SCANCODE_0,
/*0x0c*/ SDL_SCANCODE_MINUS,
/*0x0d*/ SDL_SCANCODE_EQUALS,
/*0x0e*/ SDL_SCANCODE_BACKSPACE,
/*0x0f*/ SDL_SCANCODE_TAB,
/*0x10*/ SDL_SCANCODE_Q,
/*0x11*/ SDL_SCANCODE_W,
/*0x12*/ SDL_SCANCODE_E,
/*0x13*/ SDL_SCANCODE_R,
/*0x14*/ SDL_SCANCODE_T,
/*0x15*/ SDL_SCANCODE_Y,
/*0x16*/ SDL_SCANCODE_U,
/*0x17*/ SDL_SCANCODE_I,
/*0x18*/ SDL_SCANCODE_O,
/*0x19*/ SDL_SCANCODE_P,
/*0x1a*/ SDL_SCANCODE_LEFTBRACKET,
/*0x1b*/ SDL_SCANCODE_RIGHTBRACKET,
/*0x1c*/ SDL_SCANCODE_RETURN,
/*0x1d*/ SDL_SCANCODE_LCTRL,
/*0x1e*/ SDL_SCANCODE_A,
/*0x1f*/ SDL_SCANCODE_S,
/*0x20*/ SDL_SCANCODE_D,
/*0x21*/ SDL_SCANCODE_F,
/*0x22*/ SDL_SCANCODE_G,
/*0x23*/ SDL_SCANCODE_H,
/*0x24*/ SDL_SCANCODE_J,
/*0x25*/ SDL_SCANCODE_K,
/*0x26*/ SDL_SCANCODE_L,
/*0x27*/ SDL_SCANCODE_SEMICOLON,
/*0x28*/ SDL_SCANCODE_APOSTROPHE,
/*0x29*/ SDL_SCANCODE_GRAVE,
/*0x2a*/ SDL_SCANCODE_LSHIFT,
/*0x2b*/ SDL_SCANCODE_BACKSLASH,
/*0x2c*/ SDL_SCANCODE_Z,
/*0x2d*/ SDL_SCANCODE_X,
/*0x2e*/ SDL_SCANCODE_C,
/*0x2f*/ SDL_SCANCODE_V,
/*0x30*/ SDL_SCANCODE_B,
/*0x31*/ SDL_SCANCODE_N,
/*0x32*/ SDL_SCANCODE_M,
/*0x33*/ SDL_SCANCODE_COMMA,
/*0x34*/ SDL_SCANCODE_PERIOD,
/*0x35*/ SDL_SCANCODE_SLASH,
/*0x36*/ SDL_SCANCODE_RSHIFT,
/*0x37*/ SDL_SCANCODE_KP_MULTIPLY,
/*0x38*/ SDL_SCANCODE_LALT,
/*0x39*/ SDL_SCANCODE_SPACE,
/*0x3a*/ SDL_SCANCODE_CAPSLOCK,
/*0x3b*/ SDL_SCANCODE_F1,
/*0x3c*/ SDL_SCANCODE_F2,
/*0x3d*/ SDL_SCANCODE_F3,
/*0x3e*/ SDL_SCANCODE_F4,
/*0x3f*/ SDL_SCANCODE_F5,
/*0x40*/ SDL_SCANCODE_F6,
/*0x41*/ SDL_SCANCODE_F7,
/*0x42*/ SDL_SCANCODE_F8,
/*0x43*/ SDL_SCANCODE_F9,
/*0x44*/ SDL_SCANCODE_F10,
/*0x45*/ SDL_SCANCODE_NUMLOCKCLEAR,
/*0x46*/ SDL_SCANCODE_SCROLLLOCK,
/*0x47*/ SDL_SCANCODE_KP_7,
/*0x48*/ SDL_SCANCODE_KP_8,
/*0x49*/ SDL_SCANCODE_KP_9,
/*0x4a*/ SDL_SCANCODE_KP_MINUS,
/*0x4b*/ SDL_SCANCODE_KP_4,
/*0x4c*/ SDL_SCANCODE_KP_5,
/*0x4d*/ SDL_SCANCODE_KP_6,
/*0x4e*/ SDL_SCANCODE_KP_PLUS,
/*0x4f*/ SDL_SCANCODE_KP_1,
/*0x50*/ SDL_SCANCODE_KP_2,
/*0x51*/ SDL_SCANCODE_KP_3,
/*0x52*/ SDL_SCANCODE_KP_0,
/*0x53*/ SDL_SCANCODE_KP_PERIOD,
/*0x54*/ SDL_SCANCODE_UNKNOWN,
/*0x55*/ SDL_SCANCODE_UNKNOWN,
/*0x56*/ SDL_SCANCODE_NONUSBACKSLASH,
/*0x57*/ SDL_SCANCODE_F11,
/*0x58*/ SDL_SCANCODE_F12,
/*0x59*/ SDL_SCANCODE_KP_EQUALS,
/*0x5a*/ SDL_SCANCODE_UNKNOWN,
/*0x5b*/ SDL_SCANCODE_UNKNOWN,
/*0x5c*/ SDL_SCANCODE_INTERNATIONAL6,
/*0x5d*/ SDL_SCANCODE_UNKNOWN,
/*0x5e*/ SDL_SCANCODE_UNKNOWN,
/*0x5f*/ SDL_SCANCODE_UNKNOWN,
/*0x60*/ SDL_SCANCODE_UNKNOWN,
/*0x61*/ SDL_SCANCODE_UNKNOWN,
/*0x62*/ SDL_SCANCODE_UNKNOWN,
/*0x63*/ SDL_SCANCODE_UNKNOWN,
/*0x64*/ SDL_SCANCODE_F13,
/*0x65*/ SDL_SCANCODE_F14,
/*0x66*/ SDL_SCANCODE_F15,
/*0x67*/ SDL_SCANCODE_F16,
/*0x68*/ SDL_SCANCODE_F17,
/*0x69*/ SDL_SCANCODE_F18,
/*0x6a*/ SDL_SCANCODE_F19,
/*0x6b*/ SDL_SCANCODE_F20,
/*0x6c*/ SDL_SCANCODE_F21,
/*0x6d*/ SDL_SCANCODE_F22,
/*0x6e*/ SDL_SCANCODE_F23,
/*0x6f*/ SDL_SCANCODE_UNKNOWN,
/*0x70*/ SDL_SCANCODE_INTERNATIONAL2,
/*0x71*/ SDL_SCANCODE_LANG2,
/*0x72*/ SDL_SCANCODE_LANG1,
/*0x73*/ SDL_SCANCODE_INTERNATIONAL1,
/*0x74*/ SDL_SCANCODE_UNKNOWN,
/*0x75*/ SDL_SCANCODE_UNKNOWN,
/*0x76*/ SDL_SCANCODE_F24,
/*0x77*/ SDL_SCANCODE_LANG4,
/*0x78*/ SDL_SCANCODE_LANG3,
/*0x79*/ SDL_SCANCODE_INTERNATIONAL4,
/*0x7a*/ SDL_SCANCODE_UNKNOWN,
/*0x7b*/ SDL_SCANCODE_INTERNATIONAL5,
/*0x7c*/ SDL_SCANCODE_UNKNOWN,
/*0x7d*/ SDL_SCANCODE_INTERNATIONAL3,
/*0x7e*/ SDL_SCANCODE_KP_COMMA,
/*0x7f*/ SDL_SCANCODE_UNKNOWN,
/*0xe000*/ SDL_SCANCODE_UNKNOWN,
/*0xe001*/ SDL_SCANCODE_UNKNOWN,
/*0xe002*/ SDL_SCANCODE_UNKNOWN,
/*0xe003*/ SDL_SCANCODE_UNKNOWN,
/*0xe004*/ SDL_SCANCODE_UNKNOWN,
/*0xe005*/ SDL_SCANCODE_UNKNOWN,
/*0xe006*/ SDL_SCANCODE_UNKNOWN,
/*0xe007*/ SDL_SCANCODE_UNKNOWN,
/*0xe008*/ SDL_SCANCODE_UNKNOWN,
/*0xe009*/ SDL_SCANCODE_UNKNOWN,
/*0xe00a*/ SDL_SCANCODE_UNKNOWN,
/*0xe00b*/ SDL_SCANCODE_UNKNOWN,
/*0xe00c*/ SDL_SCANCODE_UNKNOWN,
/*0xe00d*/ SDL_SCANCODE_UNKNOWN,
/*0xe00e*/ SDL_SCANCODE_UNKNOWN,
/*0xe00f*/ SDL_SCANCODE_UNKNOWN,
/*0xe010*/ SDL_SCANCODE_AUDIOPREV,
/*0xe011*/ SDL_SCANCODE_UNKNOWN,
/*0xe012*/ SDL_SCANCODE_UNKNOWN,
/*0xe013*/ SDL_SCANCODE_UNKNOWN,
/*0xe014*/ SDL_SCANCODE_UNKNOWN,
/*0xe015*/ SDL_SCANCODE_UNKNOWN,
/*0xe016*/ SDL_SCANCODE_UNKNOWN,
/*0xe017*/ SDL_SCANCODE_UNKNOWN,
/*0xe018*/ SDL_SCANCODE_UNKNOWN,
/*0xe019*/ SDL_SCANCODE_AUDIONEXT,
/*0xe01a*/ SDL_SCANCODE_UNKNOWN,
/*0xe01b*/ SDL_SCANCODE_UNKNOWN,
/*0xe01c*/ SDL_SCANCODE_KP_ENTER,
/*0xe01d*/ SDL_SCANCODE_RCTRL,
/*0xe01e*/ SDL_SCANCODE_UNKNOWN,
/*0xe01f*/ SDL_SCANCODE_UNKNOWN,
/*0xe020*/ SDL_SCANCODE_MUTE,
/*0xe021*/ SDL_SCANCODE_CALCULATOR,
/*0xe022*/ SDL_SCANCODE_AUDIOPLAY,
/*0xe023*/ SDL_SCANCODE_UNKNOWN,
/*0xe024*/ SDL_SCANCODE_AUDIOSTOP,
/*0xe025*/ SDL_SCANCODE_UNKNOWN,
/*0xe026*/ SDL_SCANCODE_UNKNOWN,
/*0xe027*/ SDL_SCANCODE_UNKNOWN,
/*0xe028*/ SDL_SCANCODE_UNKNOWN,
/*0xe029*/ SDL_SCANCODE_UNKNOWN,
/*0xe02a*/ SDL_SCANCODE_UNKNOWN,
/*0xe02b*/ SDL_SCANCODE_UNKNOWN,
/*0xe02c*/ SDL_SCANCODE_UNKNOWN,
/*0xe02d*/ SDL_SCANCODE_UNKNOWN,
/*0xe02e*/ SDL_SCANCODE_VOLUMEDOWN,
/*0xe02f*/ SDL_SCANCODE_UNKNOWN,
/*0xe030*/ SDL_SCANCODE_VOLUMEUP,
/*0xe031*/ SDL_SCANCODE_UNKNOWN,
/*0xe032*/ SDL_SCANCODE_AC_HOME,
/*0xe033*/ SDL_SCANCODE_UNKNOWN,
/*0xe034*/ SDL_SCANCODE_UNKNOWN,
/*0xe035*/ SDL_SCANCODE_KP_DIVIDE,
/*0xe036*/ SDL_SCANCODE_UNKNOWN,
/*0xe037*/ SDL_SCANCODE_PRINTSCREEN,
/*0xe038*/ SDL_SCANCODE_RALT,
/*0xe039*/ SDL_SCANCODE_UNKNOWN,
/*0xe03a*/ SDL_SCANCODE_UNKNOWN,
/*0xe03b*/ SDL_SCANCODE_UNKNOWN,
/*0xe03c*/ SDL_SCANCODE_UNKNOWN,
/*0xe03d*/ SDL_SCANCODE_UNKNOWN,
/*0xe03e*/ SDL_SCANCODE_UNKNOWN,
/*0xe03f*/ SDL_SCANCODE_UNKNOWN,
/*0xe040*/ SDL_SCANCODE_UNKNOWN,
/*0xe041*/ SDL_SCANCODE_UNKNOWN,
/*0xe042*/ SDL_SCANCODE_UNKNOWN,
/*0xe043*/ SDL_SCANCODE_UNKNOWN,
/*0xe044*/ SDL_SCANCODE_UNKNOWN,
/*0xe045*/ SDL_SCANCODE_NUMLOCKCLEAR,
/*0xe046*/ SDL_SCANCODE_PAUSE,
/*0xe047*/ SDL_SCANCODE_HOME,
/*0xe048*/ SDL_SCANCODE_UP,
/*0xe049*/ SDL_SCANCODE_PAGEUP,
/*0xe04a*/ SDL_SCANCODE_UNKNOWN,
/*0xe04b*/ SDL_SCANCODE_LEFT,
/*0xe04c*/ SDL_SCANCODE_UNKNOWN,
/*0xe04d*/ SDL_SCANCODE_RIGHT,
/*0xe04e*/ SDL_SCANCODE_UNKNOWN,
/*0xe04f*/ SDL_SCANCODE_END,
/*0xe050*/ SDL_SCANCODE_DOWN,
/*0xe051*/ SDL_SCANCODE_PAGEDOWN,
/*0xe052*/ SDL_SCANCODE_INSERT,
/*0xe053*/ SDL_SCANCODE_DELETE,
/*0xe054*/ SDL_SCANCODE_UNKNOWN,
/*0xe055*/ SDL_SCANCODE_UNKNOWN,
/*0xe056*/ SDL_SCANCODE_UNKNOWN,
/*0xe057*/ SDL_SCANCODE_UNKNOWN,
/*0xe058*/ SDL_SCANCODE_UNKNOWN,
/*0xe059*/ SDL_SCANCODE_UNKNOWN,
/*0xe05a*/ SDL_SCANCODE_UNKNOWN,
/*0xe05b*/ SDL_SCANCODE_LGUI,
/*0xe05c*/ SDL_SCANCODE_RGUI,
/*0xe05d*/ SDL_SCANCODE_APPLICATION,
/*0xe05e*/ SDL_SCANCODE_POWER,
/*0xe05f*/ SDL_SCANCODE_SLEEP,
/*0xe060*/ SDL_SCANCODE_UNKNOWN,
/*0xe061*/ SDL_SCANCODE_UNKNOWN,
/*0xe062*/ SDL_SCANCODE_UNKNOWN,
/*0xe063*/ SDL_SCANCODE_UNKNOWN,
/*0xe064*/ SDL_SCANCODE_UNKNOWN,
/*0xe065*/ SDL_SCANCODE_AC_SEARCH,
/*0xe066*/ SDL_SCANCODE_AC_BOOKMARKS,
/*0xe067*/ SDL_SCANCODE_AC_REFRESH,
/*0xe068*/ SDL_SCANCODE_AC_STOP,
/*0xe069*/ SDL_SCANCODE_AC_FORWARD,
/*0xe06a*/ SDL_SCANCODE_AC_BACK,
/*0xe06b*/ SDL_SCANCODE_COMPUTER,
/*0xe06c*/ SDL_SCANCODE_MAIL,
/*0xe06d*/ SDL_SCANCODE_MEDIASELECT,
/*0xe06e*/ SDL_SCANCODE_UNKNOWN,
/*0xe06f*/ SDL_SCANCODE_UNKNOWN,
/*0xe070*/ SDL_SCANCODE_UNKNOWN,
/*0xe071*/ SDL_SCANCODE_UNKNOWN,
/*0xe072*/ SDL_SCANCODE_UNKNOWN,
/*0xe073*/ SDL_SCANCODE_UNKNOWN,
/*0xe074*/ SDL_SCANCODE_UNKNOWN,
/*0xe075*/ SDL_SCANCODE_UNKNOWN,
/*0xe076*/ SDL_SCANCODE_UNKNOWN,
/*0xe077*/ SDL_SCANCODE_UNKNOWN,
/*0xe078*/ SDL_SCANCODE_UNKNOWN,
/*0xe079*/ SDL_SCANCODE_UNKNOWN,
/*0xe07a*/ SDL_SCANCODE_UNKNOWN,
/*0xe07b*/ SDL_SCANCODE_UNKNOWN,
/*0xe07c*/ SDL_SCANCODE_UNKNOWN,
/*0xe07d*/ SDL_SCANCODE_UNKNOWN,
/*0xe07e*/ SDL_SCANCODE_UNKNOWN,
/*0xe07f*/ SDL_SCANCODE_UNKNOWN
};
/* *INDENT-ON* */ /* clang-format on */

View File

@ -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