Initial support for hotplugging mice and keyboards

This commit is contained in:
Sam Lantinga
2024-03-20 06:58:00 -07:00
parent c33e4c998d
commit 2fe1a6a279
44 changed files with 961 additions and 321 deletions

View File

@@ -1661,6 +1661,14 @@ static void SDLTest_PrintEvent(const SDL_Event *event)
case SDL_EVENT_WINDOW_DESTROYED:
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " destroyed", event->window.windowID);
break;
case SDL_EVENT_KEYBOARD_ADDED:
SDL_Log("SDL EVENT: Keyboard %" SDL_PRIu32 " attached",
event->kdevice.which);
break;
case SDL_EVENT_KEYBOARD_REMOVED:
SDL_Log("SDL EVENT: Keyboard %" SDL_PRIu32 " removed",
event->kdevice.which);
break;
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP: {
char modstr[64];
@@ -1691,6 +1699,14 @@ static void SDLTest_PrintEvent(const SDL_Event *event)
case SDL_EVENT_KEYMAP_CHANGED:
SDL_Log("SDL EVENT: Keymap changed");
break;
case SDL_EVENT_MOUSE_ADDED:
SDL_Log("SDL EVENT: Mouse %" SDL_PRIu32 " attached",
event->mdevice.which);
break;
case SDL_EVENT_MOUSE_REMOVED:
SDL_Log("SDL EVENT: Mouse %" SDL_PRIu32 " removed",
event->mdevice.which);
break;
case SDL_EVENT_MOUSE_MOTION:
SDL_Log("SDL EVENT: Mouse: moved to %g,%g (%g,%g) in window %" SDL_PRIu32,
event->motion.x, event->motion.y,
@@ -1712,7 +1728,7 @@ static void SDLTest_PrintEvent(const SDL_Event *event)
event->wheel.x, event->wheel.y, event->wheel.direction, event->wheel.windowID);
break;
case SDL_EVENT_JOYSTICK_ADDED:
SDL_Log("SDL EVENT: Joystick index %" SDL_PRIu32 " attached",
SDL_Log("SDL EVENT: Joystick %" SDL_PRIu32 " attached",
event->jdevice.which);
break;
case SDL_EVENT_JOYSTICK_REMOVED:
@@ -1768,7 +1784,7 @@ static void SDLTest_PrintEvent(const SDL_Event *event)
event->jbutton.which, event->jbutton.button);
break;
case SDL_EVENT_GAMEPAD_ADDED:
SDL_Log("SDL EVENT: Gamepad index %" SDL_PRIu32 " attached",
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " attached",
event->gdevice.which);
break;
case SDL_EVENT_GAMEPAD_REMOVED: