Use the correct device ID (global or default or specific) based on context

main
Sam Lantinga 2024-03-22 10:49:07 -07:00
parent 9eb87ca325
commit 35756593d6
44 changed files with 143 additions and 174 deletions

View File

@ -46,8 +46,6 @@ extern "C" {
#include <vector>
#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;

View File

@ -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 <typename BackButtonEventArgs>
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;

View File

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

View File

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

View File

@ -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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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_ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,9 +28,6 @@
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
#define EMSCRIPTEN_KEYBOARD_ID 1
#define EMSCRIPTEN_MOUSE_ID 1
struct SDL_WindowData
{
SDL_Window *window;

View File

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

View File

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

View File

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

View File

@ -60,9 +60,6 @@ struct SDL_VideoData
TPoint NGAGE_ScreenOffset;
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
SDL_KeyboardID keyboardID;
SDL_MouseID mouseID;
};
#endif /* SDL_ngagevideo_h */

View File

@ -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]));
}
}
}

View File

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

View File

@ -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);
}
}

View File

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

View File

@ -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);
}

View File

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

View File

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

View File

@ -29,8 +29,6 @@
struct SDL_VideoData
{
SDL_KeyboardID keyboardID;
SDL_MouseID mouseID;
int last_mouse_buttons;
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
};

View File

@ -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()) {

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

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

View File

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

View File

@ -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:
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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