diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index f70e51692..17176c103 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -78,6 +78,16 @@ static QString ButtonToText(const Common::ParamPackage& param) { } static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) { + // If this is an analog stick made from buttons, keyboards will need to be handled + // here at the frontend rather than at InputCommon + // It might be nice to move the GetKeyName code to input_common, but would need a non-QT way of + // doing it + if (param.Get("engine", "") == "analog_from_button") { + auto dirParam = Common::ParamPackage(param.Get(dir, "")); + if (dirParam.Get("engine", "") == "keyboard") { + return GetKeyName(dirParam.Get("code", 0)); + } + } return QString::fromStdString(InputCommon::AnalogToText(param, dir)); } diff --git a/src/citra_qt/hotkey_monitor.cpp b/src/citra_qt/hotkey_monitor.cpp index 7ffce7df1..97301524d 100644 --- a/src/citra_qt/hotkey_monitor.cpp +++ b/src/citra_qt/hotkey_monitor.cpp @@ -61,12 +61,12 @@ void ControllerHotkeyMonitor::checkAllButtons() { if (it.hk->action) { it.hk->action->trigger(); } - for (auto const& [name, hotkey_shortcut] : it.hk->shortcuts) { + for (auto const& [hotkey_name, hotkey_shortcut] : it.hk->shortcuts) { if (hotkey_shortcut && hotkey_shortcut->isEnabled()) { QWidget* parent = qobject_cast(hotkey_shortcut->parent()); if (!parent) continue; - if (name == QStringLiteral("move down")) { + if (hotkey_name == QStringLiteral("move down")) { std::cout << "move down triggered before context check" << std::endl; } bool shouldFire = true; diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 3288e6979..3ef4fd539 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include "common/param_package.h" @@ -75,9 +76,10 @@ std::string ButtonToText(const Common::ParamPackage& param) { return "[not set]"; } const auto engine_str = param.Get("engine", ""); - // keyboard should be handled by the frontend + // if this is a keyboard string, return the param package back as a string + // to be handled at the frontend if (engine_str == "keyboard") { - return "keyboard code " + param.Get("code", 0); + return param.Serialize(); } if (engine_str == "sdl") { diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 29a972f74..1ab727ae0 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -463,7 +463,8 @@ public: : joysticks(joysticks_), button(button_), isController(isController_), port(port_) {} bool GetStatus() const override { - if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) { + if (port >= 0 && joysticks && static_cast(joysticks->size()) > port && + joysticks->at(port)) { return joysticks->at(port)->GetButton(button, isController); } for (const auto& joystick : *joysticks) { @@ -489,7 +490,8 @@ public: : joysticks(joysticks_), hat(hat_), direction(direction_), port(port_) {} bool GetStatus() const override { - if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) { + if (port >= 0 && joysticks && static_cast(joysticks->size()) > port && + joysticks->at(port)) { return joysticks->at(port)->GetHatDirection(hat, direction); } for (const auto& joystick : *joysticks) { @@ -515,7 +517,8 @@ public: trigger_if_greater(trigger_if_greater_), isController(isController_), port(port_) {} bool GetStatus() const override { - if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) { + if (port >= 0 && joysticks && static_cast(joysticks->size()) > port && + joysticks->at(port)) { return joysticks->at(port)->GetAxis(axis, isController); } for (const auto& joystick : *joysticks) { @@ -548,7 +551,8 @@ public: std::tuple GetStatus() const override { float rMax = 0.0f, xMax = 0.0f, yMax = 0.0f; - if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) { + if (port >= 0 && joysticks && static_cast(joysticks->size()) > port && + joysticks->at(port)) { const auto [x, y] = joysticks->at(port)->GetAnalog(axis_x, axis_y, isController); const float r = std::sqrt((x * x) + (y * y)); if (r > deadzone) { @@ -663,7 +667,6 @@ public: } if (params.Has("axis")) { - bool controller = params.Get("api", "joystick") == "controller"; const int axis = params.Get("axis", 0); const float threshold = params.Get("threshold", 0.5f); const std::string direction_name = params.Get("direction", ""); @@ -730,7 +733,8 @@ public: auto joysticks = state.GetJoysticksByGUID(guid); if (joysticks->empty()) return std::make_unique(nullptr); - auto joystick = joysticks->size() > port ? joysticks->at(port) : joysticks->at(0); + auto joystick = + static_cast(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0); return std::make_unique(joystick); } @@ -755,7 +759,8 @@ public: const int port = params.Get("port", 0); const int touchpad = params.Get("touchpad", 0); auto joysticks = state.GetJoysticksByGUID(guid); - auto joystick = joysticks->size() > port ? joysticks->at(port) : joysticks->at(0); + auto joystick = + static_cast(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0); return std::make_unique(joystick, touchpad); } @@ -975,7 +980,6 @@ public: auto id = event.jaxis.which; auto value = event.jaxis.value; auto timestamp = event.jaxis.timestamp; - auto button = event.jbutton.button; bool controller = false; switch (event.type) { case SDL_CONTROLLERAXISMOTION: {