diff --git a/src/core/haiku/SDL_BApp.h b/src/core/haiku/SDL_BApp.h index 54f98b267f..484b0f3c8b 100644 --- a/src/core/haiku/SDL_BApp.h +++ b/src/core/haiku/SDL_BApp.h @@ -46,8 +46,6 @@ extern "C" { #include -#define BAPP_KEYBOARD_ID 1 -#define BAPP_MOUSE_ID 1 /* Forward declarations */ class SDL_BLooper; @@ -251,12 +249,12 @@ class SDL_BLooper : public BLooper SDL_GetWindowPosition(win, &winPosX, &winPosY); int dx = x - (winWidth / 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)); if (!be_app->IsCursorHidden()) be_app->HideCursor(); } 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()) be_app->ShowCursor(); } @@ -274,7 +272,7 @@ class SDL_BLooper : public BLooper return; } 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) @@ -289,7 +287,7 @@ class SDL_BLooper : public BLooper return; } 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) @@ -306,7 +304,7 @@ class SDL_BLooper : public BLooper return; } 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)) { const int8 *keyUtf8; diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 0565d4f855..013d03e2eb 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -538,7 +538,7 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr */ #if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION >= NTDDI_WINBLUE 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 /* 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 static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args) { - SDL_SendKeyboardKey(0, 0, SDL_PRESSED, SDL_SCANCODE_AC_BACK); - SDL_SendKeyboardKey(0, 0, SDL_RELEASED, SDL_SCANCODE_AC_BACK); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, 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)) { args->Handled = true; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 577e6ba5f1..3ef19e6506 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -804,7 +804,7 @@ void SDL_ResetKeyboard(void) #endif for (scancode = (SDL_Scancode)0; scancode < SDL_NUM_SCANCODES; ++scancode) { 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; 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) { return 0; } @@ -1099,23 +1102,23 @@ int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch) if (mod & SDL_KMOD_SHIFT) { /* 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 */ - SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, 0, 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_PRESSED, code, SDLK_UNKNOWN); + SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, code, SDLK_UNKNOWN); if (mod & SDL_KMOD_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; } 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) @@ -1130,7 +1133,7 @@ int SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboardID, U 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) @@ -1146,7 +1149,7 @@ void SDL_ReleaseAutoReleaseKeys(void) if (keyboard->autorelease_pending) { for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { 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; diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index b44ec8276f..323b139d1c 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -23,6 +23,12 @@ #ifndef 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 */ extern int SDL_InitKeyboard(void); diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 1edaab464f..3346325a21 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -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"); #endif 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); } @@ -520,7 +520,7 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3 #endif SDL_SetMouseFocus(window); 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; @@ -691,6 +691,11 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ float xrel = 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 */ if (mouse->mouse_touch_events) { 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; 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); if (!source) { 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->WarpMouse(window, x, y); } else { - SDL_PrivateSendMouseMotion(0, window, 0, SDL_FALSE, x, y); + SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); } } diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index f02811a5ef..0603577fab 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -23,6 +23,12 @@ #ifndef SDL_mouse_c_h_ #define SDL_mouse_c_h_ +/* Mouse events not associated with a specific input device */ +#define SDL_GLOBAL_MOUSE_ID 0 + +/* The default mouse input device, for platforms that don't have multiple mice */ +#define SDL_DEFAULT_MOUSE_ID 1 + struct SDL_Cursor { struct SDL_Cursor *next; diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index c6408c0676..9afd002cf9 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -205,7 +205,7 @@ int Android_OnPadDown(int device_id, int keycode) if (item && item->joystick) { SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_PRESSED); } 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(); return 0; @@ -225,7 +225,7 @@ int Android_OnPadUp(int device_id, int keycode) if (item && item->joystick) { SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_RELEASED); } 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(); return 0; diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index cff44ed613..1422622a8e 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -330,12 +330,12 @@ static SDL_Scancode TranslateKeycode(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) { - 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) diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 122fece95f..84c15e50a5 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -221,25 +221,25 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y changes = state & ~last_state; button = TranslateButton(changes); last_state = state; - SDL_SendMouseMotion(0, window, Android_MouseID, relative, x, y); - SDL_SendMouseButton(0, window, Android_MouseID, SDL_PRESSED, button); + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y); + SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_PRESSED, button); break; case ACTION_UP: changes = last_state & ~state; button = TranslateButton(changes); last_state = state; - SDL_SendMouseMotion(0, window, Android_MouseID, relative, x, y); - SDL_SendMouseButton(0, window, Android_MouseID, SDL_RELEASED, button); + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y); + SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_RELEASED, button); break; case ACTION_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; 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; default: diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 3a0686ce8a..17f7e57048 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -67,8 +67,6 @@ SDL_Semaphore *Android_PauseSem = NULL; SDL_Semaphore *Android_ResumeSem = NULL; SDL_Mutex *Android_ActivityMutex = NULL; static SDL_SystemTheme Android_SystemTheme; -SDL_KeyboardID Android_KeyboardID = 0; -SDL_MouseID Android_MouseID = 0; static int Android_SuspendScreenSaver(SDL_VideoDevice *_this) { diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h index ebda0cc200..f6dd54eb56 100644 --- a/src/video/android/SDL_androidvideo.h +++ b/src/video/android/SDL_androidvideo.h @@ -46,7 +46,5 @@ extern int Android_SurfaceHeight; extern float Android_ScreenDensity; extern SDL_Semaphore *Android_PauseSem, *Android_ResumeSem; extern SDL_Mutex *Android_ActivityMutex; -extern SDL_KeyboardID Android_KeyboardID; -extern SDL_MouseID Android_MouseID; #endif /* SDL_androidvideo_h_ */ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 99dfb99318..fc12196c8d 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -200,7 +200,6 @@ static bool IsModifierKeyPressed(unsigned int flags, static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned int modifierFlags) { - SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata; bool pressed = false; if (code == SDL_SCANCODE_LSHIFT) { @@ -232,9 +231,9 @@ static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned } if (pressed) { - SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_PRESSED, code); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, code); } 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); } - 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 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 or to Christian Walther . Mac virtual key code is %d.\n", scancode); @@ -434,7 +433,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) } break; 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; case NSEventTypeFlagsChanged: { // see if the new modifierFlags mean any existing keys should be pressed/released... diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 727912cae5..eef892a67c 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -302,7 +302,7 @@ static int Cocoa_WarpMouseGlobal(float x, float y) SDL_SetMouseFocus(win); if (win) { 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) { - SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata; - SDL_MouseID mouseID = videodata.mouseID; + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; SDL_Mouse *mouse; SDL_MouseData *driverdata; NSPoint location; @@ -529,8 +528,7 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) { - SDL_CocoaVideoData *videodata = ((__bridge SDL_CocoaWindowData *)window->driverdata).videodata; - SDL_MouseID mouseID = videodata.mouseID; + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; SDL_MouseWheelDirection direction; CGFloat x, y; diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index a35063a6a2..2929fe0ad1 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -101,8 +101,6 @@ DECLARE_ALERT_STYLE(Critical); @property(nonatomic) int trackpad_is_touch_only; @property(nonatomic) unsigned int modifierFlags; @property(nonatomic) void *key_layout; -@property(nonatomic) SDL_KeyboardID keyboardID; -@property(nonatomic) SDL_MouseID mouseID; @property(nonatomic) SDLTranslatorResponder *fieldEdit; @property(nonatomic) NSInteger clipboard_count; @property(nonatomic) IOPMAssertionID screensaver_assertion; diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index eb96d35266..ae4bbcfbf0 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -203,10 +203,8 @@ int Cocoa_VideoInit(SDL_VideoDevice *_this) // Assume we have a mouse and keyboard // We could use GCMouse and GCKeyboard if we needed to, as is done in SDL_uikitevents.m - data.keyboardID = SDL_GetNextObjectID(); - SDL_AddKeyboard(data.keyboardID, NULL, SDL_FALSE); - data.mouseID = SDL_GetNextObjectID(); - SDL_AddMouse(data.mouseID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); 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); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 0a43da32c0..03fdfbe1c8 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -210,7 +210,7 @@ x = point.x; y = (sdlwindow->h - point.y); 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 */ @@ -1089,7 +1089,7 @@ static SDL_bool Cocoa_IsZoomed(SDL_Window *window) y = (window->h - point.y); 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 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 sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? SDL_TRUE : SDL_FALSE; if (osenabled ^ sdlenabled) { - SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); - SDL_SendKeyboardKey(0, videodata.keyboardID, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); } } - (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) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata; - SDL_MouseID mouseID = videodata.mouseID; + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; const int clicks = (int)[theEvent clickCount]; SDL_Window *focus = SDL_GetKeyboardFocus(); int rc; @@ -1591,9 +1587,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ - (void)mouseMoved:(NSEvent *)theEvent { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata; - SDL_MouseID mouseID = videodata.mouseID; + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; SDL_Mouse *mouse = SDL_GetMouse(); NSPoint point; float x, y; diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index e7f2c1d3f8..7bf4e76ca3 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -631,7 +631,7 @@ static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEv 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; } @@ -669,7 +669,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse sdl_event_type = SDL_EVENT_MOUSE_BUTTON_UP; 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. */ 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)); 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); @@ -720,7 +720,7 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent 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); } @@ -811,7 +811,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent } 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 diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 1437b0a669..8e220d29e9 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -137,8 +137,8 @@ int Emscripten_VideoInit(SDL_VideoDevice *_this) Emscripten_InitMouse(); /* Assume we have a mouse and keyboard */ - SDL_AddKeyboard(EMSCRIPTEN_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(EMSCRIPTEN_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); /* We're done! */ return 0; diff --git a/src/video/emscripten/SDL_emscriptenvideo.h b/src/video/emscripten/SDL_emscriptenvideo.h index 094f9b1508..4417205850 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.h +++ b/src/video/emscripten/SDL_emscriptenvideo.h @@ -28,9 +28,6 @@ #include #include -#define EMSCRIPTEN_KEYBOARD_ID 1 -#define EMSCRIPTEN_MOUSE_ID 1 - struct SDL_WindowData { SDL_Window *window; diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 9720e41d64..9b8f1c949f 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -282,8 +282,8 @@ int HAIKU_VideoInit(SDL_VideoDevice *_this) HAIKU_MouseInit(_this); /* Assume we have a mouse and keyboard */ - SDL_AddKeyboard(BAPP_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(BAPP_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); #ifdef SDL_VIDEO_OPENGL /* testgl application doesn't load library, just tries to load symbols */ diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 9270afb119..31a3131cb1 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -351,7 +351,7 @@ static int KMSDRM_WarpMouseGlobal(float x, float y) SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); /* 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. */ if (dispdata->cursor_bo) { diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp index 4977516c7c..86deba4757 100644 --- a/src/video/ngage/SDL_ngageevents.cpp +++ b/src/video/ngage/SDL_ngageevents.cpp @@ -154,10 +154,10 @@ int HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent) switch (aWsEvent.Type()) { 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; 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; case EEventFocusGained: /* SDL window got focus */ data->NGAGE_IsWindowFocused = ETrue; diff --git a/src/video/ngage/SDL_ngagevideo.h b/src/video/ngage/SDL_ngagevideo.h index d3e3a7cfdb..39dbed8a01 100644 --- a/src/video/ngage/SDL_ngagevideo.h +++ b/src/video/ngage/SDL_ngagevideo.h @@ -60,9 +60,6 @@ struct SDL_VideoData TPoint NGAGE_ScreenOffset; CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation; - - SDL_KeyboardID keyboardID; - SDL_MouseID mouseID; }; #endif /* SDL_ngagevideo_h */ diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index 5cf7e66f25..64b17ae9b8 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -90,7 +90,7 @@ void PSP_PumpEvents(SDL_VideoDevice *_this) if (changed) { for (i = 0; i < sizeof(keymap_psp) / sizeof(keymap_psp[0]); i++) { 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]; /* not tested */ /* 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])); } } } diff --git a/src/video/qnx/SDL_qnx.h b/src/video/qnx/SDL_qnx.h index 1a9826bb5d..368f84000f 100644 --- a/src/video/qnx/SDL_qnx.h +++ b/src/video/qnx/SDL_qnx.h @@ -33,9 +33,6 @@ typedef struct EGLConfig conf; } window_impl_t; -#define QNX_KEYBOARD_ID 1 -#define QNX_MOUSE_ID 1 - extern void handleKeyboardEvent(screen_event_t event); extern int glGetConfig(EGLConfig *pconf, int *pformat); diff --git a/src/video/qnx/SDL_qnxkeyboard.c b/src/video/qnx/SDL_qnxkeyboard.c index 453a02801c..61b0e5aabf 100644 --- a/src/video/qnx/SDL_qnxkeyboard.c +++ b/src/video/qnx/SDL_qnxkeyboard.c @@ -125,8 +125,8 @@ void handleKeyboardEvent(screen_event_t event) // FIXME: // Need to handle more key states (such as key combinations). if (val & KEY_DOWN) { - SDL_SendKeyboardKey(0, QNX_KEYBOARD_ID, SDL_PRESSED, scancode); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_PRESSED, scancode); } else { - SDL_SendKeyboardKey(0, QNX_KEYBOARD_ID, SDL_RELEASED, scancode); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, SDL_RELEASED, scancode); } } diff --git a/src/video/qnx/SDL_qnxvideo.c b/src/video/qnx/SDL_qnxvideo.c index 43e8a5ec0b..6a646832b5 100644 --- a/src/video/qnx/SDL_qnxvideo.c +++ b/src/video/qnx/SDL_qnxvideo.c @@ -53,8 +53,8 @@ static int videoInit(SDL_VideoDevice *_this) } /* Assume we have a mouse and keyboard */ - SDL_AddKeyboard(QNX_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(QNX_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); return 0; } diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index c834037e56..aa16a5d36b 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -276,7 +276,7 @@ static int RPI_WarpMouseGlobal(float x, float y) } /* 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); } diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index 8c6403f5dc..3771fe5912 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -58,7 +58,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this) for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { if (driverdata->key_pressed[i] != 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; } } @@ -81,7 +81,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this) break; 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. */ for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { @@ -126,12 +126,12 @@ void RISCOS_PollMouse(SDL_VideoDevice *_this) buttons = regs.r[2]; 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) { 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; } diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 2068f17c4a..baaeb67191 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -109,10 +109,8 @@ static int RISCOS_VideoInit(SDL_VideoDevice *_this) } /* Assume we have a mouse and keyboard */ - data->keyboardID = SDL_GetNextObjectID(); - SDL_AddKeyboard(data->keyboardID, NULL, SDL_FALSE); - data->mouseID = SDL_GetNextObjectID(); - SDL_AddMouse(data->mouseID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); if (RISCOS_InitModes(_this) < 0) { return -1; diff --git a/src/video/riscos/SDL_riscosvideo.h b/src/video/riscos/SDL_riscosvideo.h index c05598d9c6..986bcc2ff1 100644 --- a/src/video/riscos/SDL_riscosvideo.h +++ b/src/video/riscos/SDL_riscosvideo.h @@ -29,8 +29,6 @@ struct SDL_VideoData { - SDL_KeyboardID keyboardID; - SDL_MouseID mouseID; int last_mouse_buttons; Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED]; }; diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 3bd4d46943..0db9d3be4f 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -158,7 +158,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; point.x -= origin.x; 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]; } @@ -250,7 +250,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; button = (Uint8)i; 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; 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()) { for (UIPress *press in presses) { 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()) { @@ -427,7 +427,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; if (!SDL_HasKeyboard()) { for (UIPress *press in presses) { 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()) { @@ -440,7 +440,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; if (!SDL_HasKeyboard()) { for (UIPress *press in presses) { 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()) { diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index a6f94d01b0..1d72eaeb41 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -2709,7 +2709,7 @@ static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *too input->current_pen.update_window = window; } else { /* 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); } } } diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 11f31eb303..d0efa67d49 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -296,7 +296,7 @@ static void WIN_CheckRawMouseButtons(Uint64 timestamp, HANDLE hDevice, ULONG raw static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data) { - SDL_MouseID mouseID = data->videodata->mouseID; + SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID; Uint32 mouseFlags; SHORT keyState; SDL_bool swapButtons; @@ -367,7 +367,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) if (!SDL_GetMouse()->relative_mode) { GetCursorPos(&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); @@ -508,9 +508,9 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) } 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 { - 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 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) { - SDL_VideoData *data = _this->driverdata; PRAWINPUTDEVICELIST raw_devices = NULL; UINT raw_device_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]); } } - if (new_keyboard_count > 0) { - data->keyboardID = new_keyboards[0]; - } else { - data->keyboardID = 0; - } for (int i = old_mouse_count; i--;) { if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) { 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_mice); @@ -1001,7 +990,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara /* Only generate mouse events for real mouse */ if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH && 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; @@ -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 (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH && 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; @@ -1061,9 +1050,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara short amount = GET_WHEEL_DELTA_WPARAM(wParam); float fAmount = (float)amount / WHEEL_DELTA; 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 { - 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; @@ -1076,13 +1065,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara ScreenToClient(hwnd, &cursorPos); mouse = SDL_GetMouse(); 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? */ mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */ 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); } 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) { - 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_PRINTSCREEN && 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; @@ -1850,7 +1839,7 @@ static void WIN_UpdateMouseCapture() if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) { 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_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. */ keystate = SDL_GetKeyboardState(NULL); 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)) { - 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 @@ -2012,10 +2001,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) focusWindow = SDL_GetKeyboardFocus(); if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { 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)) { - SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_RGUI); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_RGUI); } } diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 85e7263664..5485f02132 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -493,7 +493,7 @@ static int WIN_WarpMouse(SDL_Window *window, float x, float y) WIN_SetCursorPos(pt.x, pt.y); /* 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; } diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index b6113b5206..4b3d3c27ac 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -373,9 +373,6 @@ struct SDL_VideoData { int render; - SDL_KeyboardID keyboardID; - SDL_MouseID mouseID; - DWORD clipboard_count; #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/ diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h index cd6ce2e22a..e77e37d90e 100644 --- a/src/video/winrt/SDL_winrtevents_c.h +++ b/src/video/winrt/SDL_winrtevents_c.h @@ -24,9 +24,6 @@ extern "C" { #include "../SDL_sysvideo.h" } -#define WINRT_KEYBOARD_ID 1 -#define WINRT_MOUSE_ID 1 - /* * Internal-use, C-style functions: */ diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp index ab320779d8..6f088ec172 100644 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/src/video/winrt/SDL_winrtkeyboard.cpp @@ -77,7 +77,7 @@ void WINRT_ProcessAcceleratorKeyActivated(Windows::UI::Core::AcceleratorKeyEvent } 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) diff --git a/src/video/winrt/SDL_winrtpointerinput.cpp b/src/video/winrt/SDL_winrtpointerinput.cpp index 1fa6abc28a..dd3c9b2b3a 100644 --- a/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/src/video/winrt/SDL_winrtpointerinput.cpp @@ -220,7 +220,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po Uint8 button, pressed; WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed); 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 { Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); 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 */ Uint8 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 { SDL_SendTouchMotion(0, WINRT_TouchID, @@ -274,7 +274,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P Uint8 button, pressed; WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed); 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 { 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; - 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) @@ -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 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 diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index b40681852a..b8c65c0d30 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -240,8 +240,8 @@ int WINRT_VideoInit(SDL_VideoDevice *_this) } /* Assume we have a mouse and keyboard */ - SDL_AddKeyboard(WINRT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(WINRT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); return 0; } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 3766515796..c170a59f5b 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -437,13 +437,13 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this) case SDLK_LGUI: case SDLK_RGUI: case SDLK_MODE: - SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_PRESSED, scancode); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode); break; default: break; } } 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; if (orig_event_type == KeyPress) { - SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_PRESSED, scancode); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scancode); } else { - SDL_SendKeyboardKey(0, videodata->keyboardID, SDL_RELEASED, scancode); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scancode); } #endif } @@ -1106,7 +1106,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #endif 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 */ @@ -1130,7 +1130,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #endif 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 && @@ -1262,7 +1262,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (xevent->type == KeyPress) { /* 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) { - 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) { 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 */ 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 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; 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); } break; case ButtonRelease: { - X11_HandleButtonRelease(_this, data, videodata->mouseID, xevent->xbutton.button); + X11_HandleButtonRelease(_this, data, SDL_GLOBAL_MOUSE_ID, xevent->xbutton.button); } break; #endif /* !SDL_VIDEO_DRIVER_X11_XINPUT2 */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 662e96cf46..e63be44a03 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -419,10 +419,8 @@ int X11_VideoInit(SDL_VideoDevice *_this) if (!X11_InitXinput2(_this)) { /* Assume a mouse and keyboard are attached */ - data->keyboardID = SDL_GetNextObjectID(); - SDL_AddKeyboard(data->keyboardID, NULL, SDL_FALSE); - data->mouseID = SDL_GetNextObjectID(); - SDL_AddMouse(data->mouseID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); } #ifdef SDL_VIDEO_DRIVER_X11_XFIXES diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 30780098c0..e199dd5169 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -110,9 +110,6 @@ struct SDL_VideoData SDL_Point global_mouse_position; Uint32 global_mouse_buttons; - SDL_KeyboardID keyboardID; - SDL_MouseID mouseID; - SDL_XInput2DeviceInfo *mouse_device_info; int xrandr_event_base; diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index f3029949d5..03bb87cd23 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -107,14 +107,12 @@ static void xinput2_init_device_list(SDL_VideoData *videodata) switch (dev->use) { case XIMasterKeyboard: - videodata->keyboardID = (SDL_KeyboardID)dev->deviceid; SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE); break; case XISlaveKeyboard: SDL_AddKeyboard((SDL_KeyboardID)dev->deviceid, dev->name, SDL_FALSE); break; case XIMasterPointer: - videodata->mouseID = (SDL_MouseID)dev->deviceid; SDL_AddMouse((SDL_MouseID)dev->deviceid, dev->name, SDL_FALSE); break; 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[1] = coords[1]; return 1;