mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-12 21:06:01 +00:00
Use the correct device ID (global or default or specific) based on context
This commit is contained in:
@@ -46,8 +46,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define BAPP_KEYBOARD_ID 1
|
|
||||||
#define BAPP_MOUSE_ID 1
|
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
class SDL_BLooper;
|
class SDL_BLooper;
|
||||||
@@ -251,12 +249,12 @@ class SDL_BLooper : public BLooper
|
|||||||
SDL_GetWindowPosition(win, &winPosX, &winPosY);
|
SDL_GetWindowPosition(win, &winPosX, &winPosY);
|
||||||
int dx = x - (winWidth / 2);
|
int dx = x - (winWidth / 2);
|
||||||
int dy = y - (winHeight / 2);
|
int dy = y - (winHeight / 2);
|
||||||
SDL_SendMouseMotion(0, win, BAPP_MOUSE_ID, SDL_GetMouse()->relative_mode, (float)dx, (float)dy);
|
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, SDL_GetMouse()->relative_mode, (float)dx, (float)dy);
|
||||||
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
|
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
|
||||||
if (!be_app->IsCursorHidden())
|
if (!be_app->IsCursorHidden())
|
||||||
be_app->HideCursor();
|
be_app->HideCursor();
|
||||||
} else {
|
} else {
|
||||||
SDL_SendMouseMotion(0, win, BAPP_MOUSE_ID, SDL_FALSE, (float)x, (float)y);
|
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, (float)x, (float)y);
|
||||||
if (SDL_CursorVisible() && be_app->IsCursorHidden())
|
if (SDL_CursorVisible() && be_app->IsCursorHidden())
|
||||||
be_app->ShowCursor();
|
be_app->ShowCursor();
|
||||||
}
|
}
|
||||||
@@ -274,7 +272,7 @@ class SDL_BLooper : public BLooper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
win = GetSDLWindow(winID);
|
win = GetSDLWindow(winID);
|
||||||
SDL_SendMouseButton(0, win, BAPP_MOUSE_ID, state, button);
|
SDL_SendMouseButton(0, win, SDL_DEFAULT_MOUSE_ID, state, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _HandleMouseWheel(BMessage *msg)
|
void _HandleMouseWheel(BMessage *msg)
|
||||||
@@ -289,7 +287,7 @@ class SDL_BLooper : public BLooper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
win = GetSDLWindow(winID);
|
win = GetSDLWindow(winID);
|
||||||
SDL_SendMouseWheel(0, win, BAPP_MOUSE_ID, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(0, win, SDL_DEFAULT_MOUSE_ID, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _HandleKey(BMessage *msg)
|
void _HandleKey(BMessage *msg)
|
||||||
@@ -306,7 +304,7 @@ class SDL_BLooper : public BLooper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HAIKU_SetKeyState(scancode, state);
|
HAIKU_SetKeyState(scancode, state);
|
||||||
SDL_SendKeyboardKey(0, BAPP_KEYBOARD_ID, state, HAIKU_GetScancodeFromBeKey(scancode));
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, state, HAIKU_GetScancodeFromBeKey(scancode));
|
||||||
|
|
||||||
if (state == SDL_PRESSED && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
|
if (state == SDL_PRESSED && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
|
||||||
const int8 *keyUtf8;
|
const int8 *keyUtf8;
|
||||||
|
@@ -538,7 +538,7 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr
|
|||||||
*/
|
*/
|
||||||
#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION >= NTDDI_WINBLUE
|
#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION >= NTDDI_WINBLUE
|
||||||
Point cursorPos = WINRT_TransformCursorPosition(window, sender->PointerPosition, TransformToSDLWindowSize);
|
Point cursorPos = WINRT_TransformCursorPosition(window, sender->PointerPosition, TransformToSDLWindowSize);
|
||||||
SDL_SendMouseMotion(0, window, 0, SDL_FALSE, cursorPos.X, cursorPos.Y);
|
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, cursorPos.X, cursorPos.Y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */
|
/* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */
|
||||||
@@ -724,8 +724,8 @@ void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, W
|
|||||||
template <typename BackButtonEventArgs>
|
template <typename BackButtonEventArgs>
|
||||||
static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args)
|
static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args)
|
||||||
{
|
{
|
||||||
SDL_SendKeyboardKey(0, 0, SDL_PRESSED, SDL_SCANCODE_AC_BACK);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, SDL_SCANCODE_AC_BACK);
|
||||||
SDL_SendKeyboardKey(0, 0, SDL_RELEASED, SDL_SCANCODE_AC_BACK);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_AC_BACK);
|
||||||
|
|
||||||
if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, SDL_FALSE)) {
|
if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, SDL_FALSE)) {
|
||||||
args->Handled = true;
|
args->Handled = true;
|
||||||
|
@@ -804,7 +804,7 @@ void SDL_ResetKeyboard(void)
|
|||||||
#endif
|
#endif
|
||||||
for (scancode = (SDL_Scancode)0; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
for (scancode = (SDL_Scancode)0; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||||
if (keyboard->keystate[scancode] == SDL_PRESSED) {
|
if (keyboard->keystate[scancode] == SDL_PRESSED) {
|
||||||
SDL_SendKeyboardKey(0, 0, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -947,6 +947,9 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo
|
|||||||
Uint8 repeat = SDL_FALSE;
|
Uint8 repeat = SDL_FALSE;
|
||||||
const Uint8 source = flags & KEYBOARD_SOURCE_MASK;
|
const Uint8 source = flags & KEYBOARD_SOURCE_MASK;
|
||||||
|
|
||||||
|
/* We currently don't have raw keyboard mode, so all key events are global */
|
||||||
|
keyboardID = SDL_GLOBAL_KEYBOARD_ID;
|
||||||
|
|
||||||
if (scancode == SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
if (scancode == SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1099,23 +1102,23 @@ int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch)
|
|||||||
|
|
||||||
if (mod & SDL_KMOD_SHIFT) {
|
if (mod & SDL_KMOD_SHIFT) {
|
||||||
/* If the character uses shift, press shift down */
|
/* If the character uses shift, press shift down */
|
||||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send a keydown and keyup for the character */
|
/* Send a keydown and keyup for the character */
|
||||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, SDL_PRESSED, code, SDLK_UNKNOWN);
|
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, code, SDLK_UNKNOWN);
|
||||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, SDL_RELEASED, code, SDLK_UNKNOWN);
|
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, code, SDLK_UNKNOWN);
|
||||||
|
|
||||||
if (mod & SDL_KMOD_SHIFT) {
|
if (mod & SDL_KMOD_SHIFT) {
|
||||||
/* If the character uses shift, release shift */
|
/* If the character uses shift, release shift */
|
||||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SendVirtualKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode)
|
int SDL_SendVirtualKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode)
|
||||||
{
|
{
|
||||||
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, state, scancode, SDLK_UNKNOWN);
|
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, state, scancode, SDLK_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SendKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, Uint8 state, SDL_Scancode scancode)
|
int SDL_SendKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, Uint8 state, SDL_Scancode scancode)
|
||||||
@@ -1130,7 +1133,7 @@ int SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboardID, U
|
|||||||
|
|
||||||
int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode)
|
int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode)
|
||||||
{
|
{
|
||||||
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_AUTORELEASE, 0, SDL_PRESSED, scancode, SDLK_UNKNOWN);
|
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode, SDLK_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SendKeyboardKeyIgnoreModifiers(Uint64 timestamp, SDL_KeyboardID keyboardID, Uint8 state, SDL_Scancode scancode)
|
int SDL_SendKeyboardKeyIgnoreModifiers(Uint64 timestamp, SDL_KeyboardID keyboardID, Uint8 state, SDL_Scancode scancode)
|
||||||
@@ -1146,7 +1149,7 @@ void SDL_ReleaseAutoReleaseKeys(void)
|
|||||||
if (keyboard->autorelease_pending) {
|
if (keyboard->autorelease_pending) {
|
||||||
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||||
if (keyboard->keysource[scancode] == KEYBOARD_AUTORELEASE) {
|
if (keyboard->keysource[scancode] == KEYBOARD_AUTORELEASE) {
|
||||||
SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, 0, SDL_RELEASED, scancode, SDLK_UNKNOWN);
|
SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode, SDLK_UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keyboard->autorelease_pending = SDL_FALSE;
|
keyboard->autorelease_pending = SDL_FALSE;
|
||||||
|
@@ -23,6 +23,12 @@
|
|||||||
#ifndef SDL_keyboard_c_h_
|
#ifndef SDL_keyboard_c_h_
|
||||||
#define SDL_keyboard_c_h_
|
#define SDL_keyboard_c_h_
|
||||||
|
|
||||||
|
/* Keyboard events not associated with a specific input device */
|
||||||
|
#define SDL_GLOBAL_KEYBOARD_ID 0
|
||||||
|
|
||||||
|
/* The default keyboard input device, for platforms that don't have multiple keyboards */
|
||||||
|
#define SDL_DEFAULT_KEYBOARD_ID 1
|
||||||
|
|
||||||
/* Initialize the keyboard subsystem */
|
/* Initialize the keyboard subsystem */
|
||||||
extern int SDL_InitKeyboard(void);
|
extern int SDL_InitKeyboard(void);
|
||||||
|
|
||||||
|
@@ -507,7 +507,7 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3
|
|||||||
SDL_Log("Mouse left window, synthesizing move & focus lost event\n");
|
SDL_Log("Mouse left window, synthesizing move & focus lost event\n");
|
||||||
#endif
|
#endif
|
||||||
if (send_mouse_motion) {
|
if (send_mouse_motion) {
|
||||||
SDL_PrivateSendMouseMotion(0, window, 0, SDL_FALSE, x, y);
|
SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
}
|
}
|
||||||
SDL_SetMouseFocus(NULL);
|
SDL_SetMouseFocus(NULL);
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3
|
|||||||
#endif
|
#endif
|
||||||
SDL_SetMouseFocus(window);
|
SDL_SetMouseFocus(window);
|
||||||
if (send_mouse_motion) {
|
if (send_mouse_motion) {
|
||||||
SDL_PrivateSendMouseMotion(0, window, 0, SDL_FALSE, x, y);
|
SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
@@ -691,6 +691,11 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
|
|||||||
float xrel = 0.0f;
|
float xrel = 0.0f;
|
||||||
float yrel = 0.0f;
|
float yrel = 0.0f;
|
||||||
|
|
||||||
|
if (!mouse->relative_mode && mouseID != SDL_TOUCH_MOUSEID && mouseID != SDL_PEN_MOUSEID) {
|
||||||
|
/* We're not in relative mode, so all mouse events are global mouse events */
|
||||||
|
mouseID = SDL_GLOBAL_MOUSE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
/* SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events */
|
/* SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events */
|
||||||
if (mouse->mouse_touch_events) {
|
if (mouse->mouse_touch_events) {
|
||||||
if (mouseID != SDL_TOUCH_MOUSEID && !relative && track_mouse_down) {
|
if (mouseID != SDL_TOUCH_MOUSEID && !relative && track_mouse_down) {
|
||||||
@@ -880,6 +885,11 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_
|
|||||||
Uint32 buttonstate;
|
Uint32 buttonstate;
|
||||||
SDL_MouseInputSource *source;
|
SDL_MouseInputSource *source;
|
||||||
|
|
||||||
|
if (!mouse->relative_mode && mouseID != SDL_TOUCH_MOUSEID && mouseID != SDL_PEN_MOUSEID) {
|
||||||
|
/* We're not in relative mode, so all mouse events are global mouse events */
|
||||||
|
mouseID = SDL_GLOBAL_MOUSE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
source = GetMouseInputSource(mouse, mouseID, state, button);
|
source = GetMouseInputSource(mouse, mouseID, state, button);
|
||||||
if (!source) {
|
if (!source) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1198,7 +1208,7 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool
|
|||||||
(!mouse->relative_mode || mouse->relative_mode_warp)) {
|
(!mouse->relative_mode || mouse->relative_mode_warp)) {
|
||||||
mouse->WarpMouse(window, x, y);
|
mouse->WarpMouse(window, x, y);
|
||||||
} else {
|
} else {
|
||||||
SDL_PrivateSendMouseMotion(0, window, 0, SDL_FALSE, x, y);
|
SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,6 +23,12 @@
|
|||||||
#ifndef SDL_mouse_c_h_
|
#ifndef SDL_mouse_c_h_
|
||||||
#define SDL_mouse_c_h_
|
#define SDL_mouse_c_h_
|
||||||
|
|
||||||
|
/* Mouse events not associated with a specific input device */
|
||||||
|
#define SDL_GLOBAL_MOUSE_ID 0
|
||||||
|
|
||||||
|
/* The default mouse input device, for platforms that don't have multiple mice */
|
||||||
|
#define SDL_DEFAULT_MOUSE_ID 1
|
||||||
|
|
||||||
struct SDL_Cursor
|
struct SDL_Cursor
|
||||||
{
|
{
|
||||||
struct SDL_Cursor *next;
|
struct SDL_Cursor *next;
|
||||||
|
@@ -205,7 +205,7 @@ int Android_OnPadDown(int device_id, int keycode)
|
|||||||
if (item && item->joystick) {
|
if (item && item->joystick) {
|
||||||
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_PRESSED);
|
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_PRESSED);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(timestamp, 0, SDL_PRESSED, button_to_scancode(button));
|
SDL_SendKeyboardKey(timestamp, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, button_to_scancode(button));
|
||||||
}
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -225,7 +225,7 @@ int Android_OnPadUp(int device_id, int keycode)
|
|||||||
if (item && item->joystick) {
|
if (item && item->joystick) {
|
||||||
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_RELEASED);
|
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_RELEASED);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(timestamp, 0, SDL_RELEASED, button_to_scancode(button));
|
SDL_SendKeyboardKey(timestamp, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, button_to_scancode(button));
|
||||||
}
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -330,12 +330,12 @@ static SDL_Scancode TranslateKeycode(int keycode)
|
|||||||
|
|
||||||
int Android_OnKeyDown(int keycode)
|
int Android_OnKeyDown(int keycode)
|
||||||
{
|
{
|
||||||
return SDL_SendKeyboardKey(0, Android_KeyboardID, SDL_PRESSED, TranslateKeycode(keycode));
|
return SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, TranslateKeycode(keycode));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Android_OnKeyUp(int keycode)
|
int Android_OnKeyUp(int keycode)
|
||||||
{
|
{
|
||||||
return SDL_SendKeyboardKey(0, Android_KeyboardID, SDL_RELEASED, TranslateKeycode(keycode));
|
return SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, TranslateKeycode(keycode));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this)
|
SDL_bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this)
|
||||||
|
@@ -221,25 +221,25 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y
|
|||||||
changes = state & ~last_state;
|
changes = state & ~last_state;
|
||||||
button = TranslateButton(changes);
|
button = TranslateButton(changes);
|
||||||
last_state = state;
|
last_state = state;
|
||||||
SDL_SendMouseMotion(0, window, Android_MouseID, relative, x, y);
|
SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y);
|
||||||
SDL_SendMouseButton(0, window, Android_MouseID, SDL_PRESSED, button);
|
SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_PRESSED, button);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_UP:
|
case ACTION_UP:
|
||||||
changes = last_state & ~state;
|
changes = last_state & ~state;
|
||||||
button = TranslateButton(changes);
|
button = TranslateButton(changes);
|
||||||
last_state = state;
|
last_state = state;
|
||||||
SDL_SendMouseMotion(0, window, Android_MouseID, relative, x, y);
|
SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y);
|
||||||
SDL_SendMouseButton(0, window, Android_MouseID, SDL_RELEASED, button);
|
SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_RELEASED, button);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_MOVE:
|
case ACTION_MOVE:
|
||||||
case ACTION_HOVER_MOVE:
|
case ACTION_HOVER_MOVE:
|
||||||
SDL_SendMouseMotion(0, window, Android_MouseID, relative, x, y);
|
SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_SCROLL:
|
case ACTION_SCROLL:
|
||||||
SDL_SendMouseWheel(0, window, Android_MouseID, x, y, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(0, window, SDL_DEFAULT_MOUSE_ID, x, y, SDL_MOUSEWHEEL_NORMAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -67,8 +67,6 @@ SDL_Semaphore *Android_PauseSem = NULL;
|
|||||||
SDL_Semaphore *Android_ResumeSem = NULL;
|
SDL_Semaphore *Android_ResumeSem = NULL;
|
||||||
SDL_Mutex *Android_ActivityMutex = NULL;
|
SDL_Mutex *Android_ActivityMutex = NULL;
|
||||||
static SDL_SystemTheme Android_SystemTheme;
|
static SDL_SystemTheme Android_SystemTheme;
|
||||||
SDL_KeyboardID Android_KeyboardID = 0;
|
|
||||||
SDL_MouseID Android_MouseID = 0;
|
|
||||||
|
|
||||||
static int Android_SuspendScreenSaver(SDL_VideoDevice *_this)
|
static int Android_SuspendScreenSaver(SDL_VideoDevice *_this)
|
||||||
{
|
{
|
||||||
|
@@ -46,7 +46,5 @@ extern int Android_SurfaceHeight;
|
|||||||
extern float Android_ScreenDensity;
|
extern float Android_ScreenDensity;
|
||||||
extern SDL_Semaphore *Android_PauseSem, *Android_ResumeSem;
|
extern SDL_Semaphore *Android_PauseSem, *Android_ResumeSem;
|
||||||
extern SDL_Mutex *Android_ActivityMutex;
|
extern SDL_Mutex *Android_ActivityMutex;
|
||||||
extern SDL_KeyboardID Android_KeyboardID;
|
|
||||||
extern SDL_MouseID Android_MouseID;
|
|
||||||
|
|
||||||
#endif /* SDL_androidvideo_h_ */
|
#endif /* SDL_androidvideo_h_ */
|
||||||
|
@@ -200,7 +200,6 @@ static bool IsModifierKeyPressed(unsigned int flags,
|
|||||||
|
|
||||||
static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned int modifierFlags)
|
static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned int modifierFlags)
|
||||||
{
|
{
|
||||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
|
|
||||||
if (code == SDL_SCANCODE_LSHIFT) {
|
if (code == SDL_SCANCODE_LSHIFT) {
|
||||||
@@ -232,9 +231,9 @@ static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_PRESSED, code);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, code);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_RELEASED, code);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +414,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|||||||
UpdateKeymap(data, SDL_TRUE);
|
UpdateKeymap(data, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), data ? data.keyboardID : 0, SDL_PRESSED, code);
|
SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, code);
|
||||||
#ifdef DEBUG_SCANCODES
|
#ifdef DEBUG_SCANCODES
|
||||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||||
SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL forums/mailing list <https://discourse.libsdl.org/> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL forums/mailing list <https://discourse.libsdl.org/> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
||||||
@@ -434,7 +433,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSEventTypeKeyUp:
|
case NSEventTypeKeyUp:
|
||||||
SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), data ? data.keyboardID : 0, SDL_RELEASED, code);
|
SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, code);
|
||||||
break;
|
break;
|
||||||
case NSEventTypeFlagsChanged: {
|
case NSEventTypeFlagsChanged: {
|
||||||
// see if the new modifierFlags mean any existing keys should be pressed/released...
|
// see if the new modifierFlags mean any existing keys should be pressed/released...
|
||||||
|
@@ -302,7 +302,7 @@ static int Cocoa_WarpMouseGlobal(float x, float y)
|
|||||||
SDL_SetMouseFocus(win);
|
SDL_SetMouseFocus(win);
|
||||||
if (win) {
|
if (win) {
|
||||||
SDL_assert(win == mouse->focus);
|
SDL_assert(win == mouse->focus);
|
||||||
SDL_SendMouseMotion(0, win, 0, SDL_FALSE, x - win->x, y - win->y);
|
SDL_SendMouseMotion(0, win, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x - win->x, y - win->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,8 +450,7 @@ static void Cocoa_HandleTitleButtonEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|||||||
|
|
||||||
void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
|
void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
|
||||||
{
|
{
|
||||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
||||||
SDL_MouseID mouseID = videodata.mouseID;
|
|
||||||
SDL_Mouse *mouse;
|
SDL_Mouse *mouse;
|
||||||
SDL_MouseData *driverdata;
|
SDL_MouseData *driverdata;
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
@@ -529,8 +528,7 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|||||||
|
|
||||||
void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
||||||
{
|
{
|
||||||
SDL_CocoaVideoData *videodata = ((__bridge SDL_CocoaWindowData *)window->driverdata).videodata;
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
||||||
SDL_MouseID mouseID = videodata.mouseID;
|
|
||||||
SDL_MouseWheelDirection direction;
|
SDL_MouseWheelDirection direction;
|
||||||
CGFloat x, y;
|
CGFloat x, y;
|
||||||
|
|
||||||
|
@@ -101,8 +101,6 @@ DECLARE_ALERT_STYLE(Critical);
|
|||||||
@property(nonatomic) int trackpad_is_touch_only;
|
@property(nonatomic) int trackpad_is_touch_only;
|
||||||
@property(nonatomic) unsigned int modifierFlags;
|
@property(nonatomic) unsigned int modifierFlags;
|
||||||
@property(nonatomic) void *key_layout;
|
@property(nonatomic) void *key_layout;
|
||||||
@property(nonatomic) SDL_KeyboardID keyboardID;
|
|
||||||
@property(nonatomic) SDL_MouseID mouseID;
|
|
||||||
@property(nonatomic) SDLTranslatorResponder *fieldEdit;
|
@property(nonatomic) SDLTranslatorResponder *fieldEdit;
|
||||||
@property(nonatomic) NSInteger clipboard_count;
|
@property(nonatomic) NSInteger clipboard_count;
|
||||||
@property(nonatomic) IOPMAssertionID screensaver_assertion;
|
@property(nonatomic) IOPMAssertionID screensaver_assertion;
|
||||||
|
@@ -203,10 +203,8 @@ int Cocoa_VideoInit(SDL_VideoDevice *_this)
|
|||||||
|
|
||||||
// Assume we have a mouse and keyboard
|
// Assume we have a mouse and keyboard
|
||||||
// We could use GCMouse and GCKeyboard if we needed to, as is done in SDL_uikitevents.m
|
// We could use GCMouse and GCKeyboard if we needed to, as is done in SDL_uikitevents.m
|
||||||
data.keyboardID = SDL_GetNextObjectID();
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddKeyboard(data.keyboardID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
data.mouseID = SDL_GetNextObjectID();
|
|
||||||
SDL_AddMouse(data.mouseID, NULL, SDL_FALSE);
|
|
||||||
|
|
||||||
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
|
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
|
||||||
data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, SDL_FALSE);
|
data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, SDL_FALSE);
|
||||||
|
@@ -210,7 +210,7 @@
|
|||||||
x = point.x;
|
x = point.x;
|
||||||
y = (sdlwindow->h - point.y);
|
y = (sdlwindow->h - point.y);
|
||||||
if (x >= 0.0f && x < (float)sdlwindow->w && y >= 0.0f && y < (float)sdlwindow->h) {
|
if (x >= 0.0f && x < (float)sdlwindow->w && y >= 0.0f && y < (float)sdlwindow->h) {
|
||||||
SDL_SendMouseMotion(0, sdlwindow, 0, SDL_FALSE, x, y);
|
SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
}
|
}
|
||||||
/* Code addon to update the mouse location */
|
/* Code addon to update the mouse location */
|
||||||
|
|
||||||
@@ -1089,7 +1089,7 @@ static SDL_bool Cocoa_IsZoomed(SDL_Window *window)
|
|||||||
y = (window->h - point.y);
|
y = (window->h - point.y);
|
||||||
|
|
||||||
if (x >= 0.0f && x < (float)window->w && y >= 0.0f && y < (float)window->h) {
|
if (x >= 0.0f && x < (float)window->w && y >= 0.0f && y < (float)window->h) {
|
||||||
SDL_SendMouseMotion(0, window, 0, SDL_FALSE, x, y);
|
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,13 +1376,11 @@ static SDL_bool Cocoa_IsZoomed(SDL_Window *window)
|
|||||||
|
|
||||||
/* Also note that SDL_SendKeyboardKey expects all capslock events to be
|
/* Also note that SDL_SendKeyboardKey expects all capslock events to be
|
||||||
keypresses; it won't toggle the mod state if you send a keyrelease. */
|
keypresses; it won't toggle the mod state if you send a keyrelease. */
|
||||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
||||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
|
||||||
const SDL_bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE;
|
const SDL_bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE;
|
||||||
const SDL_bool sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? SDL_TRUE : SDL_FALSE;
|
const SDL_bool sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? SDL_TRUE : SDL_FALSE;
|
||||||
if (osenabled ^ sdlenabled) {
|
if (osenabled ^ sdlenabled) {
|
||||||
SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||||
SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (void)keyDown:(NSEvent *)theEvent
|
- (void)keyDown:(NSEvent *)theEvent
|
||||||
@@ -1457,9 +1455,7 @@ static SDL_bool Cocoa_IsZoomed(SDL_Window *window)
|
|||||||
|
|
||||||
static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, const Uint8 state, const Uint8 button)
|
static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, const Uint8 state, const Uint8 button)
|
||||||
{
|
{
|
||||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
||||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
|
||||||
SDL_MouseID mouseID = videodata.mouseID;
|
|
||||||
const int clicks = (int)[theEvent clickCount];
|
const int clicks = (int)[theEvent clickCount];
|
||||||
SDL_Window *focus = SDL_GetKeyboardFocus();
|
SDL_Window *focus = SDL_GetKeyboardFocus();
|
||||||
int rc;
|
int rc;
|
||||||
@@ -1591,9 +1587,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
|
|||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)theEvent
|
- (void)mouseMoved:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
||||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
|
||||||
SDL_MouseID mouseID = videodata.mouseID;
|
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
@@ -631,7 +631,7 @@ static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEv
|
|||||||
my = (float)(mouseEvent->targetY * yscale);
|
my = (float)(mouseEvent->targetY * yscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendMouseMotion(0, window_data->window, EMSCRIPTEN_MOUSE_ID, isPointerLocked, mx, my);
|
SDL_SendMouseMotion(0, window_data->window, SDL_DEFAULT_MOUSE_ID, isPointerLocked, mx, my);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,7 +669,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse
|
|||||||
sdl_event_type = SDL_EVENT_MOUSE_BUTTON_UP;
|
sdl_event_type = SDL_EVENT_MOUSE_BUTTON_UP;
|
||||||
prevent_default = SDL_EventEnabled(sdl_event_type);
|
prevent_default = SDL_EventEnabled(sdl_event_type);
|
||||||
}
|
}
|
||||||
SDL_SendMouseButton(0, window_data->window, EMSCRIPTEN_MOUSE_ID, sdl_button_state, sdl_button);
|
SDL_SendMouseButton(0, window_data->window, SDL_DEFAULT_MOUSE_ID, sdl_button_state, sdl_button);
|
||||||
|
|
||||||
/* Do not consume the event if the mouse is outside of the canvas. */
|
/* Do not consume the event if the mouse is outside of the canvas. */
|
||||||
emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h);
|
emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h);
|
||||||
@@ -695,7 +695,7 @@ static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseE
|
|||||||
|
|
||||||
mx = (float)(mouseEvent->targetX * (window_data->window->w / client_w));
|
mx = (float)(mouseEvent->targetX * (window_data->window->w / client_w));
|
||||||
my = (float)(mouseEvent->targetY * (window_data->window->h / client_h));
|
my = (float)(mouseEvent->targetY * (window_data->window->h / client_h));
|
||||||
SDL_SendMouseMotion(0, window_data->window, EMSCRIPTEN_MOUSE_ID, isPointerLocked, mx, my);
|
SDL_SendMouseMotion(0, window_data->window, SDL_GLOBAL_MOUSE_ID, isPointerLocked, mx, my);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetMouseFocus(eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? window_data->window : NULL);
|
SDL_SetMouseFocus(eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? window_data->window : NULL);
|
||||||
@@ -720,7 +720,7 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendMouseWheel(0, window_data->window, EMSCRIPTEN_MOUSE_ID, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(0, window_data->window, SDL_DEFAULT_MOUSE_ID, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
|
||||||
return SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL);
|
return SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,7 +811,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||||
SDL_SendKeyboardKeyAndKeycode(0, EMSCRIPTEN_KEYBOARD_ID, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode, keycode);
|
SDL_SendKeyboardKeyAndKeycode(0, SDL_DEFAULT_KEYBOARD_ID, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
|
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
|
||||||
|
@@ -137,8 +137,8 @@ int Emscripten_VideoInit(SDL_VideoDevice *_this)
|
|||||||
Emscripten_InitMouse();
|
Emscripten_InitMouse();
|
||||||
|
|
||||||
/* Assume we have a mouse and keyboard */
|
/* Assume we have a mouse and keyboard */
|
||||||
SDL_AddKeyboard(EMSCRIPTEN_KEYBOARD_ID, NULL, SDL_FALSE);
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddMouse(EMSCRIPTEN_MOUSE_ID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
|
|
||||||
/* We're done! */
|
/* We're done! */
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -28,9 +28,6 @@
|
|||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
|
|
||||||
#define EMSCRIPTEN_KEYBOARD_ID 1
|
|
||||||
#define EMSCRIPTEN_MOUSE_ID 1
|
|
||||||
|
|
||||||
struct SDL_WindowData
|
struct SDL_WindowData
|
||||||
{
|
{
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
@@ -282,8 +282,8 @@ int HAIKU_VideoInit(SDL_VideoDevice *_this)
|
|||||||
HAIKU_MouseInit(_this);
|
HAIKU_MouseInit(_this);
|
||||||
|
|
||||||
/* Assume we have a mouse and keyboard */
|
/* Assume we have a mouse and keyboard */
|
||||||
SDL_AddKeyboard(BAPP_KEYBOARD_ID, NULL, SDL_FALSE);
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddMouse(BAPP_MOUSE_ID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_OPENGL
|
#ifdef SDL_VIDEO_OPENGL
|
||||||
/* testgl application doesn't load library, just tries to load symbols */
|
/* testgl application doesn't load library, just tries to load symbols */
|
||||||
|
@@ -351,7 +351,7 @@ static int KMSDRM_WarpMouseGlobal(float x, float y)
|
|||||||
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
||||||
|
|
||||||
/* Update internal mouse position. */
|
/* Update internal mouse position. */
|
||||||
SDL_SendMouseMotion(0, mouse->focus, 0, SDL_FALSE, x, y);
|
SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
|
|
||||||
/* And now update the cursor graphic position on screen. */
|
/* And now update the cursor graphic position on screen. */
|
||||||
if (dispdata->cursor_bo) {
|
if (dispdata->cursor_bo) {
|
||||||
|
@@ -154,10 +154,10 @@ int HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent)
|
|||||||
|
|
||||||
switch (aWsEvent.Type()) {
|
switch (aWsEvent.Type()) {
|
||||||
case EEventKeyDown: /* Key events */
|
case EEventKeyDown: /* Key events */
|
||||||
SDL_SendKeyboardKey(0, data->keyboardID, SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
||||||
break;
|
break;
|
||||||
case EEventKeyUp: /* Key events */
|
case EEventKeyUp: /* Key events */
|
||||||
SDL_SendKeyboardKey(0, data->keyboardID, SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
||||||
break;
|
break;
|
||||||
case EEventFocusGained: /* SDL window got focus */
|
case EEventFocusGained: /* SDL window got focus */
|
||||||
data->NGAGE_IsWindowFocused = ETrue;
|
data->NGAGE_IsWindowFocused = ETrue;
|
||||||
|
@@ -60,9 +60,6 @@ struct SDL_VideoData
|
|||||||
TPoint NGAGE_ScreenOffset;
|
TPoint NGAGE_ScreenOffset;
|
||||||
|
|
||||||
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
|
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
|
||||||
|
|
||||||
SDL_KeyboardID keyboardID;
|
|
||||||
SDL_MouseID mouseID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SDL_ngagevideo_h */
|
#endif /* SDL_ngagevideo_h */
|
||||||
|
@@ -90,7 +90,7 @@ void PSP_PumpEvents(SDL_VideoDevice *_this)
|
|||||||
if (changed) {
|
if (changed) {
|
||||||
for (i = 0; i < sizeof(keymap_psp) / sizeof(keymap_psp[0]); i++) {
|
for (i = 0; i < sizeof(keymap_psp) / sizeof(keymap_psp[0]); i++) {
|
||||||
if (changed & keymap_psp[i].id) {
|
if (changed & keymap_psp[i].id) {
|
||||||
SDL_SendKeyboardKey(0, 0, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap_psp[i].sym));
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap_psp[i].sym));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ void PSP_PumpEvents(SDL_VideoDevice *_this)
|
|||||||
sym.sym = keymap[raw];
|
sym.sym = keymap[raw];
|
||||||
/* not tested */
|
/* not tested */
|
||||||
/* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */
|
/* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */
|
||||||
SDL_SendKeyboardKey(0, 0, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]));
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,9 +33,6 @@ typedef struct
|
|||||||
EGLConfig conf;
|
EGLConfig conf;
|
||||||
} window_impl_t;
|
} window_impl_t;
|
||||||
|
|
||||||
#define QNX_KEYBOARD_ID 1
|
|
||||||
#define QNX_MOUSE_ID 1
|
|
||||||
|
|
||||||
extern void handleKeyboardEvent(screen_event_t event);
|
extern void handleKeyboardEvent(screen_event_t event);
|
||||||
|
|
||||||
extern int glGetConfig(EGLConfig *pconf, int *pformat);
|
extern int glGetConfig(EGLConfig *pconf, int *pformat);
|
||||||
|
@@ -125,8 +125,8 @@ void handleKeyboardEvent(screen_event_t event)
|
|||||||
// FIXME:
|
// FIXME:
|
||||||
// Need to handle more key states (such as key combinations).
|
// Need to handle more key states (such as key combinations).
|
||||||
if (val & KEY_DOWN) {
|
if (val & KEY_DOWN) {
|
||||||
SDL_SendKeyboardKey(0, QNX_KEYBOARD_ID, SDL_PRESSED, scancode);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, scancode);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(0, QNX_KEYBOARD_ID, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,8 +53,8 @@ static int videoInit(SDL_VideoDevice *_this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Assume we have a mouse and keyboard */
|
/* Assume we have a mouse and keyboard */
|
||||||
SDL_AddKeyboard(QNX_KEYBOARD_ID, NULL, SDL_FALSE);
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddMouse(QNX_MOUSE_ID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -276,7 +276,7 @@ static int RPI_WarpMouseGlobal(float x, float y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update internal mouse position. */
|
/* Update internal mouse position. */
|
||||||
SDL_SendMouseMotion(0, mouse->focus, 0, SDL_FALSE, x, y);
|
SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
|
|
||||||
return RPI_WarpMouseGlobalGraphically(x, y);
|
return RPI_WarpMouseGlobalGraphically(x, y);
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this)
|
|||||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||||
if (driverdata->key_pressed[i] != 255) {
|
if (driverdata->key_pressed[i] != 255) {
|
||||||
if ((_kernel_osbyte(129, driverdata->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) {
|
if ((_kernel_osbyte(129, driverdata->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) {
|
||||||
SDL_SendKeyboardKey(0, driverdata->keyboardID, SDL_RELEASED, SDL_RISCOS_translate_keycode(driverdata->key_pressed[i]));
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, SDL_RISCOS_translate_keycode(driverdata->key_pressed[i]));
|
||||||
driverdata->key_pressed[i] = 255;
|
driverdata->key_pressed[i] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SDL_SendKeyboardKey(0, driverdata->keyboardID, SDL_PRESSED, SDL_RISCOS_translate_keycode(key));
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, SDL_RISCOS_translate_keycode(key));
|
||||||
|
|
||||||
/* Record the press so we can detect release later. */
|
/* Record the press so we can detect release later. */
|
||||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||||
@@ -126,12 +126,12 @@ void RISCOS_PollMouse(SDL_VideoDevice *_this)
|
|||||||
buttons = regs.r[2];
|
buttons = regs.r[2];
|
||||||
|
|
||||||
if (mouse->x != x || mouse->y != y) {
|
if (mouse->x != x || mouse->y != y) {
|
||||||
SDL_SendMouseMotion(0, mouse->focus, driverdata->mouseID, 0, (float)x, (float)y);
|
SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, (float)x, (float)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (driverdata->last_mouse_buttons != buttons) {
|
if (driverdata->last_mouse_buttons != buttons) {
|
||||||
for (i = 0; i < SDL_arraysize(mouse_button_map); i++) {
|
for (i = 0; i < SDL_arraysize(mouse_button_map); i++) {
|
||||||
SDL_SendMouseButton(0, mouse->focus, driverdata->mouseID, (buttons & (1 << i)) ? SDL_PRESSED : SDL_RELEASED, mouse_button_map[i]);
|
SDL_SendMouseButton(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, (buttons & (1 << i)) ? SDL_PRESSED : SDL_RELEASED, mouse_button_map[i]);
|
||||||
}
|
}
|
||||||
driverdata->last_mouse_buttons = buttons;
|
driverdata->last_mouse_buttons = buttons;
|
||||||
}
|
}
|
||||||
|
@@ -109,10 +109,8 @@ static int RISCOS_VideoInit(SDL_VideoDevice *_this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Assume we have a mouse and keyboard */
|
/* Assume we have a mouse and keyboard */
|
||||||
data->keyboardID = SDL_GetNextObjectID();
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddKeyboard(data->keyboardID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
data->mouseID = SDL_GetNextObjectID();
|
|
||||||
SDL_AddMouse(data->mouseID, NULL, SDL_FALSE);
|
|
||||||
|
|
||||||
if (RISCOS_InitModes(_this) < 0) {
|
if (RISCOS_InitModes(_this) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -29,8 +29,6 @@
|
|||||||
|
|
||||||
struct SDL_VideoData
|
struct SDL_VideoData
|
||||||
{
|
{
|
||||||
SDL_KeyboardID keyboardID;
|
|
||||||
SDL_MouseID mouseID;
|
|
||||||
int last_mouse_buttons;
|
int last_mouse_buttons;
|
||||||
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
|
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
|
||||||
};
|
};
|
||||||
|
@@ -158,7 +158,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
point.x -= origin.x;
|
point.x -= origin.x;
|
||||||
point.y -= origin.y;
|
point.y -= origin.y;
|
||||||
|
|
||||||
SDL_SendMouseMotion(0, sdlwindow, 0, 0, point.x, point.y);
|
SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, point.x, point.y);
|
||||||
}
|
}
|
||||||
return [UIPointerRegion regionWithRect:self.bounds identifier:nil];
|
return [UIPointerRegion regionWithRect:self.bounds identifier:nil];
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
button = (Uint8)i;
|
button = (Uint8)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, 0, SDL_PRESSED, button);
|
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_PRESSED, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
button = (Uint8)i;
|
button = (Uint8)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, 0, SDL_RELEASED, button);
|
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_RELEASED, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
if (!SDL_HasKeyboard()) {
|
if (!SDL_HasKeyboard()) {
|
||||||
for (UIPress *press in presses) {
|
for (UIPress *press in presses) {
|
||||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||||
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), 0, SDL_PRESSED, scancode);
|
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDL_TextInputActive()) {
|
if (SDL_TextInputActive()) {
|
||||||
@@ -427,7 +427,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
if (!SDL_HasKeyboard()) {
|
if (!SDL_HasKeyboard()) {
|
||||||
for (UIPress *press in presses) {
|
for (UIPress *press in presses) {
|
||||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||||
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), 0, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDL_TextInputActive()) {
|
if (SDL_TextInputActive()) {
|
||||||
@@ -440,7 +440,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||||||
if (!SDL_HasKeyboard()) {
|
if (!SDL_HasKeyboard()) {
|
||||||
for (UIPress *press in presses) {
|
for (UIPress *press in presses) {
|
||||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||||
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), 0, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDL_TextInputActive()) {
|
if (SDL_TextInputActive()) {
|
||||||
|
@@ -2709,7 +2709,7 @@ static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *too
|
|||||||
input->current_pen.update_window = window;
|
input->current_pen.update_window = window;
|
||||||
} else {
|
} else {
|
||||||
/* Plain mouse event */
|
/* Plain mouse event */
|
||||||
SDL_SendMouseMotion(0, window->sdlwindow, 0, SDL_FALSE, sx, sy);
|
SDL_SendMouseMotion(0, window->sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, sx, sy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -296,7 +296,7 @@ static void WIN_CheckRawMouseButtons(Uint64 timestamp, HANDLE hDevice, ULONG raw
|
|||||||
|
|
||||||
static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data)
|
static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data)
|
||||||
{
|
{
|
||||||
SDL_MouseID mouseID = data->videodata->mouseID;
|
SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID;
|
||||||
Uint32 mouseFlags;
|
Uint32 mouseFlags;
|
||||||
SHORT keyState;
|
SHORT keyState;
|
||||||
SDL_bool swapButtons;
|
SDL_bool swapButtons;
|
||||||
@@ -367,7 +367,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
|
|||||||
if (!SDL_GetMouse()->relative_mode) {
|
if (!SDL_GetMouse()->relative_mode) {
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
ScreenToClient(hwnd, &cursorPos);
|
ScreenToClient(hwnd, &cursorPos);
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data);
|
WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data);
|
||||||
@@ -508,9 +508,9 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
|
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
|
||||||
SDL_SendKeyboardKey(0, data->keyboardID, SDL_PRESSED, scanCode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scanCode);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(0, data->keyboardID, SDL_RELEASED, scanCode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scanCode);
|
||||||
|
|
||||||
/* If the key was down prior to our hook being installed, allow the
|
/* If the key was down prior to our hook being installed, allow the
|
||||||
key up message to pass normally the first time. This ensures other
|
key up message to pass normally the first time. This ensures other
|
||||||
@@ -752,7 +752,6 @@ static void GetDeviceName(HDEVINFO devinfo, const char *instance, char *name, si
|
|||||||
|
|
||||||
void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_check)
|
void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_check)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = _this->driverdata;
|
|
||||||
PRAWINPUTDEVICELIST raw_devices = NULL;
|
PRAWINPUTDEVICELIST raw_devices = NULL;
|
||||||
UINT raw_device_count = 0;
|
UINT raw_device_count = 0;
|
||||||
int old_keyboard_count = 0;
|
int old_keyboard_count = 0;
|
||||||
@@ -864,22 +863,12 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
|
|||||||
SDL_RemoveKeyboard(old_keyboards[i]);
|
SDL_RemoveKeyboard(old_keyboards[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new_keyboard_count > 0) {
|
|
||||||
data->keyboardID = new_keyboards[0];
|
|
||||||
} else {
|
|
||||||
data->keyboardID = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = old_mouse_count; i--;) {
|
for (int i = old_mouse_count; i--;) {
|
||||||
if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) {
|
if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) {
|
||||||
SDL_RemoveMouse(old_mice[i]);
|
SDL_RemoveMouse(old_mice[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new_mouse_count > 0) {
|
|
||||||
data->mouseID = new_mice[0];
|
|
||||||
} else {
|
|
||||||
data->mouseID = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_free(old_keyboards);
|
SDL_free(old_keyboards);
|
||||||
SDL_free(old_mice);
|
SDL_free(old_mice);
|
||||||
@@ -1001,7 +990,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
/* Only generate mouse events for real mouse */
|
/* Only generate mouse events for real mouse */
|
||||||
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
||||||
lParam != data->last_pointer_update) {
|
lParam != data->last_pointer_update) {
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -1023,7 +1012,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
if (!mouse->relative_mode || mouse->relative_mode_warp) {
|
if (!mouse->relative_mode || mouse->relative_mode_warp) {
|
||||||
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
||||||
lParam != data->last_pointer_update) {
|
lParam != data->last_pointer_update) {
|
||||||
WIN_CheckWParamMouseButtons(WIN_GetEventTimestamp(), wParam, data, data->videodata->mouseID);
|
WIN_CheckWParamMouseButtons(WIN_GetEventTimestamp(), wParam, data, SDL_GLOBAL_MOUSE_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -1061,9 +1050,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
short amount = GET_WHEEL_DELTA_WPARAM(wParam);
|
short amount = GET_WHEEL_DELTA_WPARAM(wParam);
|
||||||
float fAmount = (float)amount / WHEEL_DELTA;
|
float fAmount = (float)amount / WHEEL_DELTA;
|
||||||
if (msg == WM_MOUSEWHEEL) {
|
if (msg == WM_MOUSEWHEEL) {
|
||||||
SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@@ -1076,13 +1065,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
ScreenToClient(hwnd, &cursorPos);
|
ScreenToClient(hwnd, &cursorPos);
|
||||||
mouse = SDL_GetMouse();
|
mouse = SDL_GetMouse();
|
||||||
if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */
|
if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
||||||
} else { /* touch handling? */
|
} else { /* touch handling? */
|
||||||
mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */
|
mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */
|
||||||
if (mouse->touch_mouse_events) { /* convert touch to mouse events */
|
if (mouse->touch_mouse_events) { /* convert touch to mouse events */
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
||||||
} else { /* normal handling */
|
} else { /* normal handling */
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1115,7 +1104,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (code != SDL_SCANCODE_UNKNOWN) {
|
if (code != SDL_SCANCODE_UNKNOWN) {
|
||||||
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_PRESSED, code);
|
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1131,9 +1120,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
if (code != SDL_SCANCODE_UNKNOWN) {
|
if (code != SDL_SCANCODE_UNKNOWN) {
|
||||||
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
||||||
keyboardState[code] == SDL_RELEASED) {
|
keyboardState[code] == SDL_RELEASED) {
|
||||||
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_PRESSED, code);
|
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, code);
|
||||||
}
|
}
|
||||||
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_RELEASED, code);
|
SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
@@ -1850,7 +1839,7 @@ static void WIN_UpdateMouseCapture()
|
|||||||
|
|
||||||
if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) {
|
if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) {
|
||||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||||
SDL_MouseID mouseID = data->videodata->mouseID;
|
SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID;
|
||||||
|
|
||||||
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
||||||
SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED,
|
SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED,
|
||||||
@@ -2000,10 +1989,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this)
|
|||||||
and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */
|
and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */
|
||||||
keystate = SDL_GetKeyboardState(NULL);
|
keystate = SDL_GetKeyboardState(NULL);
|
||||||
if ((keystate[SDL_SCANCODE_LSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
|
if ((keystate[SDL_SCANCODE_LSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
|
||||||
SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
|
if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
|
||||||
SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts and
|
/* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts and
|
||||||
@@ -2012,10 +2001,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this)
|
|||||||
focusWindow = SDL_GetKeyboardFocus();
|
focusWindow = SDL_GetKeyboardFocus();
|
||||||
if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) {
|
if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) {
|
||||||
if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) {
|
if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) {
|
||||||
SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_LGUI);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_LGUI);
|
||||||
}
|
}
|
||||||
if ((keystate[SDL_SCANCODE_RGUI] == SDL_PRESSED) && !(GetKeyState(VK_RWIN) & 0x8000)) {
|
if ((keystate[SDL_SCANCODE_RGUI] == SDL_PRESSED) && !(GetKeyState(VK_RWIN) & 0x8000)) {
|
||||||
SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_RGUI);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_RGUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -493,7 +493,7 @@ static int WIN_WarpMouse(SDL_Window *window, float x, float y)
|
|||||||
WIN_SetCursorPos(pt.x, pt.y);
|
WIN_SetCursorPos(pt.x, pt.y);
|
||||||
|
|
||||||
/* Send the exact mouse motion associated with this warp */
|
/* Send the exact mouse motion associated with this warp */
|
||||||
SDL_SendMouseMotion(0, window, data->videodata->mouseID, SDL_FALSE, x, y);
|
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -373,9 +373,6 @@ struct SDL_VideoData
|
|||||||
{
|
{
|
||||||
int render;
|
int render;
|
||||||
|
|
||||||
SDL_KeyboardID keyboardID;
|
|
||||||
SDL_MouseID mouseID;
|
|
||||||
|
|
||||||
DWORD clipboard_count;
|
DWORD clipboard_count;
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/
|
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/
|
||||||
|
@@ -24,9 +24,6 @@ extern "C" {
|
|||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WINRT_KEYBOARD_ID 1
|
|
||||||
#define WINRT_MOUSE_ID 1
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal-use, C-style functions:
|
* Internal-use, C-style functions:
|
||||||
*/
|
*/
|
||||||
|
@@ -77,7 +77,7 @@ void WINRT_ProcessAcceleratorKeyActivated(Windows::UI::Core::AcceleratorKeyEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
code = WINRT_TranslateKeycode(args->VirtualKey, args->KeyStatus);
|
code = WINRT_TranslateKeycode(args->VirtualKey, args->KeyStatus);
|
||||||
SDL_SendKeyboardKey(0, WINRT_KEYBOARD_ID, state, code);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, state, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI::Core::CharacterReceivedEventArgs ^ args)
|
void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI::Core::CharacterReceivedEventArgs ^ args)
|
||||||
|
@@ -220,7 +220,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
|
|||||||
Uint8 button, pressed;
|
Uint8 button, pressed;
|
||||||
WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
||||||
SDL_assert(pressed == 1);
|
SDL_assert(pressed == 1);
|
||||||
SDL_SendMouseButton(0, window, WINRT_MOUSE_ID, SDL_PRESSED, button);
|
SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_PRESSED, button);
|
||||||
} else {
|
} else {
|
||||||
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|
||||||
Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
|
Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
|
||||||
@@ -249,10 +249,10 @@ void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::Poin
|
|||||||
/* For some odd reason Moved events are used for multiple mouse buttons */
|
/* For some odd reason Moved events are used for multiple mouse buttons */
|
||||||
Uint8 button, pressed;
|
Uint8 button, pressed;
|
||||||
if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) {
|
if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) {
|
||||||
SDL_SendMouseButton(0, window, WINRT_MOUSE_ID, pressed, button);
|
SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, pressed, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendMouseMotion(0, window, WINRT_MOUSE_ID, SDL_FALSE, windowPoint.X, windowPoint.Y);
|
SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, windowPoint.X, windowPoint.Y);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendTouchMotion(0,
|
SDL_SendTouchMotion(0,
|
||||||
WINRT_TouchID,
|
WINRT_TouchID,
|
||||||
@@ -274,7 +274,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
|
|||||||
Uint8 button, pressed;
|
Uint8 button, pressed;
|
||||||
WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
||||||
SDL_assert(pressed == 0);
|
SDL_assert(pressed == 0);
|
||||||
SDL_SendMouseButton(0, window, WINRT_MOUSE_ID, SDL_RELEASED, button);
|
SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_RELEASED, button);
|
||||||
} else {
|
} else {
|
||||||
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Inpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
float motion = (float)pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
|
float motion = (float)pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
|
||||||
SDL_SendMouseWheel(0, window, WINRT_MOUSE_ID, 0.0f, motion, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(0, window, SDL_DEFAULT_MOUSE_ID, 0.0f, motion, SDL_MOUSEWHEEL_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args)
|
void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args)
|
||||||
@@ -383,7 +383,7 @@ void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::M
|
|||||||
//
|
//
|
||||||
const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
|
const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
|
||||||
const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);
|
const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);
|
||||||
SDL_SendMouseMotion(0, window, WINRT_MOUSE_ID, SDL_TRUE, mouseDeltaInSDLWindowCoords.X, mouseDeltaInSDLWindowCoords.Y);
|
SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, SDL_TRUE, mouseDeltaInSDLWindowCoords.X, mouseDeltaInSDLWindowCoords.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SDL_VIDEO_DRIVER_WINRT
|
#endif // SDL_VIDEO_DRIVER_WINRT
|
||||||
|
@@ -240,8 +240,8 @@ int WINRT_VideoInit(SDL_VideoDevice *_this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Assume we have a mouse and keyboard */
|
/* Assume we have a mouse and keyboard */
|
||||||
SDL_AddKeyboard(WINRT_KEYBOARD_ID, NULL, SDL_FALSE);
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddMouse(WINRT_MOUSE_ID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -437,13 +437,13 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this)
|
|||||||
case SDLK_LGUI:
|
case SDLK_LGUI:
|
||||||
case SDLK_RGUI:
|
case SDLK_RGUI:
|
||||||
case SDLK_MODE:
|
case SDLK_MODE:
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_PRESSED, scancode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!x11KeyPressed && sdlKeyPressed) {
|
} else if (!x11KeyPressed && sdlKeyPressed) {
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -957,9 +957,9 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
videodata->filter_time = xevent->xkey.time;
|
videodata->filter_time = xevent->xkey.time;
|
||||||
|
|
||||||
if (orig_event_type == KeyPress) {
|
if (orig_event_type == KeyPress) {
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_PRESSED, scancode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode);
|
||||||
} else {
|
} else {
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_RELEASED, scancode);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1106,7 +1106,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!mouse->relative_mode) {
|
if (!mouse->relative_mode) {
|
||||||
SDL_SendMouseMotion(0, data->window, videodata->mouseID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y);
|
SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We ungrab in LeaveNotify, so we may need to grab again here */
|
/* We ungrab in LeaveNotify, so we may need to grab again here */
|
||||||
@@ -1130,7 +1130,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!SDL_GetMouse()->relative_mode) {
|
if (!SDL_GetMouse()->relative_mode) {
|
||||||
SDL_SendMouseMotion(0, data->window, videodata->mouseID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y);
|
SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xevent->xcrossing.mode != NotifyGrab &&
|
if (xevent->xcrossing.mode != NotifyGrab &&
|
||||||
@@ -1262,7 +1262,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
if (xevent->type == KeyPress) {
|
if (xevent->type == KeyPress) {
|
||||||
/* Don't send the key if it looks like a duplicate of a filtered key sent by an IME */
|
/* Don't send the key if it looks like a duplicate of a filtered key sent by an IME */
|
||||||
if (xevent->xkey.keycode != videodata->filter_code || xevent->xkey.time != videodata->filter_time) {
|
if (xevent->xkey.keycode != videodata->filter_code || xevent->xkey.time != videodata->filter_time) {
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_PRESSED, videodata->key_layout[keycode]);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, videodata->key_layout[keycode]);
|
||||||
}
|
}
|
||||||
if (*text) {
|
if (*text) {
|
||||||
SDL_SendKeyboardText(text);
|
SDL_SendKeyboardText(text);
|
||||||
@@ -1272,7 +1272,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
/* We're about to get a repeated key down, ignore the key up */
|
/* We're about to get a repeated key down, ignore the key up */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_RELEASED, videodata->key_layout[keycode]);
|
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, videodata->key_layout[keycode]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,19 +1525,19 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
X11_ProcessHitTest(_this, data, (float)xevent->xmotion.x, (float)xevent->xmotion.y, SDL_FALSE);
|
X11_ProcessHitTest(_this, data, (float)xevent->xmotion.x, (float)xevent->xmotion.y, SDL_FALSE);
|
||||||
SDL_SendMouseMotion(0, data->window, videodata->mouseID, SDL_FALSE, (float)xevent->xmotion.x, (float)xevent->xmotion.y);
|
SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xmotion.x, (float)xevent->xmotion.y);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
{
|
{
|
||||||
X11_HandleButtonPress(_this, data, videodata->mouseID, xevent->xbutton.button,
|
X11_HandleButtonPress(_this, data, SDL_GLOBAL_MOUSE_ID, xevent->xbutton.button,
|
||||||
xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.time);
|
xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.time);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
{
|
{
|
||||||
X11_HandleButtonRelease(_this, data, videodata->mouseID, xevent->xbutton.button);
|
X11_HandleButtonRelease(_this, data, SDL_GLOBAL_MOUSE_ID, xevent->xbutton.button);
|
||||||
} break;
|
} break;
|
||||||
#endif /* !SDL_VIDEO_DRIVER_X11_XINPUT2 */
|
#endif /* !SDL_VIDEO_DRIVER_X11_XINPUT2 */
|
||||||
|
|
||||||
|
@@ -419,10 +419,8 @@ int X11_VideoInit(SDL_VideoDevice *_this)
|
|||||||
|
|
||||||
if (!X11_InitXinput2(_this)) {
|
if (!X11_InitXinput2(_this)) {
|
||||||
/* Assume a mouse and keyboard are attached */
|
/* Assume a mouse and keyboard are attached */
|
||||||
data->keyboardID = SDL_GetNextObjectID();
|
SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE);
|
||||||
SDL_AddKeyboard(data->keyboardID, NULL, SDL_FALSE);
|
SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE);
|
||||||
data->mouseID = SDL_GetNextObjectID();
|
|
||||||
SDL_AddMouse(data->mouseID, NULL, SDL_FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
|
#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
|
||||||
|
@@ -110,9 +110,6 @@ struct SDL_VideoData
|
|||||||
SDL_Point global_mouse_position;
|
SDL_Point global_mouse_position;
|
||||||
Uint32 global_mouse_buttons;
|
Uint32 global_mouse_buttons;
|
||||||
|
|
||||||
SDL_KeyboardID keyboardID;
|
|
||||||
SDL_MouseID mouseID;
|
|
||||||
|
|
||||||
SDL_XInput2DeviceInfo *mouse_device_info;
|
SDL_XInput2DeviceInfo *mouse_device_info;
|
||||||
|
|
||||||
int xrandr_event_base;
|
int xrandr_event_base;
|
||||||
|
@@ -107,14 +107,12 @@ static void xinput2_init_device_list(SDL_VideoData *videodata)
|
|||||||
|
|
||||||
switch (dev->use) {
|
switch (dev->use) {
|
||||||
case XIMasterKeyboard:
|
case XIMasterKeyboard:
|
||||||
videodata->keyboardID = (SDL_KeyboardID)dev->deviceid;
|
|
||||||
SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE);
|
SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE);
|
||||||
break;
|
break;
|
||||||
case XISlaveKeyboard:
|
case XISlaveKeyboard:
|
||||||
SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE);
|
SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE);
|
||||||
break;
|
break;
|
||||||
case XIMasterPointer:
|
case XIMasterPointer:
|
||||||
videodata->mouseID = (SDL_MouseID)dev->deviceid;
|
|
||||||
SDL_AddMouse((SDL_MouseID)dev->deviceid, dev->name, SDL_FALSE);
|
SDL_AddMouse((SDL_MouseID)dev->deviceid, dev->name, SDL_FALSE);
|
||||||
break;
|
break;
|
||||||
case XISlavePointer:
|
case XISlavePointer:
|
||||||
@@ -407,7 +405,7 @@ int X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendMouseMotion(0, mouse->focus, videodata->mouseID, SDL_TRUE, (float)processed_coords[0], (float)processed_coords[1]);
|
SDL_SendMouseMotion(0, mouse->focus, (SDL_MouseID)rawev->sourceid, SDL_TRUE, (float)processed_coords[0], (float)processed_coords[1]);
|
||||||
devinfo->prev_coords[0] = coords[0];
|
devinfo->prev_coords[0] = coords[0];
|
||||||
devinfo->prev_coords[1] = coords[1];
|
devinfo->prev_coords[1] = coords[1];
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user