mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 02:17:39 +00:00
Added Steam Input API support for game controllers
Added support for getting the real controller info, as well as the function SDL_GetGamepadSteamHandle() to get the Steam Input API handle, from the virtual gamepads provided by Steam. Also added an event SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED which is triggered when a controller's API handle changes, e.g. the controllers were reassigned slots in the Steam UI.
This commit is contained in:
parent
a8f4f40d08
commit
c981a597dc
42 changed files with 779 additions and 40 deletions
|
@ -1292,6 +1292,13 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
|||
SDL_SetRenderDrawColor(renderer, r, g, b, a);
|
||||
}
|
||||
|
||||
if (controller->joystick) {
|
||||
SDL_snprintf(text, sizeof(text), "(%" SDL_PRIu32 ")", SDL_GetJoystickInstanceID(controller->joystick));
|
||||
x = (float)SCREEN_WIDTH - (FONT_CHARACTER_SIZE * SDL_strlen(text)) - 8.0f;
|
||||
y = 8.0f;
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
}
|
||||
|
||||
if (controller_name && *controller_name) {
|
||||
x = title_area.x + title_area.w / 2 - (FONT_CHARACTER_SIZE * SDL_strlen(controller_name)) / 2;
|
||||
y = title_area.y + title_area.h / 2 - FONT_CHARACTER_SIZE / 2;
|
||||
|
@ -1311,6 +1318,14 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
|||
SDLTest_DrawString(renderer, x, y, type);
|
||||
|
||||
if (display_mode == CONTROLLER_MODE_TESTING) {
|
||||
Uint64 steam_handle = SDL_GetGamepadSteamHandle(controller->gamepad);
|
||||
if (steam_handle) {
|
||||
SDL_snprintf(text, SDL_arraysize(text), "Steam: 0x%.16llx", (unsigned long long)steam_handle);
|
||||
y = (float)SCREEN_HEIGHT - 2 * (8.0f + FONT_LINE_HEIGHT);
|
||||
x = (float)SCREEN_WIDTH - 8.0f - (FONT_CHARACTER_SIZE * SDL_strlen(text));
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
}
|
||||
|
||||
SDL_snprintf(text, SDL_arraysize(text), "VID: 0x%.4x PID: 0x%.4x",
|
||||
SDL_GetJoystickVendor(controller->joystick),
|
||||
SDL_GetJoystickProduct(controller->joystick));
|
||||
|
@ -1595,6 +1610,10 @@ static void loop(void *arg)
|
|||
HandleGamepadRemapped(event.gdevice.which);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED:
|
||||
RefreshControllerName();
|
||||
break;
|
||||
|
||||
#ifdef VERBOSE_TOUCHPAD
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue