From 804115b2a46d25408b34e3e08e83d3f926fd9968 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 11 Sep 2018 03:29:59 +0200 Subject: Port #4141 from citra: Joystick hotplug support (#1275) * Joystick hotplug support (#4141) * use SDL_PollEvent instead of SDL_JoystickUpdate Register hot plugged controller by GUID if they were configured in a previous session * Move SDL_PollEvent into its own thread * Don't store SDLJoystick pointer in Input Device; Get pointer on each GetStatus call * Fix that joystick_list gets cleared after SDL_Quit * Add VirtualJoystick for InputDevices thats never nullptr * fixup! Add VirtualJoystick for InputDevices thats never nullptr * fixup! fixup! Add VirtualJoystick for InputDevices thats never nullptr * Remove SDL_GameController, make SDL_Joystick* unique_ptr * fixup! Remove SDL_GameController, make SDL_Joystick* unique_ptr * Adressed feedback; fixed handling of same guid reconnects * fixup! Adressed feedback; fixed handling of same guid reconnects * merge the two joystick_lists into one * make SDLJoystick a member of VirtualJoystick * fixup! make SDLJoystick a member of VirtualJoystick * fixup! make SDLJoystick a member of VirtualJoystick * fixup! fixup! make SDLJoystick a member of VirtualJoystick * SDLJoystick: Addressed review comments * Address one missed review comment --- src/yuzu/configuration/configure_input.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/yuzu/configuration') diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 5e7badedf..d29abb74b 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -1,4 +1,4 @@ -// Copyright 2016 Citra Emulator Project +// Copyright 2016 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -53,19 +53,18 @@ static QString ButtonToText(const Common::ParamPackage& param) { } else if (param.Get("engine", "") == "keyboard") { return getKeyName(param.Get("code", 0)); } else if (param.Get("engine", "") == "sdl") { - QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); if (param.Has("hat")) { - text += QString(QObject::tr(" Hat %1 %2")) - .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); + return QString(QObject::tr("Hat %1 %2")) + .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); } if (param.Has("axis")) { - text += QString(QObject::tr(" Axis %1%2")) - .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); + return QString(QObject::tr("Axis %1%2")) + .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); } if (param.Has("button")) { - text += QString(QObject::tr(" Button %1")).arg(param.Get("button", "").c_str()); + return QString(QObject::tr("Button %1")).arg(param.Get("button", "").c_str()); } - return text; + return QString(); } else { return QObject::tr("[unknown]"); } @@ -81,13 +80,12 @@ static QString AnalogToText(const Common::ParamPackage& param, const std::string return QString(QObject::tr("[unused]")); } - QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); if (dir == "left" || dir == "right") { - text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_x", "").c_str()); + return QString(QObject::tr("Axis %1")).arg(param.Get("axis_x", "").c_str()); } else if (dir == "up" || dir == "down") { - text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_y", "").c_str()); + return QString(QObject::tr("Axis %1")).arg(param.Get("axis_y", "").c_str()); } - return text; + return QString(); } else { return QObject::tr("[unknown]"); } -- cgit v1.2.3