From c79506746c19827d892730fae2ea1be267cf7823 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 31 Jan 2020 18:09:58 -0800 Subject: [PATCH] Qt: Fix non-SDL build (fixes #1656) --- CHANGES | 1 + src/platform/qt/InputController.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES b/CHANGES index dae63f5f2..f57d8dade 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ Other fixes: - Qt: Fix extraneous dialog (fixes mgba.io/i/1654) - Util: Fix crash reading invalid ELFs Misc: + - Qt: Fix non-SDL build (fixes mgba.io/i/1656) - Switch: Make OpenGL scale adjustable while running 0.8.0: (2020-01-21) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index 77ee07042..c6a598cee 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -271,9 +271,21 @@ void InputController::setPreferredGamepad(uint32_t type, int index) { if (!m_config) { return; } +#ifdef BUILD_SDL char name[34] = {0}; +#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_JoystickListGetPointer(&s_sdlEvents.joysticks, index)->joystick), name, sizeof(name)); +#else + const char* name = SDL_JoystickName(SDL_JoystickIndex(SDL_JoystickListGetPointer(&s_sdlEvents.joysticks, index)->joystick)); + if (!name) { + return; + } +#endif mInputSetPreferredDevice(m_config->input(), "gba", type, m_playerId, name); +#else + UNUSED(type); + UNUSED(index); +#endif } mRumble* InputController::rumble() {