early-access version 1617
This commit is contained in:
89
externals/SDL/src/events/SDL_events.c
vendored
89
externals/SDL/src/events/SDL_events.c
vendored
@@ -35,9 +35,9 @@
|
||||
|
||||
#undef SDL_PRIs64
|
||||
#ifdef __WIN32__
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#else
|
||||
#define SDL_PRIs64 "lld"
|
||||
#define SDL_PRIs64 "lld"
|
||||
#endif
|
||||
|
||||
/* An arbitrary limit so we don't have unbounded growth */
|
||||
@@ -92,6 +92,54 @@ static struct
|
||||
} SDL_EventQ = { NULL, { 1 }, { 0 }, 0, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
|
||||
static SDL_bool SDL_update_joysticks = SDL_TRUE;
|
||||
|
||||
static void
|
||||
SDL_CalculateShouldUpdateJoysticks()
|
||||
{
|
||||
if (SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_TRUE) &&
|
||||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) {
|
||||
SDL_update_joysticks = SDL_TRUE;
|
||||
} else {
|
||||
SDL_update_joysticks = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_CalculateShouldUpdateJoysticks();
|
||||
}
|
||||
|
||||
#endif /* !SDL_JOYSTICK_DISABLED */
|
||||
|
||||
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
|
||||
static SDL_bool SDL_update_sensors = SDL_TRUE;
|
||||
|
||||
static void
|
||||
SDL_CalculateShouldUpdateSensors()
|
||||
{
|
||||
if (SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_TRUE) &&
|
||||
!SDL_disabled_events[SDL_SENSORUPDATE >> 8]) {
|
||||
SDL_update_sensors = SDL_TRUE;
|
||||
} else {
|
||||
SDL_update_sensors = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_CalculateShouldUpdateSensors();
|
||||
}
|
||||
|
||||
#endif /* !SDL_SENSOR_DISABLED */
|
||||
|
||||
|
||||
/* 0 (default) means no logging, 1 means logging, 2 means logging with mouse and finger motion */
|
||||
static int SDL_DoEventLogging = 0;
|
||||
|
||||
@@ -678,20 +726,24 @@ SDL_PumpEvents(void)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
/* Release any keys held down from last frame */
|
||||
SDL_ReleaseAutoReleaseKeys();
|
||||
|
||||
/* 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))) {
|
||||
if (SDL_update_joysticks) {
|
||||
SDL_JoystickUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
/* Check for sensor state change */
|
||||
if (!SDL_disabled_events[SDL_SENSORUPDATE >> 8]) {
|
||||
if (SDL_update_sensors) {
|
||||
SDL_SensorUpdate();
|
||||
}
|
||||
#endif
|
||||
@@ -943,6 +995,17 @@ SDL_EventState(Uint32 type, int state)
|
||||
/* Querying state... */
|
||||
break;
|
||||
}
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (state == SDL_DISABLE || state == SDL_ENABLE) {
|
||||
SDL_CalculateShouldUpdateJoysticks();
|
||||
}
|
||||
#endif
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
if (state == SDL_DISABLE || state == SDL_ENABLE) {
|
||||
SDL_CalculateShouldUpdateSensors();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* turn off drag'n'drop support if we've disabled the events.
|
||||
@@ -1005,9 +1068,21 @@ SDL_SendKeymapChangedEvent(void)
|
||||
return SDL_SendAppEvent(SDL_KEYMAPCHANGED);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendLocaleChangedEvent(void)
|
||||
{
|
||||
return SDL_SendAppEvent(SDL_LOCALECHANGED);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_EventsInit(void)
|
||||
{
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL);
|
||||
#endif
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_AutoUpdateSensorsChanged, NULL);
|
||||
#endif
|
||||
SDL_AddHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL);
|
||||
if (SDL_StartEventLoop() < 0) {
|
||||
SDL_DelHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL);
|
||||
@@ -1025,6 +1100,12 @@ SDL_EventsQuit(void)
|
||||
SDL_QuitQuit();
|
||||
SDL_StopEventLoop();
|
||||
SDL_DelHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL);
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
SDL_DelHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL);
|
||||
#endif
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
SDL_DelHintCallback(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_AutoUpdateSensorsChanged, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
1
externals/SDL/src/events/SDL_events_c.h
vendored
1
externals/SDL/src/events/SDL_events_c.h
vendored
@@ -46,6 +46,7 @@ extern void SDL_QuitInterrupt(void);
|
||||
extern int SDL_SendAppEvent(SDL_EventType eventType);
|
||||
extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
|
||||
extern int SDL_SendKeymapChangedEvent(void);
|
||||
extern int SDL_SendLocaleChangedEvent(void);
|
||||
|
||||
extern int SDL_SendQuit(void);
|
||||
|
||||
|
81
externals/SDL/src/events/SDL_keyboard.c
vendored
81
externals/SDL/src/events/SDL_keyboard.c
vendored
@@ -25,7 +25,6 @@
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "../video/SDL_sysvideo.h"
|
||||
|
||||
|
||||
@@ -33,6 +32,9 @@
|
||||
|
||||
/* Global keyboard information */
|
||||
|
||||
#define KEYBOARD_HARDWARE 0x01
|
||||
#define KEYBOARD_AUTORELEASE 0x02
|
||||
|
||||
typedef struct SDL_Keyboard SDL_Keyboard;
|
||||
|
||||
struct SDL_Keyboard
|
||||
@@ -40,8 +42,10 @@ struct SDL_Keyboard
|
||||
/* Data common to all keyboards */
|
||||
SDL_Window *focus;
|
||||
Uint16 modstate;
|
||||
Uint8 keysource[SDL_NUM_SCANCODES];
|
||||
Uint8 keystate[SDL_NUM_SCANCODES];
|
||||
SDL_Keycode keymap[SDL_NUM_SCANCODES];
|
||||
SDL_bool autorelease_pending;
|
||||
};
|
||||
|
||||
static SDL_Keyboard SDL_keyboard;
|
||||
@@ -675,19 +679,20 @@ SDL_SetKeyboardFocus(SDL_Window * window)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
||||
static int
|
||||
SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
SDL_Keymod modifier;
|
||||
SDL_Keycode keycode;
|
||||
Uint32 type;
|
||||
Uint8 repeat;
|
||||
Uint8 repeat = SDL_FALSE;
|
||||
|
||||
if (!scancode) {
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
|
||||
state == SDL_PRESSED ? "pressed" : "released");
|
||||
@@ -707,12 +712,20 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
if (state) {
|
||||
if (keyboard->keystate[scancode]) {
|
||||
if (!(keyboard->keysource[scancode] & source)) {
|
||||
keyboard->keysource[scancode] |= source;
|
||||
return 0;
|
||||
}
|
||||
repeat = SDL_TRUE;
|
||||
}
|
||||
keyboard->keysource[scancode] |= source;
|
||||
} else {
|
||||
if (!keyboard->keystate[scancode]) {
|
||||
return 0;
|
||||
}
|
||||
keyboard->keysource[scancode] = 0;
|
||||
}
|
||||
|
||||
/* Update internal keyboard state */
|
||||
@@ -720,6 +733,10 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
||||
|
||||
keycode = keyboard->keymap[scancode];
|
||||
|
||||
if (source == KEYBOARD_AUTORELEASE) {
|
||||
keyboard->autorelease_pending = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Update modifiers state if applicable */
|
||||
switch (keycode) {
|
||||
case SDLK_LCTRL:
|
||||
@@ -785,6 +802,48 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
||||
return (posted);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
||||
{
|
||||
return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode)
|
||||
{
|
||||
return SDL_SendKeyboardKeyInternal(KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ReleaseAutoReleaseKeys(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
SDL_Scancode scancode;
|
||||
|
||||
if (keyboard->autorelease_pending) {
|
||||
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||
if (keyboard->keysource[scancode] == KEYBOARD_AUTORELEASE) {
|
||||
SDL_SendKeyboardKeyInternal(KEYBOARD_AUTORELEASE, SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
keyboard->autorelease_pending = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_HardwareKeyboardKeyPressed(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
SDL_Scancode scancode;
|
||||
|
||||
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||
if ((keyboard->keysource[scancode] & KEYBOARD_HARDWARE) != 0) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardText(const char *text)
|
||||
{
|
||||
|
7
externals/SDL/src/events/SDL_keyboard_c.h
vendored
7
externals/SDL/src/events/SDL_keyboard_c.h
vendored
@@ -49,6 +49,13 @@ extern void SDL_SetKeyboardFocus(SDL_Window * window);
|
||||
|
||||
/* Send a keyboard key event */
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
|
||||
extern int SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode);
|
||||
|
||||
/* Release all the autorelease keys */
|
||||
extern void SDL_ReleaseAutoReleaseKeys(void);
|
||||
|
||||
/* Return true if any hardware key is pressed */
|
||||
extern SDL_bool SDL_HardwareKeyboardKeyPressed(void);
|
||||
|
||||
/* Send keyboard text input */
|
||||
extern int SDL_SendKeyboardText(const char *text);
|
||||
|
38
externals/SDL/src/events/SDL_mouse.c
vendored
38
externals/SDL/src/events/SDL_mouse.c
vendored
@@ -22,7 +22,6 @@
|
||||
|
||||
/* General mouse handling code for SDL */
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_events.h"
|
||||
@@ -32,6 +31,10 @@
|
||||
#ifdef __WIN32__
|
||||
#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime()
|
||||
#endif
|
||||
#if defined(__OS2__)
|
||||
#define INCL_WIN
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_MOUSE */
|
||||
|
||||
@@ -54,6 +57,8 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol
|
||||
} else {
|
||||
#ifdef __WIN32__
|
||||
mouse->double_click_time = GetDoubleClickTime();
|
||||
#elif defined(__OS2__)
|
||||
mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME);
|
||||
#else
|
||||
mouse->double_click_time = 500;
|
||||
#endif
|
||||
@@ -722,23 +727,24 @@ 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 (mouse->GetGlobalMouseState) {
|
||||
int tmpx, tmpy;
|
||||
|
||||
/* make sure these are never NULL for the backend implementations... */
|
||||
if (!x) {
|
||||
x = &tmpx;
|
||||
}
|
||||
if (!y) {
|
||||
y = &tmpy;
|
||||
}
|
||||
|
||||
*x = *y = 0;
|
||||
|
||||
return mouse->GetGlobalMouseState(x, y);
|
||||
} else {
|
||||
return SDL_GetMouseState(x, y);
|
||||
}
|
||||
if (!y) {
|
||||
y = &tmpy;
|
||||
}
|
||||
|
||||
*x = *y = 0;
|
||||
|
||||
if (!mouse->GetGlobalMouseState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mouse->GetGlobalMouseState(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
|
2
externals/SDL/src/events/SDL_quit.c
vendored
2
externals/SDL/src/events/SDL_quit.c
vendored
@@ -19,8 +19,8 @@
|
||||
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 */
|
||||
|
||||
|
1
externals/SDL/src/events/SDL_touch.c
vendored
1
externals/SDL/src/events/SDL_touch.c
vendored
@@ -22,7 +22,6 @@
|
||||
|
||||
/* General touch handling code for SDL */
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "../video/SDL_sysvideo.h"
|
||||
|
Reference in New Issue
Block a user