summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/src/events
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-02-27 16:28:05 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-02-27 16:53:49 +0100
commitcf6dc7d370407914020f3e623719f09c8668c692 (patch)
tree46b3416d091b4c09b50fba7ffcbd310aed032cc8 /3rdparty/SDL2/src/events
parent64135e73f973d9b95beb0c60b65feb34fbfec64a (diff)
Placed SDL2 source since we need it on some platforms (nw)
Diffstat (limited to '3rdparty/SDL2/src/events')
-rw-r--r--3rdparty/SDL2/src/events/SDL_clipboardevents.c46
-rw-r--r--3rdparty/SDL2/src/events/SDL_clipboardevents_c.h30
-rw-r--r--3rdparty/SDL2/src/events/SDL_dropevents.c46
-rw-r--r--3rdparty/SDL2/src/events/SDL_dropevents_c.h30
-rw-r--r--3rdparty/SDL2/src/events/SDL_events.c658
-rw-r--r--3rdparty/SDL2/src/events/SDL_events_c.h53
-rw-r--r--3rdparty/SDL2/src/events/SDL_gesture.c672
-rw-r--r--3rdparty/SDL2/src/events/SDL_gesture_c.h34
-rw-r--r--3rdparty/SDL2/src/events/SDL_keyboard.c1016
-rw-r--r--3rdparty/SDL2/src/events/SDL_keyboard_c.h70
-rw-r--r--3rdparty/SDL2/src/events/SDL_mouse.c898
-rw-r--r--3rdparty/SDL2/src/events/SDL_mouse_c.h130
-rw-r--r--3rdparty/SDL2/src/events/SDL_quit.c154
-rw-r--r--3rdparty/SDL2/src/events/SDL_sysevents.h36
-rw-r--r--3rdparty/SDL2/src/events/SDL_touch.c365
-rw-r--r--3rdparty/SDL2/src/events/SDL_touch_c.h61
-rw-r--r--3rdparty/SDL2/src/events/SDL_windowevents.c212
-rw-r--r--3rdparty/SDL2/src/events/SDL_windowevents_c.h31
-rw-r--r--3rdparty/SDL2/src/events/blank_cursor.h33
-rw-r--r--3rdparty/SDL2/src/events/default_cursor.h114
-rw-r--r--3rdparty/SDL2/src/events/scancodes_darwin.h159
-rw-r--r--3rdparty/SDL2/src/events/scancodes_linux.h263
-rw-r--r--3rdparty/SDL2/src/events/scancodes_windows.h55
-rw-r--r--3rdparty/SDL2/src/events/scancodes_xfree86.h421
24 files changed, 5587 insertions, 0 deletions
diff --git a/3rdparty/SDL2/src/events/SDL_clipboardevents.c b/3rdparty/SDL2/src/events/SDL_clipboardevents.c
new file mode 100644
index 00000000000..9b2209bdfea
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_clipboardevents.c
@@ -0,0 +1,46 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* Clipboard event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_clipboardevents_c.h"
+
+
+int
+SDL_SendClipboardUpdate(void)
+{
+ int posted;
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_CLIPBOARDUPDATE;
+
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_clipboardevents_c.h b/3rdparty/SDL2/src/events/SDL_clipboardevents_c.h
new file mode 100644
index 00000000000..98e6a38bd4b
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_clipboardevents_c.h
@@ -0,0 +1,30 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_clipboardevents_c_h
+#define _SDL_clipboardevents_c_h
+
+extern int SDL_SendClipboardUpdate(void);
+
+#endif /* _SDL_clipboardevents_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_dropevents.c b/3rdparty/SDL2/src/events/SDL_dropevents.c
new file mode 100644
index 00000000000..8f4405efa4e
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_dropevents.c
@@ -0,0 +1,46 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* Drag and drop event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_dropevents_c.h"
+
+
+int
+SDL_SendDropFile(const char *file)
+{
+ int posted;
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_DROPFILE;
+ event.drop.file = SDL_strdup(file);
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_dropevents_c.h b/3rdparty/SDL2/src/events/SDL_dropevents_c.h
new file mode 100644
index 00000000000..a60e089f35e
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_dropevents_c.h
@@ -0,0 +1,30 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_dropevents_c_h
+#define _SDL_dropevents_c_h
+
+extern int SDL_SendDropFile(const char *file);
+
+#endif /* _SDL_dropevents_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_events.c b/3rdparty/SDL2/src/events/SDL_events.c
new file mode 100644
index 00000000000..ffd10382495
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_events.c
@@ -0,0 +1,658 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* General event handling code for SDL */
+
+#include "SDL.h"
+#include "SDL_events.h"
+#include "SDL_syswm.h"
+#include "SDL_thread.h"
+#include "SDL_events_c.h"
+#include "../timer/SDL_timer_c.h"
+#if !SDL_JOYSTICK_DISABLED
+#include "../joystick/SDL_joystick_c.h"
+#endif
+#include "../video/SDL_sysvideo.h"
+
+/* An arbitrary limit so we don't have unbounded growth */
+#define SDL_MAX_QUEUED_EVENTS 65535
+
+/* Public data -- the event filter */
+SDL_EventFilter SDL_EventOK = NULL;
+void *SDL_EventOKParam;
+
+typedef struct SDL_EventWatcher {
+ SDL_EventFilter callback;
+ void *userdata;
+ struct SDL_EventWatcher *next;
+} SDL_EventWatcher;
+
+static SDL_EventWatcher *SDL_event_watchers = NULL;
+
+typedef struct {
+ Uint32 bits[8];
+} SDL_DisabledEventBlock;
+
+static SDL_DisabledEventBlock *SDL_disabled_events[256];
+static Uint32 SDL_userevents = SDL_USEREVENT;
+
+/* Private data -- event queue */
+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;
+ volatile SDL_bool active;
+ volatile int count;
+ volatile int max_events_seen;
+ SDL_EventEntry *head;
+ SDL_EventEntry *tail;
+ SDL_EventEntry *free;
+ SDL_SysWMEntry *wmmsg_used;
+ SDL_SysWMEntry *wmmsg_free;
+} SDL_EventQ = { NULL, SDL_TRUE, 0, 0, NULL, NULL, NULL, NULL, NULL };
+
+
+/* Public functions */
+
+void
+SDL_StopEventLoop(void)
+{
+ const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS");
+ int i;
+ SDL_EventEntry *entry;
+ SDL_SysWMEntry *wmmsg;
+
+ if (SDL_EventQ.lock) {
+ SDL_LockMutex(SDL_EventQ.lock);
+ }
+
+ SDL_EventQ.active = SDL_FALSE;
+
+ if (report && SDL_atoi(report)) {
+ SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n",
+ SDL_EventQ.max_events_seen);
+ }
+
+ /* Clean out EventQ */
+ for (entry = SDL_EventQ.head; entry; ) {
+ SDL_EventEntry *next = entry->next;
+ SDL_free(entry);
+ entry = next;
+ }
+ for (entry = SDL_EventQ.free; entry; ) {
+ SDL_EventEntry *next = entry->next;
+ 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_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;
+
+ /* 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;
+ }
+
+ while (SDL_event_watchers) {
+ SDL_EventWatcher *tmp = SDL_event_watchers;
+ SDL_event_watchers = tmp->next;
+ SDL_free(tmp);
+ }
+ SDL_EventOK = NULL;
+
+ if (SDL_EventQ.lock) {
+ SDL_UnlockMutex(SDL_EventQ.lock);
+ SDL_DestroyMutex(SDL_EventQ.lock);
+ SDL_EventQ.lock = NULL;
+ }
+}
+
+/* This function (and associated calls) may be called more than once */
+int
+SDL_StartEventLoop(void)
+{
+ /* We'll leave the event queue alone, since we might have gotten
+ some important events at launch (like SDL_DROPFILE)
+
+ FIXME: Does this introduce any other bugs with events at startup?
+ */
+
+ /* Create the lock and set ourselves active */
+#if !SDL_THREADS_DISABLED
+ if (!SDL_EventQ.lock) {
+ SDL_EventQ.lock = SDL_CreateMutex();
+ }
+ if (SDL_EventQ.lock == NULL) {
+ return (-1);
+ }
+#endif /* !SDL_THREADS_DISABLED */
+
+ /* Process most event types */
+ SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
+ SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
+ SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
+
+ SDL_EventQ.active = SDL_TRUE;
+
+ return (0);
+}
+
+
+/* Add an event to the event queue -- called with the queue locked */
+static int
+SDL_AddEvent(SDL_Event * event)
+{
+ SDL_EventEntry *entry;
+
+ if (SDL_EventQ.count >= SDL_MAX_QUEUED_EVENTS) {
+ SDL_SetError("Event queue is full (%d events)", SDL_EventQ.count);
+ return 0;
+ }
+
+ if (SDL_EventQ.free == NULL) {
+ entry = (SDL_EventEntry *)SDL_malloc(sizeof(*entry));
+ if (!entry) {
+ return 0;
+ }
+ } else {
+ entry = SDL_EventQ.free;
+ SDL_EventQ.free = entry->next;
+ }
+
+ entry->event = *event;
+ if (event->type == SDL_SYSWMEVENT) {
+ entry->msg = *event->syswm.msg;
+ entry->event.syswm.msg = &entry->msg;
+ }
+
+ if (SDL_EventQ.tail) {
+ SDL_EventQ.tail->next = entry;
+ entry->prev = SDL_EventQ.tail;
+ SDL_EventQ.tail = entry;
+ entry->next = NULL;
+ } else {
+ SDL_assert(!SDL_EventQ.head);
+ SDL_EventQ.head = entry;
+ SDL_EventQ.tail = entry;
+ entry->prev = NULL;
+ entry->next = NULL;
+ }
+ ++SDL_EventQ.count;
+
+ if (SDL_EventQ.count > SDL_EventQ.max_events_seen) {
+ SDL_EventQ.max_events_seen = SDL_EventQ.count;
+ }
+
+ return 1;
+}
+
+/* Remove an event from the queue -- called with the queue locked */
+static void
+SDL_CutEvent(SDL_EventEntry *entry)
+{
+ if (entry->prev) {
+ entry->prev->next = entry->next;
+ }
+ if (entry->next) {
+ entry->next->prev = entry->prev;
+ }
+
+ if (entry == SDL_EventQ.head) {
+ SDL_assert(entry->prev == NULL);
+ SDL_EventQ.head = entry->next;
+ }
+ if (entry == SDL_EventQ.tail) {
+ SDL_assert(entry->next == NULL);
+ SDL_EventQ.tail = entry->prev;
+ }
+
+ entry->next = SDL_EventQ.free;
+ SDL_EventQ.free = entry;
+ SDL_assert(SDL_EventQ.count > 0);
+ --SDL_EventQ.count;
+}
+
+/* Lock the event queue, take a peep at it, and unlock it */
+int
+SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
+ Uint32 minType, Uint32 maxType)
+{
+ int i, used;
+
+ /* Don't look after we've quit */
+ if (!SDL_EventQ.active) {
+ /* We get a few spurious events at shutdown, so don't warn then */
+ if (action != SDL_ADDEVENT) {
+ SDL_SetError("The event system has been shut down");
+ }
+ return (-1);
+ }
+ /* Lock the event queue */
+ used = 0;
+ if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) {
+ if (action == SDL_ADDEVENT) {
+ for (i = 0; i < numevents; ++i) {
+ used += SDL_AddEvent(&events[i]);
+ }
+ } else {
+ SDL_EventEntry *entry, *next;
+ SDL_SysWMEntry *wmmsg, *wmmsg_next;
+ SDL_Event tmpevent;
+ Uint32 type;
+
+ /* If 'events' is NULL, just see if they exist */
+ if (events == NULL) {
+ action = SDL_PEEKEVENT;
+ numevents = 1;
+ events = &tmpevent;
+ }
+
+ /* 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 && used < numevents; entry = next) {
+ next = entry->next;
+ type = entry->event.type;
+ if (minType <= type && type <= maxType) {
+ events[used] = entry->event;
+ if (entry->event.type == SDL_SYSWMEVENT) {
+ /* 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;
+ }
+ ++used;
+
+ if (action == SDL_GETEVENT) {
+ SDL_CutEvent(entry);
+ }
+ }
+ }
+ }
+ SDL_UnlockMutex(SDL_EventQ.lock);
+ } else {
+ return SDL_SetError("Couldn't lock event queue");
+ }
+ return (used);
+}
+
+SDL_bool
+SDL_HasEvent(Uint32 type)
+{
+ return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type) > 0);
+}
+
+SDL_bool
+SDL_HasEvents(Uint32 minType, Uint32 maxType)
+{
+ return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0);
+}
+
+void
+SDL_FlushEvent(Uint32 type)
+{
+ SDL_FlushEvents(type, type);
+}
+
+void
+SDL_FlushEvents(Uint32 minType, Uint32 maxType)
+{
+ /* Don't look after we've quit */
+ if (!SDL_EventQ.active) {
+ return;
+ }
+
+ /* Make sure the events are current */
+#if 0
+ /* Actually, we can't do this since we might be flushing while processing
+ a resize event, and calling this might trigger further resize events.
+ */
+ SDL_PumpEvents();
+#endif
+
+ /* Lock the event queue */
+ if (SDL_LockMutex(SDL_EventQ.lock) == 0) {
+ SDL_EventEntry *entry, *next;
+ Uint32 type;
+ for (entry = SDL_EventQ.head; entry; entry = next) {
+ next = entry->next;
+ type = entry->event.type;
+ if (minType <= type && type <= maxType) {
+ SDL_CutEvent(entry);
+ }
+ }
+ SDL_UnlockMutex(SDL_EventQ.lock);
+ }
+}
+
+/* Run the system dependent event loops */
+void
+SDL_PumpEvents(void)
+{
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
+
+ /* Get events from the video subsystem */
+ if (_this) {
+ _this->PumpEvents(_this);
+ }
+#if !SDL_JOYSTICK_DISABLED
+ /* Check for joystick state change */
+ if ((!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) {
+ SDL_JoystickUpdate();
+ }
+#endif
+
+ SDL_SendPendingQuit(); /* in case we had a signal handler fire, etc. */
+}
+
+/* Public functions */
+
+int
+SDL_PollEvent(SDL_Event * event)
+{
+ return SDL_WaitEventTimeout(event, 0);
+}
+
+int
+SDL_WaitEvent(SDL_Event * event)
+{
+ return SDL_WaitEventTimeout(event, -1);
+}
+
+int
+SDL_WaitEventTimeout(SDL_Event * event, int timeout)
+{
+ Uint32 expiration = 0;
+
+ if (timeout > 0)
+ expiration = SDL_GetTicks() + timeout;
+
+ for (;;) {
+ SDL_PumpEvents();
+ switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
+ case -1:
+ return 0;
+ case 1:
+ return 1;
+ case 0:
+ if (timeout == 0) {
+ /* Polling and no events, just return */
+ return 0;
+ }
+ if (timeout > 0 && SDL_TICKS_PASSED(SDL_GetTicks(), expiration)) {
+ /* Timeout expired and no events */
+ return 0;
+ }
+ SDL_Delay(10);
+ break;
+ }
+ }
+}
+
+int
+SDL_PushEvent(SDL_Event * event)
+{
+ SDL_EventWatcher *curr;
+
+ event->common.timestamp = SDL_GetTicks();
+
+ if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
+ return 0;
+ }
+
+ for (curr = SDL_event_watchers; curr; curr = curr->next) {
+ curr->callback(curr->userdata, event);
+ }
+
+ if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
+ return -1;
+ }
+
+ SDL_GestureProcessEvent(event);
+
+ return 1;
+}
+
+void
+SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
+{
+ /* Set filter and discard pending events */
+ SDL_EventOK = NULL;
+ SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
+ SDL_EventOKParam = userdata;
+ SDL_EventOK = filter;
+}
+
+SDL_bool
+SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata)
+{
+ if (filter) {
+ *filter = SDL_EventOK;
+ }
+ if (userdata) {
+ *userdata = SDL_EventOKParam;
+ }
+ return SDL_EventOK ? SDL_TRUE : SDL_FALSE;
+}
+
+/* FIXME: This is not thread-safe yet */
+void
+SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
+{
+ SDL_EventWatcher *watcher, *tail;
+
+ watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher));
+ if (!watcher) {
+ /* Uh oh... */
+ return;
+ }
+
+ /* create the watcher */
+ watcher->callback = filter;
+ watcher->userdata = userdata;
+ watcher->next = NULL;
+
+ /* add the watcher to the end of the list */
+ if (SDL_event_watchers) {
+ for (tail = SDL_event_watchers; tail->next; tail = tail->next) {
+ continue;
+ }
+ tail->next = watcher;
+ } else {
+ SDL_event_watchers = watcher;
+ }
+}
+
+/* FIXME: This is not thread-safe yet */
+void
+SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
+{
+ SDL_EventWatcher *prev = NULL;
+ SDL_EventWatcher *curr;
+
+ for (curr = SDL_event_watchers; curr; prev = curr, curr = curr->next) {
+ if (curr->callback == filter && curr->userdata == userdata) {
+ if (prev) {
+ prev->next = curr->next;
+ } else {
+ SDL_event_watchers = curr->next;
+ }
+ SDL_free(curr);
+ break;
+ }
+ }
+}
+
+void
+SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
+{
+ if (SDL_EventQ.lock && SDL_LockMutex(SDL_EventQ.lock) == 0) {
+ SDL_EventEntry *entry, *next;
+ for (entry = SDL_EventQ.head; entry; entry = next) {
+ next = entry->next;
+ if (!filter(userdata, &entry->event)) {
+ SDL_CutEvent(entry);
+ }
+ }
+ SDL_UnlockMutex(SDL_EventQ.lock);
+ }
+}
+
+Uint8
+SDL_EventState(Uint32 type, int state)
+{
+ Uint8 current_state;
+ Uint8 hi = ((type >> 8) & 0xff);
+ Uint8 lo = (type & 0xff);
+
+ if (SDL_disabled_events[hi] &&
+ (SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) {
+ current_state = SDL_DISABLE;
+ } else {
+ current_state = SDL_ENABLE;
+ }
+
+ if (state != current_state)
+ {
+ switch (state) {
+ case SDL_DISABLE:
+ /* Disable this event type and discard pending events */
+ if (!SDL_disabled_events[hi]) {
+ SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
+ if (!SDL_disabled_events[hi]) {
+ /* Out of memory, nothing we can do... */
+ break;
+ }
+ }
+ SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
+ SDL_FlushEvent(type);
+ break;
+ case SDL_ENABLE:
+ SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
+ break;
+ default:
+ /* Querying state... */
+ break;
+ }
+ }
+
+ return current_state;
+}
+
+Uint32
+SDL_RegisterEvents(int numevents)
+{
+ Uint32 event_base;
+
+ if ((numevents > 0) && (SDL_userevents+numevents <= SDL_LASTEVENT)) {
+ event_base = SDL_userevents;
+ SDL_userevents += numevents;
+ } else {
+ event_base = (Uint32)-1;
+ }
+ return event_base;
+}
+
+int
+SDL_SendAppEvent(SDL_EventType eventType)
+{
+ int posted;
+
+ posted = 0;
+ if (SDL_GetEventState(eventType) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = eventType;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+int
+SDL_SendSysWMEvent(SDL_SysWMmsg * message)
+{
+ int posted;
+
+ posted = 0;
+ if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
+ SDL_Event event;
+ SDL_memset(&event, 0, sizeof(event));
+ event.type = SDL_SYSWMEVENT;
+ event.syswm.msg = message;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ /* Update internal event state */
+ return (posted);
+}
+
+int
+SDL_SendKeymapChangedEvent(void)
+{
+ return SDL_SendAppEvent(SDL_KEYMAPCHANGED);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_events_c.h b/3rdparty/SDL2/src/events/SDL_events_c.h
new file mode 100644
index 00000000000..2e331904790
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_events_c.h
@@ -0,0 +1,53 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* Useful functions and variables from SDL_events.c */
+#include "SDL_events.h"
+#include "SDL_thread.h"
+#include "SDL_clipboardevents_c.h"
+#include "SDL_dropevents_c.h"
+#include "SDL_gesture_c.h"
+#include "SDL_keyboard_c.h"
+#include "SDL_mouse_c.h"
+#include "SDL_touch_c.h"
+#include "SDL_windowevents_c.h"
+
+/* Start and stop the event processing loop */
+extern int SDL_StartEventLoop(void);
+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_QuitInit(void);
+extern int SDL_SendQuit(void);
+extern void SDL_QuitQuit(void);
+
+extern void SDL_SendPendingQuit(void);
+
+/* The event filter function */
+extern SDL_EventFilter SDL_EventOK;
+extern void *SDL_EventOKParam;
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_gesture.c b/3rdparty/SDL2/src/events/SDL_gesture.c
new file mode 100644
index 00000000000..66def442948
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_gesture.c
@@ -0,0 +1,672 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* General mouse handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_endian.h"
+#include "SDL_events_c.h"
+#include "SDL_gesture_c.h"
+
+/*
+#include <stdio.h>
+*/
+
+/* TODO: Replace with malloc */
+
+#define MAXPATHSIZE 1024
+
+#define DOLLARNPOINTS 64
+#define DOLLARSIZE 256
+
+#define ENABLE_DOLLAR
+
+#define PHI 0.618033989
+
+typedef struct {
+ float x,y;
+} SDL_FloatPoint;
+
+typedef struct {
+ float length;
+
+ int numPoints;
+ SDL_FloatPoint p[MAXPATHSIZE];
+} SDL_DollarPath;
+
+typedef struct {
+ SDL_FloatPoint path[DOLLARNPOINTS];
+ unsigned long hash;
+} SDL_DollarTemplate;
+
+typedef struct {
+ SDL_TouchID id;
+ SDL_FloatPoint centroid;
+ SDL_DollarPath dollarPath;
+ Uint16 numDownFingers;
+
+ int numDollarTemplates;
+ SDL_DollarTemplate *dollarTemplate;
+
+ SDL_bool recording;
+} SDL_GestureTouch;
+
+SDL_GestureTouch *SDL_gestureTouch;
+int SDL_numGestureTouches = 0;
+SDL_bool recordAll;
+
+#if 0
+static void PrintPath(SDL_FloatPoint *path)
+{
+ int i;
+ printf("Path:");
+ for (i=0; i<DOLLARNPOINTS; i++) {
+ printf(" (%f,%f)",path[i].x,path[i].y);
+ }
+ printf("\n");
+}
+#endif
+
+int SDL_RecordGesture(SDL_TouchID touchId)
+{
+ int i;
+ if (touchId < 0) recordAll = SDL_TRUE;
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
+ SDL_gestureTouch[i].recording = SDL_TRUE;
+ if (touchId >= 0)
+ return 1;
+ }
+ }
+ return (touchId < 0);
+}
+
+static unsigned long SDL_HashDollar(SDL_FloatPoint* points)
+{
+ unsigned long hash = 5381;
+ int i;
+ for (i = 0; i < DOLLARNPOINTS; i++) {
+ hash = ((hash<<5) + hash) + (unsigned long)points[i].x;
+ hash = ((hash<<5) + hash) + (unsigned long)points[i].y;
+ }
+ return hash;
+}
+
+
+static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
+{
+ if (dst == NULL) {
+ return 0;
+ }
+
+ /* No Longer storing the Hash, rehash on load */
+ /* if (SDL_RWops.write(dst, &(templ->hash), sizeof(templ->hash), 1) != 1) return 0; */
+
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ if (SDL_RWwrite(dst, templ->path,
+ sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) {
+ return 0;
+ }
+#else
+ {
+ SDL_DollarTemplate copy = *templ;
+ SDL_FloatPoint *p = copy.path;
+ int i;
+ for (i = 0; i < DOLLARNPOINTS; i++, p++) {
+ p->x = SDL_SwapFloatLE(p->x);
+ p->y = SDL_SwapFloatLE(p->y);
+ }
+
+ if (SDL_RWwrite(dst, copy.path,
+ sizeof(copy.path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) {
+ return 0;
+ }
+ }
+#endif
+
+ return 1;
+}
+
+
+int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
+{
+ int i,j,rtrn = 0;
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ SDL_GestureTouch* touch = &SDL_gestureTouch[i];
+ for (j = 0; j < touch->numDollarTemplates; j++) {
+ rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
+ }
+ }
+ return rtrn;
+}
+
+int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst)
+{
+ int i,j;
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ SDL_GestureTouch* touch = &SDL_gestureTouch[i];
+ for (j = 0; j < touch->numDollarTemplates; j++) {
+ if (touch->dollarTemplate[j].hash == gestureId) {
+ return SaveTemplate(&touch->dollarTemplate[j], dst);
+ }
+ }
+ }
+ return SDL_SetError("Unknown gestureId");
+}
+
+/* path is an already sampled set of points
+Returns the index of the gesture on success, or -1 */
+static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
+{
+ SDL_DollarTemplate* dollarTemplate;
+ SDL_DollarTemplate *templ;
+ int index;
+
+ index = inTouch->numDollarTemplates;
+ dollarTemplate =
+ (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
+ (index + 1) *
+ sizeof(SDL_DollarTemplate));
+ if (!dollarTemplate) {
+ return SDL_OutOfMemory();
+ }
+ inTouch->dollarTemplate = dollarTemplate;
+
+ templ = &inTouch->dollarTemplate[index];
+ SDL_memcpy(templ->path, path, DOLLARNPOINTS*sizeof(SDL_FloatPoint));
+ templ->hash = SDL_HashDollar(templ->path);
+ inTouch->numDollarTemplates++;
+
+ return index;
+}
+
+static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
+{
+ int index = -1;
+ int i = 0;
+ if (inTouch == NULL) {
+ if (SDL_numGestureTouches == 0) return SDL_SetError("no gesture touch devices registered");
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ inTouch = &SDL_gestureTouch[i];
+ index = SDL_AddDollarGesture_one(inTouch, path);
+ if (index < 0)
+ return -1;
+ }
+ /* Use the index of the last one added. */
+ return index;
+ }
+ return SDL_AddDollarGesture_one(inTouch, path);
+}
+
+int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
+{
+ int i,loaded = 0;
+ SDL_GestureTouch *touch = NULL;
+ if (src == NULL) return 0;
+ if (touchId >= 0) {
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ if (SDL_gestureTouch[i].id == touchId) {
+ touch = &SDL_gestureTouch[i];
+ }
+ }
+ if (touch == NULL) {
+ return SDL_SetError("given touch id not found");
+ }
+ }
+
+ while (1) {
+ SDL_DollarTemplate templ;
+
+ if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) {
+ if (loaded == 0) {
+ return SDL_SetError("could not read any dollar gesture from rwops");
+ }
+ break;
+ }
+
+#if SDL_BYTEORDER != SDL_LIL_ENDIAN
+ for (i = 0; i < DOLLARNPOINTS; i++) {
+ SDL_FloatPoint *p = &templ.path[i];
+ p->x = SDL_SwapFloatLE(p->x);
+ p->y = SDL_SwapFloatLE(p->y);
+ }
+#endif
+
+ if (touchId >= 0) {
+ /* printf("Adding loaded gesture to 1 touch\n"); */
+ if (SDL_AddDollarGesture(touch, templ.path) >= 0)
+ loaded++;
+ }
+ else {
+ /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ touch = &SDL_gestureTouch[i];
+ /* printf("Adding loaded gesture to + touches\n"); */
+ /* TODO: What if this fails? */
+ SDL_AddDollarGesture(touch,templ.path);
+ }
+ loaded++;
+ }
+ }
+
+ return loaded;
+}
+
+
+static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang)
+{
+ /* SDL_FloatPoint p[DOLLARNPOINTS]; */
+ float dist = 0;
+ SDL_FloatPoint p;
+ int i;
+ for (i = 0; i < DOLLARNPOINTS; i++) {
+ p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang));
+ p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang));
+ dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
+ (p.y-templ[i].y)*(p.y-templ[i].y)));
+ }
+ return dist/DOLLARNPOINTS;
+
+}
+
+static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
+{
+ /*------------BEGIN DOLLAR BLACKBOX------------------
+ -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-
+ -"http://depts.washington.edu/aimgroup/proj/dollar/"
+ */
+ double ta = -M_PI/4;
+ double tb = M_PI/4;
+ double dt = M_PI/90;
+ float x1 = (float)(PHI*ta + (1-PHI)*tb);
+ float f1 = dollarDifference(points,templ,x1);
+ float x2 = (float)((1-PHI)*ta + PHI*tb);
+ float f2 = dollarDifference(points,templ,x2);
+ while (SDL_fabs(ta-tb) > dt) {
+ if (f1 < f2) {
+ tb = x2;
+ x2 = x1;
+ f2 = f1;
+ x1 = (float)(PHI*ta + (1-PHI)*tb);
+ f1 = dollarDifference(points,templ,x1);
+ }
+ else {
+ ta = x1;
+ x1 = x2;
+ f1 = f2;
+ x2 = (float)((1-PHI)*ta + PHI*tb);
+ f2 = dollarDifference(points,templ,x2);
+ }
+ }
+ /*
+ if (f1 <= f2)
+ printf("Min angle (x1): %f\n",x1);
+ else if (f1 > f2)
+ printf("Min angle (x2): %f\n",x2);
+ */
+ return SDL_min(f1,f2);
+}
+
+/* DollarPath contains raw points, plus (possibly) the calculated length */
+static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
+{
+ int i;
+ float interval;
+ float dist;
+ int numPoints = 0;
+ SDL_FloatPoint centroid;
+ float xmin,xmax,ymin,ymax;
+ float ang;
+ float w,h;
+ float length = path->length;
+
+ /* Calculate length if it hasn't already been done */
+ if (length <= 0) {
+ for (i=1;i < path->numPoints; i++) {
+ float dx = path->p[i ].x - path->p[i-1].x;
+ float dy = path->p[i ].y - path->p[i-1].y;
+ length += (float)(SDL_sqrt(dx*dx+dy*dy));
+ }
+ }
+
+ /* Resample */
+ interval = length/(DOLLARNPOINTS - 1);
+ dist = interval;
+
+ centroid.x = 0;centroid.y = 0;
+
+ /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */
+ for (i = 1; i < path->numPoints; i++) {
+ float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+
+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y)));
+ /* printf("d = %f dist = %f/%f\n",d,dist,interval); */
+ while (dist + d > interval) {
+ points[numPoints].x = path->p[i-1].x +
+ ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x);
+ points[numPoints].y = path->p[i-1].y +
+ ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y);
+ centroid.x += points[numPoints].x;
+ centroid.y += points[numPoints].y;
+ numPoints++;
+
+ dist -= interval;
+ }
+ dist += d;
+ }
+ if (numPoints < DOLLARNPOINTS-1) {
+ SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
+ return 0;
+ }
+ /* copy the last point */
+ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1];
+ numPoints = DOLLARNPOINTS;
+
+ centroid.x /= numPoints;
+ centroid.y /= numPoints;
+
+ /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */
+ /* Rotate Points so point 0 is left of centroid and solve for the bounding box */
+ xmin = centroid.x;
+ xmax = centroid.x;
+ ymin = centroid.y;
+ ymax = centroid.y;
+
+ ang = (float)(SDL_atan2(centroid.y - points[0].y,
+ centroid.x - points[0].x));
+
+ for (i = 0; i<numPoints; i++) {
+ float px = points[i].x;
+ float py = points[i].y;
+ points[i].x = (float)((px - centroid.x)*SDL_cos(ang) -
+ (py - centroid.y)*SDL_sin(ang) + centroid.x);
+ points[i].y = (float)((px - centroid.x)*SDL_sin(ang) +
+ (py - centroid.y)*SDL_cos(ang) + centroid.y);
+
+
+ if (points[i].x < xmin) xmin = points[i].x;
+ if (points[i].x > xmax) xmax = points[i].x;
+ if (points[i].y < ymin) ymin = points[i].y;
+ if (points[i].y > ymax) ymax = points[i].y;
+ }
+
+ /* Scale points to DOLLARSIZE, and translate to the origin */
+ w = xmax-xmin;
+ h = ymax-ymin;
+
+ for (i=0; i<numPoints; i++) {
+ points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
+ points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
+ }
+ return numPoints;
+}
+
+static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch)
+{
+ SDL_FloatPoint points[DOLLARNPOINTS];
+ int i;
+ float bestDiff = 10000;
+
+ SDL_memset(points, 0, sizeof(points));
+
+ dollarNormalize(path,points);
+
+ /* PrintPath(points); */
+ *bestTempl = -1;
+ for (i = 0; i < touch->numDollarTemplates; i++) {
+ float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
+ if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
+ }
+ return bestDiff;
+}
+
+int SDL_GestureAddTouch(SDL_TouchID touchId)
+{
+ SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
+ (SDL_numGestureTouches + 1) *
+ sizeof(SDL_GestureTouch));
+
+ if (!gestureTouch) {
+ return SDL_OutOfMemory();
+ }
+
+ SDL_gestureTouch = gestureTouch;
+
+ SDL_zero(SDL_gestureTouch[SDL_numGestureTouches]);
+ SDL_gestureTouch[SDL_numGestureTouches].id = touchId;
+ SDL_numGestureTouches++;
+ return 0;
+}
+
+static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
+{
+ int i;
+ for (i = 0; i < SDL_numGestureTouches; i++) {
+ /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */
+ if (SDL_gestureTouch[i].id == id)
+ return &SDL_gestureTouch[i];
+ }
+ return NULL;
+}
+
+int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist)
+{
+ SDL_Event event;
+ event.mgesture.type = SDL_MULTIGESTURE;
+ event.mgesture.touchId = touch->id;
+ event.mgesture.x = touch->centroid.x;
+ event.mgesture.y = touch->centroid.y;
+ event.mgesture.dTheta = dTheta;
+ event.mgesture.dDist = dDist;
+ event.mgesture.numFingers = touch->numDownFingers;
+ return SDL_PushEvent(&event) > 0;
+}
+
+static int SDL_SendGestureDollar(SDL_GestureTouch* touch,
+ SDL_GestureID gestureId,float error)
+{
+ SDL_Event event;
+ event.dgesture.type = SDL_DOLLARGESTURE;
+ event.dgesture.touchId = touch->id;
+ event.dgesture.x = touch->centroid.x;
+ event.dgesture.y = touch->centroid.y;
+ event.dgesture.gestureId = gestureId;
+ event.dgesture.error = error;
+ /* A finger came up to trigger this event. */
+ event.dgesture.numFingers = touch->numDownFingers + 1;
+ return SDL_PushEvent(&event) > 0;
+}
+
+
+static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId)
+{
+ SDL_Event event;
+ event.dgesture.type = SDL_DOLLARRECORD;
+ event.dgesture.touchId = touch->id;
+ event.dgesture.gestureId = gestureId;
+ return SDL_PushEvent(&event) > 0;
+}
+
+
+void SDL_GestureProcessEvent(SDL_Event* event)
+{
+ float x,y;
+ int index;
+ int i;
+ float pathDx, pathDy;
+ SDL_FloatPoint lastP;
+ SDL_FloatPoint lastCentroid;
+ float lDist;
+ float Dist;
+ float dtheta;
+ float dDist;
+
+ if (event->type == SDL_FINGERMOTION ||
+ event->type == SDL_FINGERDOWN ||
+ event->type == SDL_FINGERUP) {
+ SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
+
+ /* Shouldn't be possible */
+ if (inTouch == NULL) return;
+
+ x = event->tfinger.x;
+ y = event->tfinger.y;
+
+ /* Finger Up */
+ if (event->type == SDL_FINGERUP) {
+ SDL_FloatPoint path[DOLLARNPOINTS];
+
+ inTouch->numDownFingers--;
+
+#ifdef ENABLE_DOLLAR
+ if (inTouch->recording) {
+ inTouch->recording = SDL_FALSE;
+ dollarNormalize(&inTouch->dollarPath,path);
+ /* PrintPath(path); */
+ if (recordAll) {
+ index = SDL_AddDollarGesture(NULL,path);
+ for (i = 0; i < SDL_numGestureTouches; i++)
+ SDL_gestureTouch[i].recording = SDL_FALSE;
+ }
+ else {
+ index = SDL_AddDollarGesture(inTouch,path);
+ }
+
+ if (index >= 0) {
+ SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
+ }
+ else {
+ SDL_SendDollarRecord(inTouch,-1);
+ }
+ }
+ else {
+ int bestTempl;
+ float error;
+ error = dollarRecognize(&inTouch->dollarPath,
+ &bestTempl,inTouch);
+ if (bestTempl >= 0){
+ /* Send Event */
+ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
+ SDL_SendGestureDollar(inTouch,gestureId,error);
+ /* printf ("%s\n",);("Dollar error: %f\n",error); */
+ }
+ }
+#endif
+ /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */
+ if (inTouch->numDownFingers > 0) {
+ inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
+ x)/inTouch->numDownFingers;
+ inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)-
+ y)/inTouch->numDownFingers;
+ }
+ }
+ else if (event->type == SDL_FINGERMOTION) {
+ float dx = event->tfinger.dx;
+ float dy = event->tfinger.dy;
+#ifdef ENABLE_DOLLAR
+ SDL_DollarPath* path = &inTouch->dollarPath;
+ if (path->numPoints < MAXPATHSIZE) {
+ path->p[path->numPoints].x = inTouch->centroid.x;
+ path->p[path->numPoints].y = inTouch->centroid.y;
+ pathDx =
+ (path->p[path->numPoints].x-path->p[path->numPoints-1].x);
+ pathDy =
+ (path->p[path->numPoints].y-path->p[path->numPoints-1].y);
+ path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
+ path->numPoints++;
+ }
+#endif
+ lastP.x = x - dx;
+ lastP.y = y - dy;
+ lastCentroid = inTouch->centroid;
+
+ inTouch->centroid.x += dx/inTouch->numDownFingers;
+ inTouch->centroid.y += dy/inTouch->numDownFingers;
+ /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */
+ if (inTouch->numDownFingers > 1) {
+ SDL_FloatPoint lv; /* Vector from centroid to last x,y position */
+ SDL_FloatPoint v; /* Vector from centroid to current x,y position */
+ /* lv = inTouch->gestureLast[j].cv; */
+ lv.x = lastP.x - lastCentroid.x;
+ lv.y = lastP.y - lastCentroid.y;
+ lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
+ /* printf("lDist = %f\n",lDist); */
+ v.x = x - inTouch->centroid.x;
+ v.y = y - inTouch->centroid.y;
+ /* inTouch->gestureLast[j].cv = v; */
+ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
+ /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */
+
+ /* Normalize Vectors to simplify angle calculation */
+ lv.x/=lDist;
+ lv.y/=lDist;
+ v.x/=Dist;
+ v.y/=Dist;
+ dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
+
+ dDist = (Dist - lDist);
+ if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */
+
+ /* inTouch->gestureLast[j].dDist = dDist;
+ inTouch->gestureLast[j].dtheta = dtheta;
+
+ printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
+ gdtheta = gdtheta*.9 + dtheta*.1;
+ gdDist = gdDist*.9 + dDist*.1
+ knob.r += dDist/numDownFingers;
+ knob.ang += dtheta;
+ printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
+ printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */
+ SDL_SendGestureMulti(inTouch,dtheta,dDist);
+ }
+ else {
+ /* inTouch->gestureLast[j].dDist = 0;
+ inTouch->gestureLast[j].dtheta = 0;
+ inTouch->gestureLast[j].cv.x = 0;
+ inTouch->gestureLast[j].cv.y = 0; */
+ }
+ /* inTouch->gestureLast[j].f.p.x = x;
+ inTouch->gestureLast[j].f.p.y = y;
+ break;
+ pressure? */
+ }
+ else if (event->type == SDL_FINGERDOWN) {
+
+ inTouch->numDownFingers++;
+ inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+
+ x)/inTouch->numDownFingers;
+ inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
+ y)/inTouch->numDownFingers;
+ /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
+ inTouch->centroid.x,inTouch->centroid.y); */
+
+#ifdef ENABLE_DOLLAR
+ inTouch->dollarPath.length = 0;
+ inTouch->dollarPath.p[0].x = x;
+ inTouch->dollarPath.p[0].y = y;
+ inTouch->dollarPath.numPoints = 1;
+#endif
+ }
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_gesture_c.h b/3rdparty/SDL2/src/events/SDL_gesture_c.h
new file mode 100644
index 00000000000..3ff542cbb27
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_gesture_c.h
@@ -0,0 +1,34 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_gesture_c_h
+#define _SDL_gesture_c_h
+
+extern int SDL_GestureAddTouch(SDL_TouchID touchId);
+
+extern void SDL_GestureProcessEvent(SDL_Event* event);
+
+extern int SDL_RecordGesture(SDL_TouchID touchId);
+
+#endif /* _SDL_gesture_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_keyboard.c b/3rdparty/SDL2/src/events/SDL_keyboard.c
new file mode 100644
index 00000000000..15726545c6f
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_keyboard.c
@@ -0,0 +1,1016 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* General keyboard handling code for SDL */
+
+#include "SDL_timer.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_assert.h"
+#include "../video/SDL_sysvideo.h"
+
+
+/* #define DEBUG_KEYBOARD */
+
+/* Global keyboard information */
+
+typedef struct SDL_Keyboard SDL_Keyboard;
+
+struct SDL_Keyboard
+{
+ /* Data common to all keyboards */
+ SDL_Window *focus;
+ Uint16 modstate;
+ Uint8 keystate[SDL_NUM_SCANCODES];
+ SDL_Keycode keymap[SDL_NUM_SCANCODES];
+};
+
+static SDL_Keyboard SDL_keyboard;
+
+static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
+ 0, 0, 0, 0,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l',
+ 'm',
+ 'n',
+ 'o',
+ 'p',
+ 'q',
+ 'r',
+ 's',
+ 't',
+ 'u',
+ 'v',
+ 'w',
+ 'x',
+ 'y',
+ 'z',
+ '1',
+ '2',
+ '3',
+ '4',
+ '5',
+ '6',
+ '7',
+ '8',
+ '9',
+ '0',
+ SDLK_RETURN,
+ SDLK_ESCAPE,
+ SDLK_BACKSPACE,
+ SDLK_TAB,
+ SDLK_SPACE,
+ '-',
+ '=',
+ '[',
+ ']',
+ '\\',
+ '#',
+ ';',
+ '\'',
+ '`',
+ ',',
+ '.',
+ '/',
+ SDLK_CAPSLOCK,
+ SDLK_F1,
+ SDLK_F2,
+ SDLK_F3,
+ SDLK_F4,
+ SDLK_F5,
+ SDLK_F6,
+ SDLK_F7,
+ SDLK_F8,
+ SDLK_F9,
+ SDLK_F10,
+ SDLK_F11,
+ SDLK_F12,
+ SDLK_PRINTSCREEN,
+ SDLK_SCROLLLOCK,
+ SDLK_PAUSE,
+ SDLK_INSERT,
+ SDLK_HOME,
+ SDLK_PAGEUP,
+ SDLK_DELETE,
+ SDLK_END,
+ SDLK_PAGEDOWN,
+ SDLK_RIGHT,
+ SDLK_LEFT,
+ SDLK_DOWN,
+ SDLK_UP,
+ SDLK_NUMLOCKCLEAR,
+ SDLK_KP_DIVIDE,
+ SDLK_KP_MULTIPLY,
+ SDLK_KP_MINUS,
+ SDLK_KP_PLUS,
+ SDLK_KP_ENTER,
+ SDLK_KP_1,
+ SDLK_KP_2,
+ SDLK_KP_3,
+ SDLK_KP_4,
+ SDLK_KP_5,
+ SDLK_KP_6,
+ SDLK_KP_7,
+ SDLK_KP_8,
+ SDLK_KP_9,
+ SDLK_KP_0,
+ SDLK_KP_PERIOD,
+ 0,
+ SDLK_APPLICATION,
+ SDLK_POWER,
+ SDLK_KP_EQUALS,
+ SDLK_F13,
+ SDLK_F14,
+ SDLK_F15,
+ SDLK_F16,
+ SDLK_F17,
+ SDLK_F18,
+ SDLK_F19,
+ SDLK_F20,
+ SDLK_F21,
+ SDLK_F22,
+ SDLK_F23,
+ SDLK_F24,
+ SDLK_EXECUTE,
+ SDLK_HELP,
+ SDLK_MENU,
+ SDLK_SELECT,
+ SDLK_STOP,
+ SDLK_AGAIN,
+ SDLK_UNDO,
+ SDLK_CUT,
+ SDLK_COPY,
+ SDLK_PASTE,
+ SDLK_FIND,
+ SDLK_MUTE,
+ SDLK_VOLUMEUP,
+ SDLK_VOLUMEDOWN,
+ 0, 0, 0,
+ SDLK_KP_COMMA,
+ SDLK_KP_EQUALSAS400,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ SDLK_ALTERASE,
+ SDLK_SYSREQ,
+ SDLK_CANCEL,
+ SDLK_CLEAR,
+ SDLK_PRIOR,
+ SDLK_RETURN2,
+ SDLK_SEPARATOR,
+ SDLK_OUT,
+ SDLK_OPER,
+ SDLK_CLEARAGAIN,
+ SDLK_CRSEL,
+ SDLK_EXSEL,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ SDLK_KP_00,
+ SDLK_KP_000,
+ SDLK_THOUSANDSSEPARATOR,
+ SDLK_DECIMALSEPARATOR,
+ SDLK_CURRENCYUNIT,
+ SDLK_CURRENCYSUBUNIT,
+ SDLK_KP_LEFTPAREN,
+ SDLK_KP_RIGHTPAREN,
+ SDLK_KP_LEFTBRACE,
+ SDLK_KP_RIGHTBRACE,
+ SDLK_KP_TAB,
+ SDLK_KP_BACKSPACE,
+ SDLK_KP_A,
+ SDLK_KP_B,
+ SDLK_KP_C,
+ SDLK_KP_D,
+ SDLK_KP_E,
+ SDLK_KP_F,
+ SDLK_KP_XOR,
+ SDLK_KP_POWER,
+ SDLK_KP_PERCENT,
+ SDLK_KP_LESS,
+ SDLK_KP_GREATER,
+ SDLK_KP_AMPERSAND,
+ SDLK_KP_DBLAMPERSAND,
+ SDLK_KP_VERTICALBAR,
+ SDLK_KP_DBLVERTICALBAR,
+ SDLK_KP_COLON,
+ SDLK_KP_HASH,
+ SDLK_KP_SPACE,
+ SDLK_KP_AT,
+ SDLK_KP_EXCLAM,
+ SDLK_KP_MEMSTORE,
+ SDLK_KP_MEMRECALL,
+ SDLK_KP_MEMCLEAR,
+ SDLK_KP_MEMADD,
+ SDLK_KP_MEMSUBTRACT,
+ SDLK_KP_MEMMULTIPLY,
+ SDLK_KP_MEMDIVIDE,
+ SDLK_KP_PLUSMINUS,
+ SDLK_KP_CLEAR,
+ SDLK_KP_CLEARENTRY,
+ SDLK_KP_BINARY,
+ SDLK_KP_OCTAL,
+ SDLK_KP_DECIMAL,
+ SDLK_KP_HEXADECIMAL,
+ 0, 0,
+ SDLK_LCTRL,
+ SDLK_LSHIFT,
+ SDLK_LALT,
+ SDLK_LGUI,
+ SDLK_RCTRL,
+ SDLK_RSHIFT,
+ SDLK_RALT,
+ SDLK_RGUI,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ SDLK_MODE,
+ SDLK_AUDIONEXT,
+ SDLK_AUDIOPREV,
+ SDLK_AUDIOSTOP,
+ SDLK_AUDIOPLAY,
+ SDLK_AUDIOMUTE,
+ SDLK_MEDIASELECT,
+ SDLK_WWW,
+ SDLK_MAIL,
+ SDLK_CALCULATOR,
+ SDLK_COMPUTER,
+ SDLK_AC_SEARCH,
+ SDLK_AC_HOME,
+ SDLK_AC_BACK,
+ SDLK_AC_FORWARD,
+ SDLK_AC_STOP,
+ SDLK_AC_REFRESH,
+ SDLK_AC_BOOKMARKS,
+ SDLK_BRIGHTNESSDOWN,
+ SDLK_BRIGHTNESSUP,
+ SDLK_DISPLAYSWITCH,
+ SDLK_KBDILLUMTOGGLE,
+ SDLK_KBDILLUMDOWN,
+ SDLK_KBDILLUMUP,
+ SDLK_EJECT,
+ SDLK_SLEEP,
+};
+
+static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
+ NULL, NULL, NULL, NULL,
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "N",
+ "O",
+ "P",
+ "Q",
+ "R",
+ "S",
+ "T",
+ "U",
+ "V",
+ "W",
+ "X",
+ "Y",
+ "Z",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "0",
+ "Return",
+ "Escape",
+ "Backspace",
+ "Tab",
+ "Space",
+ "-",
+ "=",
+ "[",
+ "]",
+ "\\",
+ "#",
+ ";",
+ "'",
+ "`",
+ ",",
+ ".",
+ "/",
+ "CapsLock",
+ "F1",
+ "F2",
+ "F3",
+ "F4",
+ "F5",
+ "F6",
+ "F7",
+ "F8",
+ "F9",
+ "F10",
+ "F11",
+ "F12",
+ "PrintScreen",
+ "ScrollLock",
+ "Pause",
+ "Insert",
+ "Home",
+ "PageUp",
+ "Delete",
+ "End",
+ "PageDown",
+ "Right",
+ "Left",
+ "Down",
+ "Up",
+ "Numlock",
+ "Keypad /",
+ "Keypad *",
+ "Keypad -",
+ "Keypad +",
+ "Keypad Enter",
+ "Keypad 1",
+ "Keypad 2",
+ "Keypad 3",
+ "Keypad 4",
+ "Keypad 5",
+ "Keypad 6",
+ "Keypad 7",
+ "Keypad 8",
+ "Keypad 9",
+ "Keypad 0",
+ "Keypad .",
+ NULL,
+ "Application",
+ "Power",
+ "Keypad =",
+ "F13",
+ "F14",
+ "F15",
+ "F16",
+ "F17",
+ "F18",
+ "F19",
+ "F20",
+ "F21",
+ "F22",
+ "F23",
+ "F24",
+ "Execute",
+ "Help",
+ "Menu",
+ "Select",
+ "Stop",
+ "Again",
+ "Undo",
+ "Cut",
+ "Copy",
+ "Paste",
+ "Find",
+ "Mute",
+ "VolumeUp",
+ "VolumeDown",
+ NULL, NULL, NULL,
+ "Keypad ,",
+ "Keypad = (AS400)",
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ "AltErase",
+ "SysReq",
+ "Cancel",
+ "Clear",
+ "Prior",
+ "Return",
+ "Separator",
+ "Out",
+ "Oper",
+ "Clear / Again",
+ "CrSel",
+ "ExSel",
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "Keypad 00",
+ "Keypad 000",
+ "ThousandsSeparator",
+ "DecimalSeparator",
+ "CurrencyUnit",
+ "CurrencySubUnit",
+ "Keypad (",
+ "Keypad )",
+ "Keypad {",
+ "Keypad }",
+ "Keypad Tab",
+ "Keypad Backspace",
+ "Keypad A",
+ "Keypad B",
+ "Keypad C",
+ "Keypad D",
+ "Keypad E",
+ "Keypad F",
+ "Keypad XOR",
+ "Keypad ^",
+ "Keypad %",
+ "Keypad <",
+ "Keypad >",
+ "Keypad &",
+ "Keypad &&",
+ "Keypad |",
+ "Keypad ||",
+ "Keypad :",
+ "Keypad #",
+ "Keypad Space",
+ "Keypad @",
+ "Keypad !",
+ "Keypad MemStore",
+ "Keypad MemRecall",
+ "Keypad MemClear",
+ "Keypad MemAdd",
+ "Keypad MemSubtract",
+ "Keypad MemMultiply",
+ "Keypad MemDivide",
+ "Keypad +/-",
+ "Keypad Clear",
+ "Keypad ClearEntry",
+ "Keypad Binary",
+ "Keypad Octal",
+ "Keypad Decimal",
+ "Keypad Hexadecimal",
+ NULL, NULL,
+ "Left Ctrl",
+ "Left Shift",
+ "Left Alt",
+ "Left GUI",
+ "Right Ctrl",
+ "Right Shift",
+ "Right Alt",
+ "Right GUI",
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL,
+ "ModeSwitch",
+ "AudioNext",
+ "AudioPrev",
+ "AudioStop",
+ "AudioPlay",
+ "AudioMute",
+ "MediaSelect",
+ "WWW",
+ "Mail",
+ "Calculator",
+ "Computer",
+ "AC Search",
+ "AC Home",
+ "AC Back",
+ "AC Forward",
+ "AC Stop",
+ "AC Refresh",
+ "AC Bookmarks",
+ "BrightnessDown",
+ "BrightnessUp",
+ "DisplaySwitch",
+ "KBDIllumToggle",
+ "KBDIllumDown",
+ "KBDIllumUp",
+ "Eject",
+ "Sleep",
+};
+
+/* Taken from SDL_iconv() */
+char *
+SDL_UCS4ToUTF8(Uint32 ch, char *dst)
+{
+ Uint8 *p = (Uint8 *) dst;
+ if (ch <= 0x7F) {
+ *p = (Uint8) ch;
+ ++dst;
+ } else if (ch <= 0x7FF) {
+ p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
+ p[1] = 0x80 | (Uint8) (ch & 0x3F);
+ dst += 2;
+ } else if (ch <= 0xFFFF) {
+ p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
+ p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
+ p[2] = 0x80 | (Uint8) (ch & 0x3F);
+ dst += 3;
+ } else if (ch <= 0x1FFFFF) {
+ p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
+ p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
+ p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
+ p[3] = 0x80 | (Uint8) (ch & 0x3F);
+ dst += 4;
+ } else if (ch <= 0x3FFFFFF) {
+ p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
+ p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
+ p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
+ p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
+ p[4] = 0x80 | (Uint8) (ch & 0x3F);
+ dst += 5;
+ } else {
+ p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
+ p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
+ p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
+ p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
+ p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
+ p[5] = 0x80 | (Uint8) (ch & 0x3F);
+ dst += 6;
+ }
+ return dst;
+}
+
+/* Public functions */
+int
+SDL_KeyboardInit(void)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ /* Set the default keymap */
+ SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
+ return (0);
+}
+
+void
+SDL_ResetKeyboard(void)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ SDL_Scancode scancode;
+
+#ifdef DEBUG_KEYBOARD
+ printf("Resetting keyboard\n");
+#endif
+ for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
+ if (keyboard->keystate[scancode] == SDL_PRESSED) {
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
+ }
+}
+
+void
+SDL_GetDefaultKeymap(SDL_Keycode * keymap)
+{
+ SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
+}
+
+void
+SDL_SetKeymap(int start, SDL_Keycode * keys, int length)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ if (start < 0 || start + length > SDL_NUM_SCANCODES) {
+ return;
+ }
+
+ SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);
+}
+
+void
+SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
+{
+ SDL_scancode_names[scancode] = name;
+}
+
+SDL_Window *
+SDL_GetKeyboardFocus(void)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ return keyboard->focus;
+}
+
+void
+SDL_SetKeyboardFocus(SDL_Window * window)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ if (keyboard->focus && !window) {
+ /* We won't get anymore keyboard messages, so reset keyboard state */
+ SDL_ResetKeyboard();
+ }
+
+ /* See if the current window has lost focus */
+ if (keyboard->focus && keyboard->focus != window) {
+
+ /* new window shouldn't think it has mouse captured. */
+ SDL_assert(!window || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE));
+
+ /* old window must lose an existing mouse capture. */
+ if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) {
+ SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */
+ SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE));
+ }
+
+ SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
+ 0, 0);
+
+ /* Ensures IME compositions are committed */
+ if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
+ SDL_VideoDevice *video = SDL_GetVideoDevice();
+ if (video && video->StopTextInput) {
+ video->StopTextInput(video);
+ }
+ }
+ }
+
+ keyboard->focus = window;
+
+ if (keyboard->focus) {
+ SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
+ 0, 0);
+
+ if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
+ SDL_VideoDevice *video = SDL_GetVideoDevice();
+ if (video && video->StartTextInput) {
+ video->StartTextInput(video);
+ }
+ }
+ }
+}
+
+int
+SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ int posted;
+ SDL_Keymod modifier;
+ SDL_Keycode keycode;
+ Uint16 modstate;
+ Uint32 type;
+ Uint8 repeat;
+
+ if (!scancode) {
+ return 0;
+ }
+#ifdef DEBUG_KEYBOARD
+ printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
+ state == SDL_PRESSED ? "pressed" : "released");
+#endif
+
+ /* Figure out what type of event this is */
+ switch (state) {
+ case SDL_PRESSED:
+ type = SDL_KEYDOWN;
+ break;
+ case SDL_RELEASED:
+ type = SDL_KEYUP;
+ break;
+ default:
+ /* Invalid state -- bail */
+ return 0;
+ }
+
+ /* Drop events that don't change state */
+ repeat = (state && keyboard->keystate[scancode]);
+ if (keyboard->keystate[scancode] == state && !repeat) {
+#if 0
+ printf("Keyboard event didn't change state - dropped!\n");
+#endif
+ return 0;
+ }
+
+ /* Update internal keyboard state */
+ keyboard->keystate[scancode] = state;
+
+ keycode = keyboard->keymap[scancode];
+
+ /* Update modifiers state if applicable */
+ switch (keycode) {
+ case SDLK_LCTRL:
+ modifier = KMOD_LCTRL;
+ break;
+ case SDLK_RCTRL:
+ modifier = KMOD_RCTRL;
+ break;
+ case SDLK_LSHIFT:
+ modifier = KMOD_LSHIFT;
+ break;
+ case SDLK_RSHIFT:
+ modifier = KMOD_RSHIFT;
+ break;
+ case SDLK_LALT:
+ modifier = KMOD_LALT;
+ break;
+ case SDLK_RALT:
+ modifier = KMOD_RALT;
+ break;
+ case SDLK_LGUI:
+ modifier = KMOD_LGUI;
+ break;
+ case SDLK_RGUI:
+ modifier = KMOD_RGUI;
+ break;
+ case SDLK_MODE:
+ modifier = KMOD_MODE;
+ break;
+ default:
+ modifier = KMOD_NONE;
+ break;
+ }
+ if (SDL_KEYDOWN == type) {
+ modstate = keyboard->modstate;
+ switch (keycode) {
+ case SDLK_NUMLOCKCLEAR:
+ keyboard->modstate ^= KMOD_NUM;
+ break;
+ case SDLK_CAPSLOCK:
+ keyboard->modstate ^= KMOD_CAPS;
+ break;
+ default:
+ keyboard->modstate |= modifier;
+ break;
+ }
+ } else {
+ keyboard->modstate &= ~modifier;
+ modstate = keyboard->modstate;
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(type) == SDL_ENABLE) {
+ SDL_Event event;
+ event.key.type = type;
+ event.key.state = state;
+ event.key.repeat = repeat;
+ event.key.keysym.scancode = scancode;
+ event.key.keysym.sym = keycode;
+ event.key.keysym.mod = modstate;
+ event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+int
+SDL_SendKeyboardText(const char *text)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ int posted;
+
+ /* Don't post text events for unprintable characters */
+ if ((unsigned char)*text < ' ' || *text == 127) {
+ return 0;
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
+ SDL_Event event;
+ event.text.type = SDL_TEXTINPUT;
+ event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
+ SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+int
+SDL_SendEditingText(const char *text, int start, int length)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ int posted;
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
+ SDL_Event event;
+ event.edit.type = SDL_TEXTEDITING;
+ 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));
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+void
+SDL_KeyboardQuit(void)
+{
+}
+
+const Uint8 *
+SDL_GetKeyboardState(int *numkeys)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ if (numkeys != (int *) 0) {
+ *numkeys = SDL_NUM_SCANCODES;
+ }
+ return keyboard->keystate;
+}
+
+SDL_Keymod
+SDL_GetModState(void)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ return keyboard->modstate;
+}
+
+void
+SDL_SetModState(SDL_Keymod modstate)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ keyboard->modstate = modstate;
+}
+
+/* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */
+void
+SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ if (toggle) {
+ keyboard->modstate |= modstate;
+ } else {
+ keyboard->modstate &= ~modstate;
+ }
+}
+
+
+SDL_Keycode
+SDL_GetKeyFromScancode(SDL_Scancode scancode)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
+ SDL_InvalidParamError("scancode");
+ return 0;
+ }
+
+ return keyboard->keymap[scancode];
+}
+
+SDL_Scancode
+SDL_GetScancodeFromKey(SDL_Keycode key)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+ SDL_Scancode scancode;
+
+ for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
+ ++scancode) {
+ if (keyboard->keymap[scancode] == key) {
+ return scancode;
+ }
+ }
+ return SDL_SCANCODE_UNKNOWN;
+}
+
+const char *
+SDL_GetScancodeName(SDL_Scancode scancode)
+{
+ const char *name;
+ if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
+ SDL_InvalidParamError("scancode");
+ return "";
+ }
+
+ name = SDL_scancode_names[scancode];
+ if (name)
+ return name;
+ else
+ return "";
+}
+
+SDL_Scancode SDL_GetScancodeFromName(const char *name)
+{
+ int i;
+
+ if (!name || !*name) {
+ SDL_InvalidParamError("name");
+ return SDL_SCANCODE_UNKNOWN;
+ }
+
+ for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
+ if (!SDL_scancode_names[i]) {
+ continue;
+ }
+ if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
+ return (SDL_Scancode)i;
+ }
+ }
+
+ SDL_InvalidParamError("name");
+ return SDL_SCANCODE_UNKNOWN;
+}
+
+const char *
+SDL_GetKeyName(SDL_Keycode key)
+{
+ static char name[8];
+ char *end;
+
+ if (key & SDLK_SCANCODE_MASK) {
+ return
+ SDL_GetScancodeName((SDL_Scancode) (key & ~SDLK_SCANCODE_MASK));
+ }
+
+ switch (key) {
+ case SDLK_RETURN:
+ return SDL_GetScancodeName(SDL_SCANCODE_RETURN);
+ case SDLK_ESCAPE:
+ return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE);
+ case SDLK_BACKSPACE:
+ return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE);
+ case SDLK_TAB:
+ return SDL_GetScancodeName(SDL_SCANCODE_TAB);
+ case SDLK_SPACE:
+ return SDL_GetScancodeName(SDL_SCANCODE_SPACE);
+ case SDLK_DELETE:
+ return SDL_GetScancodeName(SDL_SCANCODE_DELETE);
+ default:
+ /* Unaccented letter keys on latin keyboards are normally
+ labeled in upper case (and probably on others like Greek or
+ Cyrillic too, so if you happen to know for sure, please
+ adapt this). */
+ if (key >= 'a' && key <= 'z') {
+ key -= 32;
+ }
+
+ end = SDL_UCS4ToUTF8((Uint32) key, name);
+ *end = '\0';
+ return name;
+ }
+}
+
+SDL_Keycode
+SDL_GetKeyFromName(const char *name)
+{
+ SDL_Keycode key;
+
+ /* Check input */
+ if (name == NULL) return SDLK_UNKNOWN;
+
+ /* If it's a single UTF-8 character, then that's the keycode itself */
+ key = *(const unsigned char *)name;
+ if (key >= 0xF0) {
+ if (SDL_strlen(name) == 4) {
+ int i = 0;
+ key = (Uint16)(name[i]&0x07) << 18;
+ key |= (Uint16)(name[++i]&0x3F) << 12;
+ key |= (Uint16)(name[++i]&0x3F) << 6;
+ key |= (Uint16)(name[++i]&0x3F);
+ return key;
+ }
+ return SDLK_UNKNOWN;
+ } else if (key >= 0xE0) {
+ if (SDL_strlen(name) == 3) {
+ int i = 0;
+ key = (Uint16)(name[i]&0x0F) << 12;
+ key |= (Uint16)(name[++i]&0x3F) << 6;
+ key |= (Uint16)(name[++i]&0x3F);
+ return key;
+ }
+ return SDLK_UNKNOWN;
+ } else if (key >= 0xC0) {
+ if (SDL_strlen(name) == 2) {
+ int i = 0;
+ key = (Uint16)(name[i]&0x1F) << 6;
+ key |= (Uint16)(name[++i]&0x3F);
+ return key;
+ }
+ return SDLK_UNKNOWN;
+ } else {
+ if (SDL_strlen(name) == 1) {
+ if (key >= 'A' && key <= 'Z') {
+ key += 32;
+ }
+ return key;
+ }
+
+ /* Get the scancode for this name, and the associated keycode */
+ return SDL_default_keymap[SDL_GetScancodeFromName(name)];
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_keyboard_c.h b/3rdparty/SDL2/src/events/SDL_keyboard_c.h
new file mode 100644
index 00000000000..b4d1c0739ba
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_keyboard_c.h
@@ -0,0 +1,70 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_keyboard_c_h
+#define _SDL_keyboard_c_h
+
+#include "SDL_keycode.h"
+#include "SDL_events.h"
+
+/* Initialize the keyboard subsystem */
+extern int SDL_KeyboardInit(void);
+
+/* Clear the state of the keyboard */
+extern void SDL_ResetKeyboard(void);
+
+/* Get the default keymap */
+extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap);
+
+/* Set the mapping of scancode to key codes */
+extern void SDL_SetKeymap(int start, SDL_Keycode * keys, int length);
+
+/* Set a platform-dependent key name, overriding the default platform-agnostic
+ name. Encoded as UTF-8. The string is not copied, thus the pointer given to
+ this function must stay valid forever (or at least until the call to
+ VideoQuit()). */
+extern void SDL_SetScancodeName(SDL_Scancode scancode, const char *name);
+
+/* Set the keyboard focus window */
+extern void SDL_SetKeyboardFocus(SDL_Window * window);
+
+/* Send a keyboard key event */
+extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
+
+/* Send keyboard text input */
+extern int SDL_SendKeyboardText(const char *text);
+
+/* Send editing text for selected range from start to end */
+extern int SDL_SendEditingText(const char *text, int start, int end);
+
+/* Shutdown the keyboard subsystem */
+extern void SDL_KeyboardQuit(void);
+
+/* Convert to UTF-8 */
+extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst);
+
+/* Toggle on or off pieces of the keyboard mod state. */
+extern void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle);
+
+#endif /* _SDL_keyboard_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_mouse.c b/3rdparty/SDL2/src/events/SDL_mouse.c
new file mode 100644
index 00000000000..7793de870be
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_mouse.c
@@ -0,0 +1,898 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* General mouse handling code for SDL */
+
+#include "SDL_assert.h"
+#include "SDL_hints.h"
+#include "SDL_timer.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "default_cursor.h"
+#include "../video/SDL_sysvideo.h"
+
+/* #define DEBUG_MOUSE */
+
+/* The mouse state */
+static SDL_Mouse SDL_mouse;
+static Uint32 SDL_double_click_time = 500;
+static int SDL_double_click_radius = 1;
+
+static int
+SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
+
+/* Public functions */
+int
+SDL_MouseInit(void)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ mouse->cursor_shown = SDL_TRUE;
+
+ return (0);
+}
+
+void
+SDL_SetDefaultCursor(SDL_Cursor * cursor)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ mouse->def_cursor = cursor;
+ if (!mouse->cur_cursor) {
+ SDL_SetCursor(cursor);
+ }
+}
+
+SDL_Mouse *
+SDL_GetMouse(void)
+{
+ return &SDL_mouse;
+}
+
+void
+SDL_SetDoubleClickTime(Uint32 interval)
+{
+ SDL_double_click_time = interval;
+}
+
+SDL_Window *
+SDL_GetMouseFocus(void)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ return mouse->focus;
+}
+
+void
+SDL_ResetMouse(void)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ Uint8 i;
+
+#ifdef DEBUG_MOUSE
+ printf("Resetting mouse\n");
+#endif
+ for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) {
+ if (mouse->buttonstate & SDL_BUTTON(i)) {
+ SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, i);
+ }
+ }
+ SDL_assert(mouse->buttonstate == 0);
+}
+
+void
+SDL_SetMouseFocus(SDL_Window * window)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (mouse->focus == window) {
+ return;
+ }
+
+ /* Actually, this ends up being a bad idea, because most operating
+ systems have an implicit grab when you press the mouse button down
+ so you can drag things out of the window and then get the mouse up
+ when it happens. So, #if 0...
+ */
+#if 0
+ if (mouse->focus && !window) {
+ /* We won't get anymore mouse messages, so reset mouse state */
+ SDL_ResetMouse();
+ }
+#endif
+
+ /* See if the current window has lost focus */
+ if (mouse->focus) {
+ SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
+ }
+
+ mouse->focus = window;
+
+ if (mouse->focus) {
+ SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
+ }
+
+ /* Update cursor visibility */
+ SDL_SetCursor(NULL);
+}
+
+/* Check to see if we need to synthesize focus events */
+static SDL_bool
+SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_bool inWindow = SDL_TRUE;
+
+ if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
+ int w, h;
+ SDL_GetWindowSize(window, &w, &h);
+ if (x < 0 || y < 0 || x >= w || y >= h) {
+ inWindow = SDL_FALSE;
+ }
+ }
+
+/* Linux doesn't give you mouse events outside your window unless you grab
+ the pointer.
+
+ Windows doesn't give you mouse events outside your window unless you call
+ SetCapture().
+
+ Both of these are slightly scary changes, so for now we'll punt and if the
+ mouse leaves the window you'll lose mouse focus and reset button state.
+*/
+#ifdef SUPPORT_DRAG_OUTSIDE_WINDOW
+ if (!inWindow && !buttonstate) {
+#else
+ if (!inWindow) {
+#endif
+ if (window == mouse->focus) {
+#ifdef DEBUG_MOUSE
+ printf("Mouse left window, synthesizing move & focus lost event\n");
+#endif
+ SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
+ SDL_SetMouseFocus(NULL);
+ }
+ return SDL_FALSE;
+ }
+
+ if (window != mouse->focus) {
+#ifdef DEBUG_MOUSE
+ printf("Mouse entered window, synthesizing focus gain & move event\n");
+#endif
+ SDL_SetMouseFocus(window);
+ SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
+ }
+ return SDL_TRUE;
+}
+
+int
+SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
+{
+ if (window && !relative) {
+ SDL_Mouse *mouse = SDL_GetMouse();
+ if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) {
+ return 0;
+ }
+ }
+
+ return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y);
+}
+
+static int
+SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ int posted;
+ int xrel;
+ int yrel;
+
+ if (mouse->relative_mode_warp) {
+ int center_x = 0, center_y = 0;
+ SDL_GetWindowSize(window, &center_x, &center_y);
+ center_x /= 2;
+ center_y /= 2;
+ if (x == center_x && y == center_y) {
+ mouse->last_x = center_x;
+ mouse->last_y = center_y;
+ return 0;
+ }
+ SDL_WarpMouseInWindow(window, center_x, center_y);
+ }
+
+ if (relative) {
+ xrel = x;
+ yrel = y;
+ x = (mouse->last_x + xrel);
+ y = (mouse->last_y + yrel);
+ } else {
+ xrel = x - mouse->last_x;
+ yrel = y - mouse->last_y;
+ }
+
+ /* Drop events that don't change state */
+ if (!xrel && !yrel) {
+#ifdef DEBUG_MOUSE
+ printf("Mouse event didn't change state - dropped!\n");
+#endif
+ return 0;
+ }
+
+ /* Update internal mouse coordinates */
+ if (!mouse->relative_mode) {
+ mouse->x = x;
+ mouse->y = y;
+ } else {
+ mouse->x += xrel;
+ mouse->y += yrel;
+ }
+
+ /* make sure that the pointers find themselves inside the windows,
+ unless we have the mouse captured. */
+ if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
+ int x_max = 0, y_max = 0;
+
+ // !!! FIXME: shouldn't this be (window) instead of (mouse->focus)?
+ SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
+ --x_max;
+ --y_max;
+
+ if (mouse->x > x_max) {
+ mouse->x = x_max;
+ }
+ if (mouse->x < 0) {
+ mouse->x = 0;
+ }
+
+ if (mouse->y > y_max) {
+ mouse->y = y_max;
+ }
+ if (mouse->y < 0) {
+ mouse->y = 0;
+ }
+ }
+
+ mouse->xdelta += xrel;
+ mouse->ydelta += yrel;
+
+ /* Move the mouse cursor, if needed */
+ if (mouse->cursor_shown && !mouse->relative_mode &&
+ mouse->MoveCursor && mouse->cur_cursor) {
+ mouse->MoveCursor(mouse->cur_cursor);
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
+ SDL_Event event;
+ event.motion.type = SDL_MOUSEMOTION;
+ event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
+ event.motion.which = mouseID;
+ event.motion.state = mouse->buttonstate;
+ event.motion.x = mouse->x;
+ event.motion.y = mouse->y;
+ event.motion.xrel = xrel;
+ event.motion.yrel = yrel;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ if (relative) {
+ mouse->last_x = mouse->x;
+ mouse->last_y = mouse->y;
+ } else {
+ /* Use unclamped values if we're getting events outside the window */
+ mouse->last_x = x;
+ mouse->last_y = y;
+ }
+ return posted;
+}
+
+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) {
+ return NULL;
+ }
+ mouse->clickstate = clickstate;
+
+ for (i = mouse->num_clickstates; i < count; ++i) {
+ SDL_zero(mouse->clickstate[i]);
+ }
+ mouse->num_clickstates = count;
+ }
+ return &mouse->clickstate[button];
+}
+
+int
+SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ int posted;
+ Uint32 type;
+ Uint32 buttonstate = mouse->buttonstate;
+ SDL_MouseClickState *clickstate = GetMouseClickState(mouse, button);
+ Uint8 click_count;
+
+ /* Figure out which event to perform */
+ switch (state) {
+ case SDL_PRESSED:
+ type = SDL_MOUSEBUTTONDOWN;
+ buttonstate |= SDL_BUTTON(button);
+ break;
+ case SDL_RELEASED:
+ type = SDL_MOUSEBUTTONUP;
+ buttonstate &= ~SDL_BUTTON(button);
+ break;
+ default:
+ /* Invalid state -- bail */
+ return 0;
+ }
+
+ /* We do this after calculating buttonstate so button presses gain focus */
+ if (window && state == SDL_PRESSED) {
+ SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate);
+ }
+
+ if (buttonstate == mouse->buttonstate) {
+ /* Ignore this event, no state change */
+ return 0;
+ }
+ mouse->buttonstate = buttonstate;
+
+ if (clickstate) {
+ if (state == SDL_PRESSED) {
+ Uint32 now = SDL_GetTicks();
+
+ if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) ||
+ SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius ||
+ SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) {
+ clickstate->click_count = 0;
+ }
+ clickstate->last_timestamp = now;
+ clickstate->last_x = mouse->x;
+ clickstate->last_y = mouse->y;
+ if (clickstate->click_count < 255) {
+ ++clickstate->click_count;
+ }
+ }
+ click_count = clickstate->click_count;
+ } else {
+ click_count = 1;
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(type) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = type;
+ event.button.windowID = mouse->focus ? mouse->focus->id : 0;
+ event.button.which = mouseID;
+ event.button.state = state;
+ event.button.button = button;
+ event.button.clicks = click_count;
+ event.button.x = mouse->x;
+ event.button.y = mouse->y;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+
+ /* We do this after dispatching event so button releases can lose focus */
+ if (window && state == SDL_RELEASED) {
+ SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate);
+ }
+
+ return posted;
+}
+
+int
+SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ int posted;
+
+ if (window) {
+ SDL_SetMouseFocus(window);
+ }
+
+ if (!x && !y) {
+ return 0;
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_MOUSEWHEEL;
+ event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
+ event.wheel.which = mouseID;
+ event.wheel.x = x;
+ event.wheel.y = y;
+ event.wheel.direction = (Uint32)direction;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return posted;
+}
+
+void
+SDL_MouseQuit(void)
+{
+ SDL_Cursor *cursor, *next;
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (mouse->CaptureMouse) {
+ SDL_CaptureMouse(SDL_FALSE);
+ }
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+ SDL_ShowCursor(1);
+
+ cursor = mouse->cursors;
+ while (cursor) {
+ next = cursor->next;
+ SDL_FreeCursor(cursor);
+ cursor = next;
+ }
+
+ if (mouse->def_cursor && mouse->FreeCursor) {
+ mouse->FreeCursor(mouse->def_cursor);
+ }
+
+ if (mouse->clickstate) {
+ SDL_free(mouse->clickstate);
+ }
+
+ SDL_zerop(mouse);
+}
+
+Uint32
+SDL_GetMouseState(int *x, int *y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (x) {
+ *x = mouse->x;
+ }
+ if (y) {
+ *y = mouse->y;
+ }
+ return mouse->buttonstate;
+}
+
+Uint32
+SDL_GetRelativeMouseState(int *x, int *y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (x) {
+ *x = mouse->xdelta;
+ }
+ if (y) {
+ *y = mouse->ydelta;
+ }
+ mouse->xdelta = 0;
+ mouse->ydelta = 0;
+ return mouse->buttonstate;
+}
+
+Uint32
+SDL_GetGlobalMouseState(int *x, int *y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ int tmpx, tmpy;
+
+ /* make sure these are never NULL for the backend implementations... */
+ if (!x) {
+ x = &tmpx;
+ }
+ if (!y) {
+ y = &tmpy;
+ }
+
+ *x = *y = 0;
+
+ if (!mouse->GetGlobalMouseState) {
+ SDL_assert(0 && "This should really be implemented for every target.");
+ return 0;
+ }
+
+ return mouse->GetGlobalMouseState(x, y);
+}
+
+void
+SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (window == NULL) {
+ window = mouse->focus;
+ }
+
+ if (window == NULL) {
+ return;
+ }
+
+ if (mouse->WarpMouse) {
+ mouse->WarpMouse(window, x, y);
+ } else {
+ SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
+ }
+}
+
+int
+SDL_WarpMouseGlobal(int x, int y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (mouse->WarpMouseGlobal) {
+ return mouse->WarpMouseGlobal(x, y);
+ }
+
+ return SDL_Unsupported();
+}
+
+static SDL_bool
+ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
+{
+ const char *hint;
+
+ if (!mouse->SetRelativeMouseMode) {
+ return SDL_TRUE;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP);
+ if (hint) {
+ if (*hint == '0') {
+ return SDL_FALSE;
+ } else {
+ return SDL_TRUE;
+ }
+ }
+ return SDL_FALSE;
+}
+
+int
+SDL_SetRelativeMouseMode(SDL_bool enabled)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_Window *focusWindow = SDL_GetKeyboardFocus();
+
+ if (enabled == mouse->relative_mode) {
+ return 0;
+ }
+
+ if (enabled && focusWindow) {
+ /* Center it in the focused window to prevent clicks from going through
+ * to background windows.
+ */
+ SDL_SetMouseFocus(focusWindow);
+ SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
+ }
+
+ /* Set the relative mode */
+ if (!enabled && mouse->relative_mode_warp) {
+ mouse->relative_mode_warp = SDL_FALSE;
+ } else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
+ mouse->relative_mode_warp = SDL_TRUE;
+ } else if (mouse->SetRelativeMouseMode(enabled) < 0) {
+ if (enabled) {
+ /* Fall back to warp mode if native relative mode failed */
+ mouse->relative_mode_warp = SDL_TRUE;
+ }
+ }
+ mouse->relative_mode = enabled;
+
+ if (mouse->focus) {
+ SDL_UpdateWindowGrab(mouse->focus);
+
+ /* Put the cursor back to where the application expects it */
+ if (!enabled) {
+ SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
+ }
+ }
+
+ /* Flush pending mouse motion - ideally we would pump events, but that's not always safe */
+ SDL_FlushEvent(SDL_MOUSEMOTION);
+
+ /* Update cursor visibility */
+ SDL_SetCursor(NULL);
+
+ return 0;
+}
+
+SDL_bool
+SDL_GetRelativeMouseMode()
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ return mouse->relative_mode;
+}
+
+int
+SDL_CaptureMouse(SDL_bool enabled)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_Window *focusWindow;
+ SDL_bool isCaptured;
+
+ if (!mouse->CaptureMouse) {
+ return SDL_Unsupported();
+ }
+
+ focusWindow = SDL_GetKeyboardFocus();
+
+ isCaptured = focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE);
+ if (isCaptured == enabled) {
+ return 0; /* already done! */
+ }
+
+ if (enabled) {
+ if (!focusWindow) {
+ return SDL_SetError("No window has focus");
+ } else if (mouse->CaptureMouse(focusWindow) == -1) {
+ return -1; /* CaptureMouse() should call SetError */
+ }
+ focusWindow->flags |= SDL_WINDOW_MOUSE_CAPTURE;
+ } else {
+ if (mouse->CaptureMouse(NULL) == -1) {
+ return -1; /* CaptureMouse() should call SetError */
+ }
+ focusWindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
+ }
+
+ return 0;
+}
+
+SDL_Cursor *
+SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
+ int w, int h, int hot_x, int hot_y)
+{
+ SDL_Surface *surface;
+ SDL_Cursor *cursor;
+ int x, y;
+ Uint32 *pixel;
+ Uint8 datab = 0, maskb = 0;
+ const Uint32 black = 0xFF000000;
+ const Uint32 white = 0xFFFFFFFF;
+ const Uint32 transparent = 0x00000000;
+
+ /* Make sure the width is a multiple of 8 */
+ w = ((w + 7) & ~7);
+
+ /* Create the surface from a bitmap */
+ surface = SDL_CreateRGBSurface(0, w, h, 32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ if (!surface) {
+ return NULL;
+ }
+ for (y = 0; y < h; ++y) {
+ pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch);
+ for (x = 0; x < w; ++x) {
+ if ((x % 8) == 0) {
+ datab = *data++;
+ maskb = *mask++;
+ }
+ if (maskb & 0x80) {
+ *pixel++ = (datab & 0x80) ? black : white;
+ } else {
+ *pixel++ = (datab & 0x80) ? black : transparent;
+ }
+ datab <<= 1;
+ maskb <<= 1;
+ }
+ }
+
+ cursor = SDL_CreateColorCursor(surface, hot_x, hot_y);
+
+ SDL_FreeSurface(surface);
+
+ return cursor;
+}
+
+SDL_Cursor *
+SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_Surface *temp = NULL;
+ SDL_Cursor *cursor;
+
+ if (!surface) {
+ SDL_SetError("Passed NULL cursor surface");
+ return NULL;
+ }
+
+ if (!mouse->CreateCursor) {
+ SDL_SetError("Cursors are not currently supported");
+ return NULL;
+ }
+
+ /* Sanity check the hot spot */
+ if ((hot_x < 0) || (hot_y < 0) ||
+ (hot_x >= surface->w) || (hot_y >= surface->h)) {
+ SDL_SetError("Cursor hot spot doesn't lie within cursor");
+ return NULL;
+ }
+
+ if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
+ temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
+ if (!temp) {
+ return NULL;
+ }
+ surface = temp;
+ }
+
+ cursor = mouse->CreateCursor(surface, hot_x, hot_y);
+ if (cursor) {
+ cursor->next = mouse->cursors;
+ mouse->cursors = cursor;
+ }
+
+ SDL_FreeSurface(temp);
+
+ return cursor;
+}
+
+SDL_Cursor *
+SDL_CreateSystemCursor(SDL_SystemCursor id)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_Cursor *cursor;
+
+ if (!mouse->CreateSystemCursor) {
+ SDL_SetError("CreateSystemCursor is not currently supported");
+ return NULL;
+ }
+
+ cursor = mouse->CreateSystemCursor(id);
+ if (cursor) {
+ cursor->next = mouse->cursors;
+ mouse->cursors = cursor;
+ }
+
+ return cursor;
+}
+
+/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
+ if this is desired for any reason. This is used when setting
+ the video mode and when the SDL window gains the mouse focus.
+ */
+void
+SDL_SetCursor(SDL_Cursor * cursor)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ /* Set the new cursor */
+ if (cursor) {
+ /* Make sure the cursor is still valid for this mouse */
+ if (cursor != mouse->def_cursor) {
+ SDL_Cursor *found;
+ for (found = mouse->cursors; found; found = found->next) {
+ if (found == cursor) {
+ break;
+ }
+ }
+ if (!found) {
+ SDL_SetError("Cursor not associated with the current mouse");
+ return;
+ }
+ }
+ mouse->cur_cursor = cursor;
+ } else {
+ if (mouse->focus) {
+ cursor = mouse->cur_cursor;
+ } else {
+ cursor = mouse->def_cursor;
+ }
+ }
+
+ if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
+ if (mouse->ShowCursor) {
+ mouse->ShowCursor(cursor);
+ }
+ } else {
+ if (mouse->ShowCursor) {
+ mouse->ShowCursor(NULL);
+ }
+ }
+}
+
+SDL_Cursor *
+SDL_GetCursor(void)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (!mouse) {
+ return NULL;
+ }
+ return mouse->cur_cursor;
+}
+
+SDL_Cursor *
+SDL_GetDefaultCursor(void)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ if (!mouse) {
+ return NULL;
+ }
+ return mouse->def_cursor;
+}
+
+void
+SDL_FreeCursor(SDL_Cursor * cursor)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_Cursor *curr, *prev;
+
+ if (!cursor) {
+ return;
+ }
+
+ if (cursor == mouse->def_cursor) {
+ return;
+ }
+ if (cursor == mouse->cur_cursor) {
+ SDL_SetCursor(mouse->def_cursor);
+ }
+
+ for (prev = NULL, curr = mouse->cursors; curr;
+ prev = curr, curr = curr->next) {
+ if (curr == cursor) {
+ if (prev) {
+ prev->next = curr->next;
+ } else {
+ mouse->cursors = curr->next;
+ }
+
+ if (mouse->FreeCursor) {
+ mouse->FreeCursor(curr);
+ }
+ return;
+ }
+ }
+}
+
+int
+SDL_ShowCursor(int toggle)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+ SDL_bool shown;
+
+ if (!mouse) {
+ return 0;
+ }
+
+ shown = mouse->cursor_shown;
+ if (toggle >= 0) {
+ if (toggle) {
+ mouse->cursor_shown = SDL_TRUE;
+ } else {
+ mouse->cursor_shown = SDL_FALSE;
+ }
+ if (mouse->cursor_shown != shown) {
+ SDL_SetCursor(NULL);
+ }
+ }
+ return shown;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_mouse_c.h b/3rdparty/SDL2/src/events/SDL_mouse_c.h
new file mode 100644
index 00000000000..03aca0a5c78
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_mouse_c.h
@@ -0,0 +1,130 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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
+
+#include "SDL_mouse.h"
+
+typedef Uint32 SDL_MouseID;
+
+struct SDL_Cursor
+{
+ struct SDL_Cursor *next;
+ void *driverdata;
+};
+
+typedef struct
+{
+ int last_x, last_y;
+ Uint32 last_timestamp;
+ Uint8 click_count;
+} SDL_MouseClickState;
+
+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 */
+ int (*ShowCursor) (SDL_Cursor * cursor);
+
+ /* This is called when a mouse motion event occurs */
+ void (*MoveCursor) (SDL_Cursor * cursor);
+
+ /* Free a window manager cursor */
+ void (*FreeCursor) (SDL_Cursor * cursor);
+
+ /* Warp the mouse to (x,y) within a window */
+ void (*WarpMouse) (SDL_Window * window, int x, int y);
+
+ /* Warp the mouse to (x,y) in screen space */
+ int (*WarpMouseGlobal) (int x, int y);
+
+ /* Set relative mode */
+ int (*SetRelativeMouseMode) (SDL_bool enabled);
+
+ /* Set mouse capture */
+ int (*CaptureMouse) (SDL_Window * window);
+
+ /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */
+ Uint32 (*GetGlobalMouseState) (int *x, int *y);
+
+ /* Data common to all mice */
+ SDL_MouseID mouseID;
+ SDL_Window *focus;
+ int x;
+ int y;
+ int xdelta;
+ int ydelta;
+ int last_x, last_y; /* the last reported x and y coordinates */
+ Uint32 buttonstate;
+ SDL_bool relative_mode;
+ SDL_bool relative_mode_warp;
+
+ /* Data for double-click tracking */
+ int num_clickstates;
+ SDL_MouseClickState *clickstate;
+
+ SDL_Cursor *cursors;
+ SDL_Cursor *def_cursor;
+ SDL_Cursor *cur_cursor;
+ SDL_bool cursor_shown;
+
+ /* Driver-dependent data. */
+ void *driverdata;
+} SDL_Mouse;
+
+
+/* Initialize the mouse subsystem */
+extern int SDL_MouseInit(void);
+
+/* Get the mouse state structure */
+SDL_Mouse *SDL_GetMouse(void);
+
+/* Set the default double-click interval */
+extern void SDL_SetDoubleClickTime(Uint32 interval);
+
+/* Set the default mouse cursor */
+extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
+
+/* Set the mouse focus window */
+extern void SDL_SetMouseFocus(SDL_Window * window);
+
+/* Send a mouse motion event */
+extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
+
+/* Send a mouse button event */
+extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button);
+
+/* Send a mouse wheel event */
+extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction);
+
+/* Shutdown the mouse subsystem */
+extern void SDL_MouseQuit(void);
+
+#endif /* _SDL_mouse_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_quit.c b/3rdparty/SDL2/src/events/SDL_quit.c
new file mode 100644
index 00000000000..5b7105ef8b4
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_quit.c
@@ -0,0 +1,154 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_hints.h"
+#include "SDL_assert.h"
+
+/* General quit handling code for SDL */
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+
+static SDL_bool disable_signals = SDL_FALSE;
+static SDL_bool send_quit_pending = SDL_FALSE;
+
+#ifdef HAVE_SIGNAL_H
+static void
+SDL_HandleSIG(int sig)
+{
+ /* Reset the signal handler */
+ signal(sig, SDL_HandleSIG);
+
+ /* Send a quit event next time the event loop pumps. */
+ /* We can't send it in signal handler; malloc() might be interrupted! */
+ send_quit_pending = SDL_TRUE;
+}
+#endif /* HAVE_SIGNAL_H */
+
+/* Public functions */
+static int
+SDL_QuitInit_Internal(void)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction action;
+ sigaction(SIGINT, NULL, &action);
+#ifdef HAVE_SA_SIGACTION
+ if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) {
+#else
+ if ( action.sa_handler == SIG_DFL ) {
+#endif
+ action.sa_handler = SDL_HandleSIG;
+ sigaction(SIGINT, &action, NULL);
+ }
+ sigaction(SIGTERM, NULL, &action);
+
+#ifdef HAVE_SA_SIGACTION
+ if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) {
+#else
+ if ( action.sa_handler == SIG_DFL ) {
+#endif
+ action.sa_handler = SDL_HandleSIG;
+ sigaction(SIGTERM, &action, NULL);
+ }
+#elif HAVE_SIGNAL_H
+ void (*ohandler) (int);
+
+ /* Both SIGINT and SIGTERM are translated into quit interrupts */
+ ohandler = signal(SIGINT, SDL_HandleSIG);
+ if (ohandler != SIG_DFL)
+ signal(SIGINT, ohandler);
+ ohandler = signal(SIGTERM, SDL_HandleSIG);
+ if (ohandler != SIG_DFL)
+ signal(SIGTERM, ohandler);
+#endif /* HAVE_SIGNAL_H */
+
+ /* That's it! */
+ return 0;
+}
+
+int
+SDL_QuitInit(void)
+{
+ const char *hint = SDL_GetHint(SDL_HINT_NO_SIGNAL_HANDLERS);
+ disable_signals = hint && (SDL_atoi(hint) == 1);
+ if (!disable_signals) {
+ return SDL_QuitInit_Internal();
+ }
+ return 0;
+}
+
+static void
+SDL_QuitQuit_Internal(void)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction action;
+ sigaction(SIGINT, NULL, &action);
+ if ( action.sa_handler == SDL_HandleSIG ) {
+ action.sa_handler = SIG_DFL;
+ sigaction(SIGINT, &action, NULL);
+ }
+ sigaction(SIGTERM, NULL, &action);
+ if ( action.sa_handler == SDL_HandleSIG ) {
+ action.sa_handler = SIG_DFL;
+ sigaction(SIGTERM, &action, NULL);
+ }
+#elif HAVE_SIGNAL_H
+ void (*ohandler) (int);
+
+ ohandler = signal(SIGINT, SIG_DFL);
+ if (ohandler != SDL_HandleSIG)
+ signal(SIGINT, ohandler);
+ ohandler = signal(SIGTERM, SIG_DFL);
+ if (ohandler != SDL_HandleSIG)
+ signal(SIGTERM, ohandler);
+#endif /* HAVE_SIGNAL_H */
+}
+
+void
+SDL_QuitQuit(void)
+{
+ if (!disable_signals) {
+ SDL_QuitQuit_Internal();
+ }
+}
+
+/* This function returns 1 if it's okay to close the application window */
+int
+SDL_SendQuit(void)
+{
+ send_quit_pending = SDL_FALSE;
+ return SDL_SendAppEvent(SDL_QUIT);
+}
+
+void
+SDL_SendPendingQuit(void)
+{
+ if (send_quit_pending) {
+ SDL_SendQuit();
+ SDL_assert(!send_quit_pending);
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_sysevents.h b/3rdparty/SDL2/src/events/SDL_sysevents.h
new file mode 100644
index 00000000000..c4ce087643e
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_sysevents.h
@@ -0,0 +1,36 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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 "../video/SDL_sysvideo.h"
+
+/* Useful functions and variables from SDL_sysevents.c */
+
+#if defined(__HAIKU__)
+/* The Haiku event loops run in a separate thread */
+#define MUST_THREAD_EVENTS
+#endif
+
+#ifdef __WIN32__ /* Windows doesn't allow a separate event thread */
+#define CANT_THREAD_EVENTS
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_touch.c b/3rdparty/SDL2/src/events/SDL_touch.c
new file mode 100644
index 00000000000..c73827c9649
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_touch.c
@@ -0,0 +1,365 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* General touch handling code for SDL */
+
+#include "SDL_assert.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+
+
+static int SDL_num_touch = 0;
+static SDL_Touch **SDL_touchDevices = NULL;
+
+
+/* Public functions */
+int
+SDL_TouchInit(void)
+{
+ return (0);
+}
+
+int
+SDL_GetNumTouchDevices(void)
+{
+ return SDL_num_touch;
+}
+
+SDL_TouchID
+SDL_GetTouchDevice(int index)
+{
+ if (index < 0 || index >= SDL_num_touch) {
+ SDL_SetError("Unknown touch device");
+ return 0;
+ }
+ return SDL_touchDevices[index]->id;
+}
+
+static int
+SDL_GetTouchIndex(SDL_TouchID id)
+{
+ int index;
+ SDL_Touch *touch;
+
+ for (index = 0; index < SDL_num_touch; ++index) {
+ touch = SDL_touchDevices[index];
+ if (touch->id == id) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+SDL_Touch *
+SDL_GetTouch(SDL_TouchID id)
+{
+ int index = SDL_GetTouchIndex(id);
+ if (index < 0 || index >= SDL_num_touch) {
+ SDL_SetError("Unknown touch device");
+ return NULL;
+ }
+ return SDL_touchDevices[index];
+}
+
+static int
+SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid)
+{
+ int index;
+ for (index = 0; index < touch->num_fingers; ++index) {
+ if (touch->fingers[index]->id == fingerid) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+SDL_Finger *
+SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id)
+{
+ int index = SDL_GetFingerIndex(touch, id);
+ if (index < 0 || index >= touch->num_fingers) {
+ return NULL;
+ }
+ return touch->fingers[index];
+}
+
+int
+SDL_GetNumTouchFingers(SDL_TouchID touchID)
+{
+ SDL_Touch *touch = SDL_GetTouch(touchID);
+ if (touch) {
+ return touch->num_fingers;
+ }
+ return 0;
+}
+
+SDL_Finger *
+SDL_GetTouchFinger(SDL_TouchID touchID, int index)
+{
+ SDL_Touch *touch = SDL_GetTouch(touchID);
+ if (!touch) {
+ return NULL;
+ }
+ if (index < 0 || index >= touch->num_fingers) {
+ SDL_SetError("Unknown touch finger");
+ return NULL;
+ }
+ return touch->fingers[index];
+}
+
+int
+SDL_AddTouch(SDL_TouchID touchID, const char *name)
+{
+ SDL_Touch **touchDevices;
+ int index;
+
+ index = SDL_GetTouchIndex(touchID);
+ if (index >= 0) {
+ return index;
+ }
+
+ /* Add the touch to the list of touch */
+ touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices,
+ (SDL_num_touch + 1) * sizeof(*touchDevices));
+ if (!touchDevices) {
+ return SDL_OutOfMemory();
+ }
+
+ SDL_touchDevices = touchDevices;
+ index = SDL_num_touch;
+
+ SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index]));
+ if (!SDL_touchDevices[index]) {
+ return SDL_OutOfMemory();
+ }
+
+ /* Added touch to list */
+ ++SDL_num_touch;
+
+ /* we're setting the touch properties */
+ SDL_touchDevices[index]->id = touchID;
+ SDL_touchDevices[index]->num_fingers = 0;
+ SDL_touchDevices[index]->max_fingers = 0;
+ SDL_touchDevices[index]->fingers = NULL;
+
+ /* Record this touch device for gestures */
+ /* We could do this on the fly in the gesture code if we wanted */
+ SDL_GestureAddTouch(touchID);
+
+ return index;
+}
+
+static int
+SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
+{
+ SDL_Finger *finger;
+
+ 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) {
+ return SDL_OutOfMemory();
+ }
+ touch->fingers = new_fingers;
+ touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
+ if (!touch->fingers[touch->max_fingers]) {
+ return SDL_OutOfMemory();
+ }
+ touch->max_fingers++;
+ }
+
+ finger = touch->fingers[touch->num_fingers++];
+ finger->id = fingerid;
+ finger->x = x;
+ finger->y = y;
+ finger->pressure = pressure;
+ return 0;
+}
+
+static int
+SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid)
+{
+ SDL_Finger *temp;
+
+ int index = SDL_GetFingerIndex(touch, fingerid);
+ if (index < 0) {
+ return -1;
+ }
+
+ touch->num_fingers--;
+ temp = touch->fingers[index];
+ touch->fingers[index] = touch->fingers[touch->num_fingers];
+ touch->fingers[touch->num_fingers] = temp;
+ return 0;
+}
+
+int
+SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
+ SDL_bool down, float x, float y, float pressure)
+{
+ int posted;
+ SDL_Finger *finger;
+
+ SDL_Touch* touch = SDL_GetTouch(id);
+ if (!touch) {
+ return -1;
+ }
+
+ finger = SDL_GetFinger(touch, fingerid);
+ if (down) {
+ if (finger) {
+ /* This finger is already down */
+ return 0;
+ }
+
+ if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) {
+ return 0;
+ }
+
+ posted = 0;
+ if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
+ SDL_Event event;
+ event.tfinger.type = SDL_FINGERDOWN;
+ event.tfinger.touchId = id;
+ event.tfinger.fingerId = fingerid;
+ event.tfinger.x = x;
+ event.tfinger.y = y;
+ event.tfinger.dx = 0;
+ event.tfinger.dy = 0;
+ event.tfinger.pressure = pressure;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ } else {
+ if (!finger) {
+ /* This finger is already up */
+ return 0;
+ }
+
+ posted = 0;
+ if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
+ SDL_Event event;
+ event.tfinger.type = SDL_FINGERUP;
+ event.tfinger.touchId = id;
+ event.tfinger.fingerId = fingerid;
+ /* I don't trust the coordinates passed on fingerUp */
+ event.tfinger.x = finger->x;
+ event.tfinger.y = finger->y;
+ event.tfinger.dx = 0;
+ event.tfinger.dy = 0;
+ event.tfinger.pressure = pressure;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+
+ SDL_DelFinger(touch, fingerid);
+ }
+ return posted;
+}
+
+int
+SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
+ float x, float y, float pressure)
+{
+ SDL_Touch *touch;
+ SDL_Finger *finger;
+ int posted;
+ float xrel, yrel, prel;
+
+ touch = SDL_GetTouch(id);
+ if (!touch) {
+ return -1;
+ }
+
+ finger = SDL_GetFinger(touch,fingerid);
+ if (!finger) {
+ return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);
+ }
+
+ xrel = x - finger->x;
+ yrel = y - finger->y;
+ prel = pressure - finger->pressure;
+
+ /* Drop events that don't change state */
+ if (!xrel && !yrel && !prel) {
+#if 0
+ printf("Touch event didn't change state - dropped!\n");
+#endif
+ return 0;
+ }
+
+ /* Update internal touch coordinates */
+ finger->x = x;
+ finger->y = y;
+ finger->pressure = pressure;
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
+ SDL_Event event;
+ event.tfinger.type = SDL_FINGERMOTION;
+ event.tfinger.touchId = id;
+ event.tfinger.fingerId = fingerid;
+ event.tfinger.x = x;
+ event.tfinger.y = y;
+ event.tfinger.dx = xrel;
+ event.tfinger.dy = yrel;
+ event.tfinger.pressure = pressure;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return posted;
+}
+
+void
+SDL_DelTouch(SDL_TouchID id)
+{
+ int i;
+ int index = SDL_GetTouchIndex(id);
+ SDL_Touch *touch = SDL_GetTouch(id);
+
+ if (!touch) {
+ return;
+ }
+
+ for (i = 0; i < touch->max_fingers; ++i) {
+ SDL_free(touch->fingers[i]);
+ }
+ SDL_free(touch->fingers);
+ SDL_free(touch);
+
+ SDL_num_touch--;
+ SDL_touchDevices[index] = SDL_touchDevices[SDL_num_touch];
+}
+
+void
+SDL_TouchQuit(void)
+{
+ int i;
+
+ for (i = SDL_num_touch; i--; ) {
+ SDL_DelTouch(SDL_touchDevices[i]->id);
+ }
+ SDL_assert(SDL_num_touch == 0);
+
+ SDL_free(SDL_touchDevices);
+ SDL_touchDevices = NULL;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_touch_c.h b/3rdparty/SDL2/src/events/SDL_touch_c.h
new file mode 100644
index 00000000000..d025df6e847
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_touch_c.h
@@ -0,0 +1,61 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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 "../../include/SDL_touch.h"
+
+#ifndef _SDL_touch_c_h
+#define _SDL_touch_c_h
+
+typedef struct SDL_Touch
+{
+ SDL_TouchID id;
+ int num_fingers;
+ int max_fingers;
+ SDL_Finger** fingers;
+} SDL_Touch;
+
+
+/* Initialize the touch subsystem */
+extern int SDL_TouchInit(void);
+
+/* Add a touch, returning the index of the touch, or -1 if there was an error. */
+extern int SDL_AddTouch(SDL_TouchID id, const char *name);
+
+/* Get the touch with a given id */
+extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
+
+/* Send a touch down/up event for a touch */
+extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
+ SDL_bool down, float x, float y, float pressure);
+
+/* Send a touch motion event for a touch */
+extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
+ float x, float y, float pressure);
+
+/* Remove a touch */
+extern void SDL_DelTouch(SDL_TouchID id);
+
+/* Shutdown the touch subsystem */
+extern void SDL_TouchQuit(void);
+
+#endif /* _SDL_touch_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_windowevents.c b/3rdparty/SDL2/src/events/SDL_windowevents.c
new file mode 100644
index 00000000000..785ea4e0cb9
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_windowevents.c
@@ -0,0 +1,212 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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"
+
+/* Window event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_mouse_c.h"
+#include "../video/SDL_sysvideo.h"
+
+
+static int
+RemovePendingResizedEvents(void * userdata, SDL_Event *event)
+{
+ SDL_Event *new_event = (SDL_Event *)userdata;
+
+ if (event->type == SDL_WINDOWEVENT &&
+ event->window.event == SDL_WINDOWEVENT_RESIZED &&
+ event->window.windowID == new_event->window.windowID) {
+ /* We're about to post a new size event, drop the old one */
+ return 0;
+ }
+ return 1;
+}
+
+static int
+RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event)
+{
+ SDL_Event *new_event = (SDL_Event *)userdata;
+
+ if (event->type == SDL_WINDOWEVENT &&
+ event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
+ event->window.windowID == new_event->window.windowID) {
+ /* We're about to post a new size event, drop the old one */
+ return 0;
+ }
+ return 1;
+}
+
+static int
+RemovePendingMoveEvents(void * userdata, SDL_Event *event)
+{
+ SDL_Event *new_event = (SDL_Event *)userdata;
+
+ if (event->type == SDL_WINDOWEVENT &&
+ event->window.event == SDL_WINDOWEVENT_MOVED &&
+ event->window.windowID == new_event->window.windowID) {
+ /* We're about to post a new move event, drop the old one */
+ return 0;
+ }
+ return 1;
+}
+
+int
+SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
+ int data2)
+{
+ int posted;
+
+ if (!window) {
+ return 0;
+ }
+ switch (windowevent) {
+ case SDL_WINDOWEVENT_SHOWN:
+ if (window->flags & SDL_WINDOW_SHOWN) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_HIDDEN;
+ window->flags |= SDL_WINDOW_SHOWN;
+ SDL_OnWindowShown(window);
+ break;
+ case SDL_WINDOWEVENT_HIDDEN:
+ if (!(window->flags & SDL_WINDOW_SHOWN)) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_SHOWN;
+ window->flags |= SDL_WINDOW_HIDDEN;
+ SDL_OnWindowHidden(window);
+ break;
+ case SDL_WINDOWEVENT_MOVED:
+ if (SDL_WINDOWPOS_ISUNDEFINED(data1) ||
+ SDL_WINDOWPOS_ISUNDEFINED(data2)) {
+ return 0;
+ }
+ if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+ window->windowed.x = data1;
+ window->windowed.y = data2;
+ }
+ if (data1 == window->x && data2 == window->y) {
+ return 0;
+ }
+ window->x = data1;
+ window->y = data2;
+ break;
+ case SDL_WINDOWEVENT_RESIZED:
+ if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+ window->windowed.w = data1;
+ window->windowed.h = data2;
+ }
+ if (data1 == window->w && data2 == window->h) {
+ return 0;
+ }
+ window->w = data1;
+ window->h = data2;
+ SDL_OnWindowResized(window);
+ break;
+ case SDL_WINDOWEVENT_MINIMIZED:
+ if (window->flags & SDL_WINDOW_MINIMIZED) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_MAXIMIZED;
+ window->flags |= SDL_WINDOW_MINIMIZED;
+ SDL_OnWindowMinimized(window);
+ break;
+ case SDL_WINDOWEVENT_MAXIMIZED:
+ if (window->flags & SDL_WINDOW_MAXIMIZED) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_MINIMIZED;
+ window->flags |= SDL_WINDOW_MAXIMIZED;
+ break;
+ case SDL_WINDOWEVENT_RESTORED:
+ if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
+ return 0;
+ }
+ window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED);
+ SDL_OnWindowRestored(window);
+ break;
+ case SDL_WINDOWEVENT_ENTER:
+ if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
+ return 0;
+ }
+ window->flags |= SDL_WINDOW_MOUSE_FOCUS;
+ SDL_OnWindowEnter(window);
+ break;
+ case SDL_WINDOWEVENT_LEAVE:
+ if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
+ SDL_OnWindowLeave(window);
+ break;
+ case SDL_WINDOWEVENT_FOCUS_GAINED:
+ if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
+ return 0;
+ }
+ window->flags |= SDL_WINDOW_INPUT_FOCUS;
+ SDL_OnWindowFocusGained(window);
+ break;
+ case SDL_WINDOWEVENT_FOCUS_LOST:
+ if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
+ SDL_OnWindowFocusLost(window);
+ break;
+ }
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_WINDOWEVENT;
+ event.window.event = windowevent;
+ event.window.data1 = data1;
+ event.window.data2 = data2;
+ event.window.windowID = window->id;
+
+ /* Fixes queue overflow with resize events that aren't processed */
+ if (windowevent == SDL_WINDOWEVENT_RESIZED) {
+ SDL_FilterEvents(RemovePendingResizedEvents, &event);
+ }
+ if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
+ SDL_FilterEvents(RemovePendingSizeChangedEvents, &event);
+ }
+ if (windowevent == SDL_WINDOWEVENT_MOVED) {
+ SDL_FilterEvents(RemovePendingMoveEvents, &event);
+ }
+
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+
+ if (windowevent == SDL_WINDOWEVENT_CLOSE) {
+ if ( !window->prev && !window->next ) {
+ /* This is the last window in the list so send the SDL_QUIT event */
+ SDL_SendQuit();
+ }
+ }
+
+ return (posted);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/SDL_windowevents_c.h b/3rdparty/SDL2/src/events/SDL_windowevents_c.h
new file mode 100644
index 00000000000..2a6a4c05180
--- /dev/null
+++ b/3rdparty/SDL2/src/events/SDL_windowevents_c.h
@@ -0,0 +1,31 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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_windowevents_c_h
+#define _SDL_windowevents_c_h
+
+extern int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent,
+ int data1, int data2);
+
+#endif /* _SDL_windowevents_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/blank_cursor.h b/3rdparty/SDL2/src/events/blank_cursor.h
new file mode 100644
index 00000000000..5e15852cbfa
--- /dev/null
+++ b/3rdparty/SDL2/src/events/blank_cursor.h
@@ -0,0 +1,33 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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.
+*/
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * A default blank 8x8 cursor */
+
+#define BLANK_CWIDTH 8
+#define BLANK_CHEIGHT 8
+#define BLANK_CHOTX 0
+#define BLANK_CHOTY 0
+
+static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/default_cursor.h b/3rdparty/SDL2/src/events/default_cursor.h
new file mode 100644
index 00000000000..297dd2dc11c
--- /dev/null
+++ b/3rdparty/SDL2/src/events/default_cursor.h
@@ -0,0 +1,114 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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.
+*/
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Default cursor - it happens to be the Mac cursor, but could be anything */
+
+#define DEFAULT_CWIDTH 16
+#define DEFAULT_CHEIGHT 16
+#define DEFAULT_CHOTX 0
+#define DEFAULT_CHOTY 0
+
+/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */
+#define USE_MACOS_CURSOR
+
+#ifdef USE_MACOS_CURSOR
+
+static const unsigned char default_cdata[] = {
+ 0x00, 0x00,
+ 0x40, 0x00,
+ 0x60, 0x00,
+ 0x70, 0x00,
+ 0x78, 0x00,
+ 0x7C, 0x00,
+ 0x7E, 0x00,
+ 0x7F, 0x00,
+ 0x7F, 0x80,
+ 0x7C, 0x00,
+ 0x6C, 0x00,
+ 0x46, 0x00,
+ 0x06, 0x00,
+ 0x03, 0x00,
+ 0x03, 0x00,
+ 0x00, 0x00
+};
+
+static const unsigned char default_cmask[] = {
+ 0xC0, 0x00,
+ 0xE0, 0x00,
+ 0xF0, 0x00,
+ 0xF8, 0x00,
+ 0xFC, 0x00,
+ 0xFE, 0x00,
+ 0xFF, 0x00,
+ 0xFF, 0x80,
+ 0xFF, 0xC0,
+ 0xFF, 0xE0,
+ 0xFE, 0x00,
+ 0xEF, 0x00,
+ 0xCF, 0x00,
+ 0x87, 0x80,
+ 0x07, 0x80,
+ 0x03, 0x00
+};
+
+#else
+
+static const unsigned char default_cdata[] = {
+ 0x00, 0x00,
+ 0x40, 0x00,
+ 0x60, 0x00,
+ 0x70, 0x00,
+ 0x78, 0x00,
+ 0x7C, 0x00,
+ 0x7E, 0x00,
+ 0x7F, 0x00,
+ 0x7F, 0x80,
+ 0x7C, 0x00,
+ 0x6C, 0x00,
+ 0x46, 0x00,
+ 0x06, 0x00,
+ 0x03, 0x00,
+ 0x03, 0x00,
+ 0x00, 0x00
+};
+
+static const unsigned char default_cmask[] = {
+ 0x40, 0x00,
+ 0xE0, 0x00,
+ 0xF0, 0x00,
+ 0xF8, 0x00,
+ 0xFC, 0x00,
+ 0xFE, 0x00,
+ 0xFF, 0x00,
+ 0xFF, 0x80,
+ 0xFF, 0xC0,
+ 0xFF, 0x80,
+ 0xFE, 0x00,
+ 0xEF, 0x00,
+ 0x4F, 0x00,
+ 0x07, 0x80,
+ 0x07, 0x80,
+ 0x03, 0x00
+};
+
+#endif /* USE_MACOS_CURSOR */
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/events/scancodes_darwin.h b/3rdparty/SDL2/src/events/scancodes_darwin.h
new file mode 100644
index 00000000000..26922530958
--- /dev/null
+++ b/3rdparty/SDL2/src/events/scancodes_darwin.h
@@ -0,0 +1,159 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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.
+*/
+
+/* Mac virtual key code to SDL scancode mapping table
+ Sources:
+ - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
+ - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
+ - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
+*/
+/* *INDENT-OFF* */
+static const SDL_Scancode darwin_scancode_table[] = {
+ /* 0 */ SDL_SCANCODE_A,
+ /* 1 */ SDL_SCANCODE_S,
+ /* 2 */ SDL_SCANCODE_D,
+ /* 3 */ SDL_SCANCODE_F,
+ /* 4 */ SDL_SCANCODE_H,
+ /* 5 */ SDL_SCANCODE_G,
+ /* 6 */ SDL_SCANCODE_Z,
+ /* 7 */ SDL_SCANCODE_X,
+ /* 8 */ SDL_SCANCODE_C,
+ /* 9 */ SDL_SCANCODE_V,
+ /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
+ /* 11 */ SDL_SCANCODE_B,
+ /* 12 */ SDL_SCANCODE_Q,
+ /* 13 */ SDL_SCANCODE_W,
+ /* 14 */ SDL_SCANCODE_E,
+ /* 15 */ SDL_SCANCODE_R,
+ /* 16 */ SDL_SCANCODE_Y,
+ /* 17 */ SDL_SCANCODE_T,
+ /* 18 */ SDL_SCANCODE_1,
+ /* 19 */ SDL_SCANCODE_2,
+ /* 20 */ SDL_SCANCODE_3,
+ /* 21 */ SDL_SCANCODE_4,
+ /* 22 */ SDL_SCANCODE_6,
+ /* 23 */ SDL_SCANCODE_5,
+ /* 24 */ SDL_SCANCODE_EQUALS,
+ /* 25 */ SDL_SCANCODE_9,
+ /* 26 */ SDL_SCANCODE_7,
+ /* 27 */ SDL_SCANCODE_MINUS,
+ /* 28 */ SDL_SCANCODE_8,
+ /* 29 */ SDL_SCANCODE_0,
+ /* 30 */ SDL_SCANCODE_RIGHTBRACKET,
+ /* 31 */ SDL_SCANCODE_O,
+ /* 32 */ SDL_SCANCODE_U,
+ /* 33 */ SDL_SCANCODE_LEFTBRACKET,
+ /* 34 */ SDL_SCANCODE_I,
+ /* 35 */ SDL_SCANCODE_P,
+ /* 36 */ SDL_SCANCODE_RETURN,
+ /* 37 */ SDL_SCANCODE_L,
+ /* 38 */ SDL_SCANCODE_J,
+ /* 39 */ SDL_SCANCODE_APOSTROPHE,
+ /* 40 */ SDL_SCANCODE_K,
+ /* 41 */ SDL_SCANCODE_SEMICOLON,
+ /* 42 */ SDL_SCANCODE_BACKSLASH,
+ /* 43 */ SDL_SCANCODE_COMMA,
+ /* 44 */ SDL_SCANCODE_SLASH,
+ /* 45 */ SDL_SCANCODE_N,
+ /* 46 */ SDL_SCANCODE_M,
+ /* 47 */ SDL_SCANCODE_PERIOD,
+ /* 48 */ SDL_SCANCODE_TAB,
+ /* 49 */ SDL_SCANCODE_SPACE,
+ /* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
+ /* 51 */ SDL_SCANCODE_BACKSPACE,
+ /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
+ /* 53 */ SDL_SCANCODE_ESCAPE,
+ /* 54 */ SDL_SCANCODE_RGUI,
+ /* 55 */ SDL_SCANCODE_LGUI,
+ /* 56 */ SDL_SCANCODE_LSHIFT,
+ /* 57 */ SDL_SCANCODE_CAPSLOCK,
+ /* 58 */ SDL_SCANCODE_LALT,
+ /* 59 */ SDL_SCANCODE_LCTRL,
+ /* 60 */ SDL_SCANCODE_RSHIFT,
+ /* 61 */ SDL_SCANCODE_RALT,
+ /* 62 */ SDL_SCANCODE_RCTRL,
+ /* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
+ /* 64 */ SDL_SCANCODE_F17,
+ /* 65 */ SDL_SCANCODE_KP_PERIOD,
+ /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 67 */ SDL_SCANCODE_KP_MULTIPLY,
+ /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 69 */ SDL_SCANCODE_KP_PLUS,
+ /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR,
+ /* 72 */ SDL_SCANCODE_VOLUMEUP,
+ /* 73 */ SDL_SCANCODE_VOLUMEDOWN,
+ /* 74 */ SDL_SCANCODE_MUTE,
+ /* 75 */ SDL_SCANCODE_KP_DIVIDE,
+ /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
+ /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 78 */ SDL_SCANCODE_KP_MINUS,
+ /* 79 */ SDL_SCANCODE_F18,
+ /* 80 */ SDL_SCANCODE_F19,
+ /* 81 */ SDL_SCANCODE_KP_EQUALS,
+ /* 82 */ SDL_SCANCODE_KP_0,
+ /* 83 */ SDL_SCANCODE_KP_1,
+ /* 84 */ SDL_SCANCODE_KP_2,
+ /* 85 */ SDL_SCANCODE_KP_3,
+ /* 86 */ SDL_SCANCODE_KP_4,
+ /* 87 */ SDL_SCANCODE_KP_5,
+ /* 88 */ SDL_SCANCODE_KP_6,
+ /* 89 */ SDL_SCANCODE_KP_7,
+ /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 91 */ SDL_SCANCODE_KP_8,
+ /* 92 */ SDL_SCANCODE_KP_9,
+ /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
+ /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
+ /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
+ /* 96 */ SDL_SCANCODE_F5,
+ /* 97 */ SDL_SCANCODE_F6,
+ /* 98 */ SDL_SCANCODE_F7,
+ /* 99 */ SDL_SCANCODE_F3,
+ /* 100 */ SDL_SCANCODE_F8,
+ /* 101 */ SDL_SCANCODE_F9,
+ /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
+ /* 103 */ SDL_SCANCODE_F11,
+ /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
+ /* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
+ /* 106 */ SDL_SCANCODE_F16,
+ /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
+ /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 109 */ SDL_SCANCODE_F10,
+ /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
+ /* 111 */ SDL_SCANCODE_F12,
+ /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
+ /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
+ /* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
+ /* 115 */ SDL_SCANCODE_HOME,
+ /* 116 */ SDL_SCANCODE_PAGEUP,
+ /* 117 */ SDL_SCANCODE_DELETE,
+ /* 118 */ SDL_SCANCODE_F4,
+ /* 119 */ SDL_SCANCODE_END,
+ /* 120 */ SDL_SCANCODE_F2,
+ /* 121 */ SDL_SCANCODE_PAGEDOWN,
+ /* 122 */ SDL_SCANCODE_F1,
+ /* 123 */ SDL_SCANCODE_LEFT,
+ /* 124 */ SDL_SCANCODE_RIGHT,
+ /* 125 */ SDL_SCANCODE_DOWN,
+ /* 126 */ SDL_SCANCODE_UP,
+ /* 127 */ SDL_SCANCODE_POWER
+};
+/* *INDENT-ON* */
diff --git a/3rdparty/SDL2/src/events/scancodes_linux.h b/3rdparty/SDL2/src/events/scancodes_linux.h
new file mode 100644
index 00000000000..8db37df5b96
--- /dev/null
+++ b/3rdparty/SDL2/src/events/scancodes_linux.h
@@ -0,0 +1,263 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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 "../../include/SDL_scancode.h"
+
+/* Linux virtual key code to SDL_Keycode mapping table
+ Sources:
+ - Linux kernel source input.h
+*/
+/* *INDENT-OFF* */
+static SDL_Scancode const linux_scancode_table[] = {
+ /* 0 */ SDL_SCANCODE_UNKNOWN,
+ /* 1 */ SDL_SCANCODE_ESCAPE,
+ /* 2 */ SDL_SCANCODE_1,
+ /* 3 */ SDL_SCANCODE_2,
+ /* 4 */ SDL_SCANCODE_3,
+ /* 5 */ SDL_SCANCODE_4,
+ /* 6 */ SDL_SCANCODE_5,
+ /* 7 */ SDL_SCANCODE_6,
+ /* 8 */ SDL_SCANCODE_7,
+ /* 9 */ SDL_SCANCODE_8,
+ /* 10 */ SDL_SCANCODE_9,
+ /* 11 */ SDL_SCANCODE_0,
+ /* 12 */ SDL_SCANCODE_MINUS,
+ /* 13 */ SDL_SCANCODE_EQUALS,
+ /* 14 */ SDL_SCANCODE_BACKSPACE,
+ /* 15 */ SDL_SCANCODE_TAB,
+ /* 16 */ SDL_SCANCODE_Q,
+ /* 17 */ SDL_SCANCODE_W,
+ /* 18 */ SDL_SCANCODE_E,
+ /* 19 */ SDL_SCANCODE_R,
+ /* 20 */ SDL_SCANCODE_T,
+ /* 21 */ SDL_SCANCODE_Y,
+ /* 22 */ SDL_SCANCODE_U,
+ /* 23 */ SDL_SCANCODE_I,
+ /* 24 */ SDL_SCANCODE_O,
+ /* 25 */ SDL_SCANCODE_P,
+ /* 26 */ SDL_SCANCODE_LEFTBRACKET,
+ /* 27 */ SDL_SCANCODE_RIGHTBRACKET,
+ /* 28 */ SDL_SCANCODE_RETURN,
+ /* 29 */ SDL_SCANCODE_LCTRL,
+ /* 30 */ SDL_SCANCODE_A,
+ /* 31 */ SDL_SCANCODE_S,
+ /* 32 */ SDL_SCANCODE_D,
+ /* 33 */ SDL_SCANCODE_F,
+ /* 34 */ SDL_SCANCODE_G,
+ /* 35 */ SDL_SCANCODE_H,
+ /* 36 */ SDL_SCANCODE_J,
+ /* 37 */ SDL_SCANCODE_K,
+ /* 38 */ SDL_SCANCODE_L,
+ /* 39 */ SDL_SCANCODE_SEMICOLON,
+ /* 40 */ SDL_SCANCODE_APOSTROPHE,
+ /* 41 */ SDL_SCANCODE_GRAVE,
+ /* 42 */ SDL_SCANCODE_LSHIFT,
+ /* 43 */ SDL_SCANCODE_BACKSLASH,
+ /* 44 */ SDL_SCANCODE_Z,
+ /* 45 */ SDL_SCANCODE_X,
+ /* 46 */ SDL_SCANCODE_C,
+ /* 47 */ SDL_SCANCODE_V,
+ /* 48 */ SDL_SCANCODE_B,
+ /* 49 */ SDL_SCANCODE_N,
+ /* 50 */ SDL_SCANCODE_M,
+ /* 51 */ SDL_SCANCODE_COMMA,
+ /* 52 */ SDL_SCANCODE_PERIOD,
+ /* 53 */ SDL_SCANCODE_SLASH,
+ /* 54 */ SDL_SCANCODE_RSHIFT,
+ /* 55 */ SDL_SCANCODE_KP_MULTIPLY,
+ /* 56 */ SDL_SCANCODE_LALT,
+ /* 57 */ SDL_SCANCODE_SPACE,
+ /* 58 */ SDL_SCANCODE_CAPSLOCK,
+ /* 59 */ SDL_SCANCODE_F1,
+ /* 60 */ SDL_SCANCODE_F2,
+ /* 61 */ SDL_SCANCODE_F3,
+ /* 62 */ SDL_SCANCODE_F4,
+ /* 63 */ SDL_SCANCODE_F5,
+ /* 64 */ SDL_SCANCODE_F6,
+ /* 65 */ SDL_SCANCODE_F7,
+ /* 66 */ SDL_SCANCODE_F8,
+ /* 67 */ SDL_SCANCODE_F9,
+ /* 68 */ SDL_SCANCODE_F10,
+ /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
+ /* 70 */ SDL_SCANCODE_SCROLLLOCK,
+ /* 71 */ SDL_SCANCODE_KP_7,
+ /* 72 */ SDL_SCANCODE_KP_8,
+ /* 73 */ SDL_SCANCODE_KP_9,
+ /* 74 */ SDL_SCANCODE_KP_MINUS,
+ /* 75 */ SDL_SCANCODE_KP_4,
+ /* 76 */ SDL_SCANCODE_KP_5,
+ /* 77 */ SDL_SCANCODE_KP_6,
+ /* 78 */ SDL_SCANCODE_KP_PLUS,
+ /* 79 */ SDL_SCANCODE_KP_1,
+ /* 80 */ SDL_SCANCODE_KP_2,
+ /* 81 */ SDL_SCANCODE_KP_3,
+ /* 82 */ SDL_SCANCODE_KP_0,
+ /* 83 */ SDL_SCANCODE_KP_PERIOD,
+ 0,
+ /* 85 */ SDL_SCANCODE_UNKNOWN, /* KEY_ZENKAKUHANKAKU */
+ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* KEY_102ND */
+ /* 87 */ SDL_SCANCODE_F11,
+ /* 88 */ SDL_SCANCODE_F12,
+ /* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* KEY_RO */
+ /* 90 */ SDL_SCANCODE_LANG3, /* KEY_KATAKANA */
+ /* 91 */ SDL_SCANCODE_LANG4, /* KEY_HIRAGANA */
+ /* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* KEY_HENKAN */
+ /* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* KEY_KATAKANAHIRAGANA */
+ /* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_MUHENKAN */
+ /* 95 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_KPJPCOMMA */
+ /* 96 */ SDL_SCANCODE_KP_ENTER,
+ /* 97 */ SDL_SCANCODE_RCTRL,
+ /* 98 */ SDL_SCANCODE_KP_DIVIDE,
+ /* 99 */ SDL_SCANCODE_SYSREQ,
+ /* 100 */ SDL_SCANCODE_RALT,
+ /* 101 */ SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED */
+ /* 102 */ SDL_SCANCODE_HOME,
+ /* 103 */ SDL_SCANCODE_UP,
+ /* 104 */ SDL_SCANCODE_PAGEUP,
+ /* 105 */ SDL_SCANCODE_LEFT,
+ /* 106 */ SDL_SCANCODE_RIGHT,
+ /* 107 */ SDL_SCANCODE_END,
+ /* 108 */ SDL_SCANCODE_DOWN,
+ /* 109 */ SDL_SCANCODE_PAGEDOWN,
+ /* 110 */ SDL_SCANCODE_INSERT,
+ /* 111 */ SDL_SCANCODE_DELETE,
+ /* 112 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO */
+ /* 113 */ SDL_SCANCODE_MUTE,
+ /* 114 */ SDL_SCANCODE_VOLUMEDOWN,
+ /* 115 */ SDL_SCANCODE_VOLUMEUP,
+ /* 116 */ SDL_SCANCODE_POWER,
+ /* 117 */ SDL_SCANCODE_KP_EQUALS,
+ /* 118 */ SDL_SCANCODE_KP_PLUSMINUS,
+ /* 119 */ SDL_SCANCODE_PAUSE,
+ 0,
+ /* 121 */ SDL_SCANCODE_KP_COMMA,
+ /* 122 */ SDL_SCANCODE_LANG1, /* KEY_HANGUEL */
+ /* 123 */ SDL_SCANCODE_LANG2, /* KEY_HANJA */
+ /* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* KEY_YEN */
+ /* 125 */ SDL_SCANCODE_LGUI,
+ /* 126 */ SDL_SCANCODE_RGUI,
+ /* 127 */ SDL_SCANCODE_UNKNOWN, /* KEY_COMPOSE */
+ /* 128 */ SDL_SCANCODE_STOP,
+ /* 129 */ SDL_SCANCODE_AGAIN,
+ /* 130 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROPS */
+ /* 131 */ SDL_SCANCODE_UNDO,
+ /* 132 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRONT */
+ /* 133 */ SDL_SCANCODE_COPY,
+ /* 134 */ SDL_SCANCODE_UNKNOWN, /* KEY_OPEN */
+ /* 135 */ SDL_SCANCODE_PASTE,
+ /* 136 */ SDL_SCANCODE_FIND,
+ /* 137 */ SDL_SCANCODE_CUT,
+ /* 138 */ SDL_SCANCODE_HELP,
+ /* 139 */ SDL_SCANCODE_MENU,
+ /* 140 */ SDL_SCANCODE_CALCULATOR,
+ /* 141 */ SDL_SCANCODE_UNKNOWN, /* KEY_SETUP */
+ /* 142 */ SDL_SCANCODE_SLEEP,
+ /* 143 */ SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP */
+ /* 144 */ SDL_SCANCODE_UNKNOWN, /* KEY_FILE */
+ /* 145 */ SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE */
+ /* 146 */ SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE */
+ /* 147 */ SDL_SCANCODE_UNKNOWN, /* KEY_XFER */
+ /* 148 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG1 */
+ /* 149 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG2 */
+ /* 150 */ SDL_SCANCODE_UNKNOWN, /* KEY_WWW */
+ /* 151 */ SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS */
+ /* 152 */ SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE */
+ /* 153 */ SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION */
+ /* 154 */ SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS */
+ /* 155 */ SDL_SCANCODE_MAIL,
+ /* 156 */ SDL_SCANCODE_AC_BOOKMARKS,
+ /* 157 */ SDL_SCANCODE_COMPUTER,
+ /* 158 */ SDL_SCANCODE_AC_BACK,
+ /* 159 */ SDL_SCANCODE_AC_FORWARD,
+ /* 160 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD */
+ /* 161 */ SDL_SCANCODE_EJECT, /* KEY_EJECTCD */
+ /* 162 */ SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD */
+ /* 163 */ SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG */
+ /* 164 */ SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE */
+ /* 165 */ SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG */
+ /* 166 */ SDL_SCANCODE_UNKNOWN, /* KEY_STOPCD */
+ /* 167 */ SDL_SCANCODE_UNKNOWN, /* KEY_RECORD */
+ /* 168 */ SDL_SCANCODE_UNKNOWN, /* KEY_REWIND */
+ /* 169 */ SDL_SCANCODE_UNKNOWN, /* KEY_PHONE */
+ /* 170 */ SDL_SCANCODE_UNKNOWN, /* KEY_ISO */
+ /* 171 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG */
+ /* 172 */ SDL_SCANCODE_AC_HOME,
+ /* 173 */ SDL_SCANCODE_AC_REFRESH,
+ /* 174 */ SDL_SCANCODE_UNKNOWN, /* KEY_EXIT */
+ /* 175 */ SDL_SCANCODE_UNKNOWN, /* KEY_MOVE */
+ /* 176 */ SDL_SCANCODE_UNKNOWN, /* KEY_EDIT */
+ /* 177 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP */
+ /* 178 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN */
+ /* 179 */ SDL_SCANCODE_KP_LEFTPAREN,
+ /* 180 */ SDL_SCANCODE_KP_RIGHTPAREN,
+ /* 181 */ SDL_SCANCODE_UNKNOWN, /* KEY_NEW */
+ /* 182 */ SDL_SCANCODE_UNKNOWN, /* KEY_REDO */
+ /* 183 */ SDL_SCANCODE_F13,
+ /* 184 */ SDL_SCANCODE_F14,
+ /* 185 */ SDL_SCANCODE_F15,
+ /* 186 */ SDL_SCANCODE_F16,
+ /* 187 */ SDL_SCANCODE_F17,
+ /* 188 */ SDL_SCANCODE_F18,
+ /* 189 */ SDL_SCANCODE_F19,
+ /* 190 */ SDL_SCANCODE_F20,
+ /* 191 */ SDL_SCANCODE_F21,
+ /* 192 */ SDL_SCANCODE_F22,
+ /* 193 */ SDL_SCANCODE_F23,
+ /* 194 */ SDL_SCANCODE_F24,
+ 0, 0, 0, 0,
+ /* 200 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD */
+ /* 201 */ SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD */
+ /* 202 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 */
+ /* 203 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 */
+ 0,
+ /* 205 */ SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND */
+ /* 206 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE */
+ /* 207 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAY */
+ /* 208 */ SDL_SCANCODE_UNKNOWN, /* KEY_FASTFORWARD */
+ /* 209 */ SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST */
+ /* 210 */ SDL_SCANCODE_UNKNOWN, /* KEY_PRINT */
+ /* 211 */ SDL_SCANCODE_UNKNOWN, /* KEY_HP */
+ /* 212 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA */
+ /* 213 */ SDL_SCANCODE_UNKNOWN, /* KEY_SOUND */
+ /* 214 */ SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION */
+ /* 215 */ SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL */
+ /* 216 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHAT */
+ /* 217 */ SDL_SCANCODE_AC_SEARCH,
+ /* 218 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT */
+ /* 219 */ SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE */
+ /* 220 */ SDL_SCANCODE_UNKNOWN, /* KEY_SPORT */
+ /* 221 */ SDL_SCANCODE_UNKNOWN, /* KEY_SHOP */
+ /* 222 */ SDL_SCANCODE_ALTERASE,
+ /* 223 */ SDL_SCANCODE_CANCEL,
+ /* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
+ /* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
+ /* 226 */ SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA */
+ /* 227 */ SDL_SCANCODE_DISPLAYSWITCH, /* KEY_SWITCHVIDEOMODE */
+ /* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
+ /* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
+ /* 230 */ SDL_SCANCODE_KBDILLUMUP,
+ /* 231 */ SDL_SCANCODE_UNKNOWN, /* KEY_SEND */
+ /* 232 */ SDL_SCANCODE_UNKNOWN, /* KEY_REPLY */
+ /* 233 */ SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL */
+ /* 234 */ SDL_SCANCODE_UNKNOWN, /* KEY_SAVE */
+ /* 235 */ SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */
+ /* 236 */ SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */
+};
+/* *INDENT-ON* */
diff --git a/3rdparty/SDL2/src/events/scancodes_windows.h b/3rdparty/SDL2/src/events/scancodes_windows.h
new file mode 100644
index 00000000000..b23a261ea8a
--- /dev/null
+++ b/3rdparty/SDL2/src/events/scancodes_windows.h
@@ -0,0 +1,55 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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 "../../include/SDL_scancode.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 */
+
+/* *INDENT-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 */
+};
+/* *INDENT-ON* */
diff --git a/3rdparty/SDL2/src/events/scancodes_xfree86.h b/3rdparty/SDL2/src/events/scancodes_xfree86.h
new file mode 100644
index 00000000000..29d9ef9449b
--- /dev/null
+++ b/3rdparty/SDL2/src/events/scancodes_xfree86.h
@@ -0,0 +1,421 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 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 "../../include/SDL_scancode.h"
+
+/* XFree86 key code to SDL scancode mapping table
+ Sources:
+ - atKeyNames.h from XFree86 source code
+*/
+/* *INDENT-OFF* */
+static const SDL_Scancode xfree86_scancode_table[] = {
+ /* 0 */ SDL_SCANCODE_UNKNOWN,
+ /* 1 */ SDL_SCANCODE_ESCAPE,
+ /* 2 */ SDL_SCANCODE_1,
+ /* 3 */ SDL_SCANCODE_2,
+ /* 4 */ SDL_SCANCODE_3,
+ /* 5 */ SDL_SCANCODE_4,
+ /* 6 */ SDL_SCANCODE_5,
+ /* 7 */ SDL_SCANCODE_6,
+ /* 8 */ SDL_SCANCODE_7,
+ /* 9 */ SDL_SCANCODE_8,
+ /* 10 */ SDL_SCANCODE_9,
+ /* 11 */ SDL_SCANCODE_0,
+ /* 12 */ SDL_SCANCODE_MINUS,
+ /* 13 */ SDL_SCANCODE_EQUALS,
+ /* 14 */ SDL_SCANCODE_BACKSPACE,
+ /* 15 */ SDL_SCANCODE_TAB,
+ /* 16 */ SDL_SCANCODE_Q,
+ /* 17 */ SDL_SCANCODE_W,
+ /* 18 */ SDL_SCANCODE_E,
+ /* 19 */ SDL_SCANCODE_R,
+ /* 20 */ SDL_SCANCODE_T,
+ /* 21 */ SDL_SCANCODE_Y,
+ /* 22 */ SDL_SCANCODE_U,
+ /* 23 */ SDL_SCANCODE_I,
+ /* 24 */ SDL_SCANCODE_O,
+ /* 25 */ SDL_SCANCODE_P,
+ /* 26 */ SDL_SCANCODE_LEFTBRACKET,
+ /* 27 */ SDL_SCANCODE_RIGHTBRACKET,
+ /* 28 */ SDL_SCANCODE_RETURN,
+ /* 29 */ SDL_SCANCODE_LCTRL,
+ /* 30 */ SDL_SCANCODE_A,
+ /* 31 */ SDL_SCANCODE_S,
+ /* 32 */ SDL_SCANCODE_D,
+ /* 33 */ SDL_SCANCODE_F,
+ /* 34 */ SDL_SCANCODE_G,
+ /* 35 */ SDL_SCANCODE_H,
+ /* 36 */ SDL_SCANCODE_J,
+ /* 37 */ SDL_SCANCODE_K,
+ /* 38 */ SDL_SCANCODE_L,
+ /* 39 */ SDL_SCANCODE_SEMICOLON,
+ /* 40 */ SDL_SCANCODE_APOSTROPHE,
+ /* 41 */ SDL_SCANCODE_GRAVE,
+ /* 42 */ SDL_SCANCODE_LSHIFT,
+ /* 43 */ SDL_SCANCODE_BACKSLASH,
+ /* 44 */ SDL_SCANCODE_Z,
+ /* 45 */ SDL_SCANCODE_X,
+ /* 46 */ SDL_SCANCODE_C,
+ /* 47 */ SDL_SCANCODE_V,
+ /* 48 */ SDL_SCANCODE_B,
+ /* 49 */ SDL_SCANCODE_N,
+ /* 50 */ SDL_SCANCODE_M,
+ /* 51 */ SDL_SCANCODE_COMMA,
+ /* 52 */ SDL_SCANCODE_PERIOD,
+ /* 53 */ SDL_SCANCODE_SLASH,
+ /* 54 */ SDL_SCANCODE_RSHIFT,
+ /* 55 */ SDL_SCANCODE_KP_MULTIPLY,
+ /* 56 */ SDL_SCANCODE_LALT,
+ /* 57 */ SDL_SCANCODE_SPACE,
+ /* 58 */ SDL_SCANCODE_CAPSLOCK,
+ /* 59 */ SDL_SCANCODE_F1,
+ /* 60 */ SDL_SCANCODE_F2,
+ /* 61 */ SDL_SCANCODE_F3,
+ /* 62 */ SDL_SCANCODE_F4,
+ /* 63 */ SDL_SCANCODE_F5,
+ /* 64 */ SDL_SCANCODE_F6,
+ /* 65 */ SDL_SCANCODE_F7,
+ /* 66 */ SDL_SCANCODE_F8,
+ /* 67 */ SDL_SCANCODE_F9,
+ /* 68 */ SDL_SCANCODE_F10,
+ /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
+ /* 70 */ SDL_SCANCODE_SCROLLLOCK,
+ /* 71 */ SDL_SCANCODE_KP_7,
+ /* 72 */ SDL_SCANCODE_KP_8,
+ /* 73 */ SDL_SCANCODE_KP_9,
+ /* 74 */ SDL_SCANCODE_KP_MINUS,
+ /* 75 */ SDL_SCANCODE_KP_4,
+ /* 76 */ SDL_SCANCODE_KP_5,
+ /* 77 */ SDL_SCANCODE_KP_6,
+ /* 78 */ SDL_SCANCODE_KP_PLUS,
+ /* 79 */ SDL_SCANCODE_KP_1,
+ /* 80 */ SDL_SCANCODE_KP_2,
+ /* 81 */ SDL_SCANCODE_KP_3,
+ /* 82 */ SDL_SCANCODE_KP_0,
+ /* 83 */ SDL_SCANCODE_KP_PERIOD,
+ /* 84 */ SDL_SCANCODE_SYSREQ,
+ /* 85 */ SDL_SCANCODE_MODE,
+ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
+ /* 87 */ SDL_SCANCODE_F11,
+ /* 88 */ SDL_SCANCODE_F12,
+ /* 89 */ SDL_SCANCODE_HOME,
+ /* 90 */ SDL_SCANCODE_UP,
+ /* 91 */ SDL_SCANCODE_PAGEUP,
+ /* 92 */ SDL_SCANCODE_LEFT,
+ /* 93 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* on PowerBook G4 / KEY_Begin */
+ /* 94 */ SDL_SCANCODE_RIGHT,
+ /* 95 */ SDL_SCANCODE_END,
+ /* 96 */ SDL_SCANCODE_DOWN,
+ /* 97 */ SDL_SCANCODE_PAGEDOWN,
+ /* 98 */ SDL_SCANCODE_INSERT,
+ /* 99 */ SDL_SCANCODE_DELETE,
+ /* 100 */ SDL_SCANCODE_KP_ENTER,
+ /* 101 */ SDL_SCANCODE_RCTRL,
+ /* 102 */ SDL_SCANCODE_PAUSE,
+ /* 103 */ SDL_SCANCODE_PRINTSCREEN,
+ /* 104 */ SDL_SCANCODE_KP_DIVIDE,
+ /* 105 */ SDL_SCANCODE_RALT,
+ /* 106 */ SDL_SCANCODE_UNKNOWN, /* BREAK */
+ /* 107 */ SDL_SCANCODE_LGUI,
+ /* 108 */ SDL_SCANCODE_RGUI,
+ /* 109 */ SDL_SCANCODE_APPLICATION,
+ /* 110 */ SDL_SCANCODE_F13,
+ /* 111 */ SDL_SCANCODE_F14,
+ /* 112 */ SDL_SCANCODE_F15,
+ /* 113 */ SDL_SCANCODE_F16,
+ /* 114 */ SDL_SCANCODE_F17,
+ /* 115 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */
+ /* 116 */ SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */
+ /* 117 */ SDL_SCANCODE_UNKNOWN,
+ /* 118 */ SDL_SCANCODE_KP_EQUALS,
+ /* 119 */ SDL_SCANCODE_UNKNOWN,
+ /* 120 */ SDL_SCANCODE_UNKNOWN,
+ /* 121 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */
+ /* 122 */ SDL_SCANCODE_UNKNOWN,
+ /* 123 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */
+ /* 124 */ SDL_SCANCODE_UNKNOWN,
+ /* 125 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */
+ /* 126 */ SDL_SCANCODE_UNKNOWN,
+ /* 127 */ SDL_SCANCODE_UNKNOWN,
+ /* 128 */ SDL_SCANCODE_UNKNOWN,
+ /* 129 */ SDL_SCANCODE_UNKNOWN,
+ /* 130 */ SDL_SCANCODE_UNKNOWN,
+ /* 131 */ SDL_SCANCODE_UNKNOWN,
+ /* 132 */ SDL_SCANCODE_POWER,
+ /* 133 */ SDL_SCANCODE_MUTE,
+ /* 134 */ SDL_SCANCODE_VOLUMEDOWN,
+ /* 135 */ SDL_SCANCODE_VOLUMEUP,
+ /* 136 */ SDL_SCANCODE_HELP,
+ /* 137 */ SDL_SCANCODE_STOP,
+ /* 138 */ SDL_SCANCODE_AGAIN,
+ /* 139 */ SDL_SCANCODE_UNKNOWN, /* PROPS */
+ /* 140 */ SDL_SCANCODE_UNDO,
+ /* 141 */ SDL_SCANCODE_UNKNOWN, /* FRONT */
+ /* 142 */ SDL_SCANCODE_COPY,
+ /* 143 */ SDL_SCANCODE_UNKNOWN, /* OPEN */
+ /* 144 */ SDL_SCANCODE_PASTE,
+ /* 145 */ SDL_SCANCODE_FIND,
+ /* 146 */ SDL_SCANCODE_CUT,
+};
+
+/* for wireless usb keyboard (manufacturer TRUST) without numpad. */
+static const SDL_Scancode xfree86_scancode_table2[] = {
+ /* 0 */ SDL_SCANCODE_UNKNOWN,
+ /* 1 */ SDL_SCANCODE_ESCAPE,
+ /* 2 */ SDL_SCANCODE_1,
+ /* 3 */ SDL_SCANCODE_2,
+ /* 4 */ SDL_SCANCODE_3,
+ /* 5 */ SDL_SCANCODE_4,
+ /* 6 */ SDL_SCANCODE_5,
+ /* 7 */ SDL_SCANCODE_6,
+ /* 8 */ SDL_SCANCODE_7,
+ /* 9 */ SDL_SCANCODE_8,
+ /* 10 */ SDL_SCANCODE_9,
+ /* 11 */ SDL_SCANCODE_0,
+ /* 12 */ SDL_SCANCODE_MINUS,
+ /* 13 */ SDL_SCANCODE_EQUALS,
+ /* 14 */ SDL_SCANCODE_BACKSPACE,
+ /* 15 */ SDL_SCANCODE_TAB,
+ /* 16 */ SDL_SCANCODE_Q,
+ /* 17 */ SDL_SCANCODE_W,
+ /* 18 */ SDL_SCANCODE_E,
+ /* 19 */ SDL_SCANCODE_R,
+ /* 20 */ SDL_SCANCODE_T,
+ /* 21 */ SDL_SCANCODE_Y,
+ /* 22 */ SDL_SCANCODE_U,
+ /* 23 */ SDL_SCANCODE_I,
+ /* 24 */ SDL_SCANCODE_O,
+ /* 25 */ SDL_SCANCODE_P,
+ /* 26 */ SDL_SCANCODE_LEFTBRACKET,
+ /* 27 */ SDL_SCANCODE_RIGHTBRACKET,
+ /* 28 */ SDL_SCANCODE_RETURN,
+ /* 29 */ SDL_SCANCODE_LCTRL,
+ /* 30 */ SDL_SCANCODE_A,
+ /* 31 */ SDL_SCANCODE_S,
+ /* 32 */ SDL_SCANCODE_D,
+ /* 33 */ SDL_SCANCODE_F,
+ /* 34 */ SDL_SCANCODE_G,
+ /* 35 */ SDL_SCANCODE_H,
+ /* 36 */ SDL_SCANCODE_J,
+ /* 37 */ SDL_SCANCODE_K,
+ /* 38 */ SDL_SCANCODE_L,
+ /* 39 */ SDL_SCANCODE_SEMICOLON,
+ /* 40 */ SDL_SCANCODE_APOSTROPHE,
+ /* 41 */ SDL_SCANCODE_GRAVE,
+ /* 42 */ SDL_SCANCODE_LSHIFT,
+ /* 43 */ SDL_SCANCODE_BACKSLASH,
+ /* 44 */ SDL_SCANCODE_Z,
+ /* 45 */ SDL_SCANCODE_X,
+ /* 46 */ SDL_SCANCODE_C,
+ /* 47 */ SDL_SCANCODE_V,
+ /* 48 */ SDL_SCANCODE_B,
+ /* 49 */ SDL_SCANCODE_N,
+ /* 50 */ SDL_SCANCODE_M,
+ /* 51 */ SDL_SCANCODE_COMMA,
+ /* 52 */ SDL_SCANCODE_PERIOD,
+ /* 53 */ SDL_SCANCODE_SLASH,
+ /* 54 */ SDL_SCANCODE_RSHIFT,
+ /* 55 */ SDL_SCANCODE_KP_MULTIPLY,
+ /* 56 */ SDL_SCANCODE_LALT,
+ /* 57 */ SDL_SCANCODE_SPACE,
+ /* 58 */ SDL_SCANCODE_CAPSLOCK,
+ /* 59 */ SDL_SCANCODE_F1,
+ /* 60 */ SDL_SCANCODE_F2,
+ /* 61 */ SDL_SCANCODE_F3,
+ /* 62 */ SDL_SCANCODE_F4,
+ /* 63 */ SDL_SCANCODE_F5,
+ /* 64 */ SDL_SCANCODE_F6,
+ /* 65 */ SDL_SCANCODE_F7,
+ /* 66 */ SDL_SCANCODE_F8,
+ /* 67 */ SDL_SCANCODE_F9,
+ /* 68 */ SDL_SCANCODE_F10,
+ /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
+ /* 70 */ SDL_SCANCODE_SCROLLLOCK,
+ /* 71 */ SDL_SCANCODE_KP_7,
+ /* 72 */ SDL_SCANCODE_KP_8,
+ /* 73 */ SDL_SCANCODE_KP_9,
+ /* 74 */ SDL_SCANCODE_KP_MINUS,
+ /* 75 */ SDL_SCANCODE_KP_4,
+ /* 76 */ SDL_SCANCODE_KP_5,
+ /* 77 */ SDL_SCANCODE_KP_6,
+ /* 78 */ SDL_SCANCODE_KP_PLUS,
+ /* 79 */ SDL_SCANCODE_KP_1,
+ /* 80 */ SDL_SCANCODE_KP_2,
+ /* 81 */ SDL_SCANCODE_KP_3,
+ /* 82 */ SDL_SCANCODE_KP_0,
+ /* 83 */ SDL_SCANCODE_KP_PERIOD,
+ /* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */
+ /* 85 */ SDL_SCANCODE_MODE, /* ???? */
+ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
+ /* 87 */ SDL_SCANCODE_F11,
+ /* 88 */ SDL_SCANCODE_F12,
+ /* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */
+ /* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */
+ /* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */
+ /* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */
+ /* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* Hiragana_Katakana */
+ /* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */
+ /* 95 */ SDL_SCANCODE_UNKNOWN,
+ /* 96 */ SDL_SCANCODE_KP_ENTER,
+ /* 97 */ SDL_SCANCODE_RCTRL,
+ /* 98 */ SDL_SCANCODE_KP_DIVIDE,
+ /* 99 */ SDL_SCANCODE_PRINTSCREEN,
+ /* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
+ /* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */
+ /* 102 */ SDL_SCANCODE_HOME,
+ /* 103 */ SDL_SCANCODE_UP,
+ /* 104 */ SDL_SCANCODE_PAGEUP,
+ /* 105 */ SDL_SCANCODE_LEFT,
+ /* 106 */ SDL_SCANCODE_RIGHT,
+ /* 107 */ SDL_SCANCODE_END,
+ /* 108 */ SDL_SCANCODE_DOWN,
+ /* 109 */ SDL_SCANCODE_PAGEDOWN,
+ /* 110 */ SDL_SCANCODE_INSERT,
+ /* 111 */ SDL_SCANCODE_DELETE,
+ /* 112 */ SDL_SCANCODE_UNKNOWN,
+ /* 113 */ SDL_SCANCODE_MUTE,
+ /* 114 */ SDL_SCANCODE_VOLUMEDOWN,
+ /* 115 */ SDL_SCANCODE_VOLUMEUP,
+ /* 116 */ SDL_SCANCODE_POWER,
+ /* 117 */ SDL_SCANCODE_KP_EQUALS,
+ /* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */
+ /* 119 */ SDL_SCANCODE_PAUSE,
+ /* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */
+ /* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */
+ /* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */
+ /* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */
+ /* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */
+ /* 125 */ SDL_SCANCODE_LGUI,
+ /* 126 */ SDL_SCANCODE_RGUI,
+ /* 127 */ SDL_SCANCODE_APPLICATION,
+ /* 128 */ SDL_SCANCODE_CANCEL,
+ /* 129 */ SDL_SCANCODE_AGAIN,
+ /* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */
+ /* 131 */ SDL_SCANCODE_UNDO,
+ /* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */
+ /* 133 */ SDL_SCANCODE_COPY,
+ /* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */
+ /* 135 */ SDL_SCANCODE_PASTE,
+ /* 136 */ SDL_SCANCODE_FIND,
+ /* 137 */ SDL_SCANCODE_CUT,
+ /* 138 */ SDL_SCANCODE_HELP,
+ /* 139 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */
+ /* 140 */ SDL_SCANCODE_CALCULATOR,
+ /* 141 */ SDL_SCANCODE_UNKNOWN,
+ /* 142 */ SDL_SCANCODE_SLEEP,
+ /* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */
+ /* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */
+ /* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
+ /* 146 */ SDL_SCANCODE_UNKNOWN,
+ /* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */
+ /* 148 */ SDL_SCANCODE_APP1, /* XF86Launch1 */
+ /* 149 */ SDL_SCANCODE_APP2, /* XF86Launch2 */
+ /* 150 */ SDL_SCANCODE_WWW,
+ /* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */
+ /* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */
+ /* 153 */ SDL_SCANCODE_UNKNOWN,
+ /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */
+ /* 155 */ SDL_SCANCODE_MAIL,
+ /* 156 */ SDL_SCANCODE_AC_BOOKMARKS, /* XF86Favorites */
+ /* 157 */ SDL_SCANCODE_COMPUTER,
+ /* 158 */ SDL_SCANCODE_AC_BACK,
+ /* 159 */ SDL_SCANCODE_AC_FORWARD,
+ /* 160 */ SDL_SCANCODE_UNKNOWN,
+ /* 161 */ SDL_SCANCODE_EJECT,
+ /* 162 */ SDL_SCANCODE_EJECT,
+ /* 163 */ SDL_SCANCODE_AUDIONEXT,
+ /* 164 */ SDL_SCANCODE_AUDIOPLAY,
+ /* 165 */ SDL_SCANCODE_AUDIOPREV,
+ /* 166 */ SDL_SCANCODE_AUDIOSTOP,
+ /* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */
+ /* 168 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRewind */
+ /* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */
+ /* 170 */ SDL_SCANCODE_UNKNOWN,
+ /* 171 */ SDL_SCANCODE_F13, /* XF86Tools */
+ /* 172 */ SDL_SCANCODE_AC_HOME,
+ /* 173 */ SDL_SCANCODE_AC_REFRESH,
+ /* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
+ /* 175 */ SDL_SCANCODE_UNKNOWN,
+ /* 176 */ SDL_SCANCODE_UNKNOWN,
+ /* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */
+ /* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */
+ /* 179 */ SDL_SCANCODE_UNKNOWN, /* parenleft */
+ /* 180 */ SDL_SCANCODE_UNKNOWN, /* parenright */
+ /* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */
+ /* 182 */ SDL_SCANCODE_AGAIN,
+ /* 183 */ SDL_SCANCODE_F13, /* XF86Tools */
+ /* 184 */ SDL_SCANCODE_F14, /* XF86Launch5 */
+ /* 185 */ SDL_SCANCODE_F15, /* XF86Launch6 */
+ /* 186 */ SDL_SCANCODE_F16, /* XF86Launch7 */
+ /* 187 */ SDL_SCANCODE_F17, /* XF86Launch8 */
+ /* 188 */ SDL_SCANCODE_F18, /* XF86Launch9 */
+ /* 189 */ SDL_SCANCODE_F19, /* null keysym */
+ /* 190 */ SDL_SCANCODE_UNKNOWN,
+ /* 191 */ SDL_SCANCODE_UNKNOWN,
+ /* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */
+ /* 193 */ SDL_SCANCODE_UNKNOWN,
+ /* 194 */ SDL_SCANCODE_UNKNOWN,
+ /* 195 */ SDL_SCANCODE_MODE,
+ /* 196 */ SDL_SCANCODE_UNKNOWN,
+ /* 197 */ SDL_SCANCODE_UNKNOWN,
+ /* 198 */ SDL_SCANCODE_UNKNOWN,
+ /* 199 */ SDL_SCANCODE_UNKNOWN,
+ /* 200 */ SDL_SCANCODE_AUDIOPLAY,
+ /* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */
+ /* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */
+ /* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */
+ /* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */
+ /* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */
+ /* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
+ /* 207 */ SDL_SCANCODE_AUDIOPLAY,
+ /* 208 */ SDL_SCANCODE_AUDIONEXT,
+ /* 209 */ SDL_SCANCODE_UNKNOWN,
+ /* 210 */ SDL_SCANCODE_PRINTSCREEN,
+ /* 211 */ SDL_SCANCODE_UNKNOWN,
+ /* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */
+ /* 213 */ SDL_SCANCODE_UNKNOWN,
+ /* 214 */ SDL_SCANCODE_UNKNOWN,
+ /* 215 */ SDL_SCANCODE_MAIL,
+ /* 216 */ SDL_SCANCODE_UNKNOWN,
+ /* 217 */ SDL_SCANCODE_AC_SEARCH,
+ /* 218 */ SDL_SCANCODE_UNKNOWN,
+ /* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */
+ /* 220 */ SDL_SCANCODE_UNKNOWN,
+ /* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */
+ /* 222 */ SDL_SCANCODE_UNKNOWN,
+ /* 223 */ SDL_SCANCODE_STOP,
+ /* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
+ /* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
+ /* 226 */ SDL_SCANCODE_MEDIASELECT,
+ /* 227 */ SDL_SCANCODE_DISPLAYSWITCH,
+ /* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
+ /* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
+ /* 230 */ SDL_SCANCODE_KBDILLUMUP,
+ /* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
+ /* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */
+ /* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */
+ /* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */
+ /* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */
+ /* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */
+ /* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */
+ /* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */
+};
+
+/* *INDENT-ON* */