Compare commits

..

5 Commits

Author SHA1 Message Date
NovaChild
b927c51346
Merge 790473eb44 into c650473fdc 2026-04-07 16:38:18 +03:00
David Griswold
790473eb44 fix profiles not saving correctly 2026-04-07 16:38:10 +03:00
David Griswold
e13c4deb24 honor shortcut context with controller hotkeys 2026-04-02 20:54:59 +03:00
David Griswold
30db1a71fd Add "Press A (right) button" command to input automap that will map in nintendo layout if the user has a nintendo layout / prefers to match letters rather than position. 2026-04-02 15:42:01 +03:00
David Griswold
7d55d3a642 controller hotkey support and SDL refactor to use GameController API,
which adds more user-readable names to controller input maps
2026-04-01 15:21:09 +03:00
4 changed files with 12 additions and 28 deletions

View File

@ -78,16 +78,6 @@ 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));
}

View File

@ -61,12 +61,12 @@ void ControllerHotkeyMonitor::checkAllButtons() {
if (it.hk->action) {
it.hk->action->trigger();
}
for (auto const& [hotkey_name, hotkey_shortcut] : it.hk->shortcuts) {
for (auto const& [name, hotkey_shortcut] : it.hk->shortcuts) {
if (hotkey_shortcut && hotkey_shortcut->isEnabled()) {
QWidget* parent = qobject_cast<QWidget*>(hotkey_shortcut->parent());
if (!parent)
continue;
if (hotkey_name == QStringLiteral("move down")) {
if (name == QStringLiteral("move down")) {
std::cout << "move down triggered before context check" << std::endl;
}
bool shouldFire = true;

View File

@ -2,7 +2,6 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <iostream>
#include <memory>
#include <thread>
#include "common/param_package.h"
@ -76,10 +75,9 @@ std::string ButtonToText(const Common::ParamPackage& param) {
return "[not set]";
}
const auto engine_str = param.Get("engine", "");
// if this is a keyboard string, return the param package back as a string
// to be handled at the frontend
// keyboard should be handled by the frontend
if (engine_str == "keyboard") {
return param.Serialize();
return "keyboard code " + param.Get("code", 0);
}
if (engine_str == "sdl") {

View File

@ -463,8 +463,7 @@ public:
: joysticks(joysticks_), button(button_), isController(isController_), port(port_) {}
bool GetStatus() const override {
if (port >= 0 && joysticks && static_cast<int>(joysticks->size()) > port &&
joysticks->at(port)) {
if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) {
return joysticks->at(port)->GetButton(button, isController);
}
for (const auto& joystick : *joysticks) {
@ -490,8 +489,7 @@ public:
: joysticks(joysticks_), hat(hat_), direction(direction_), port(port_) {}
bool GetStatus() const override {
if (port >= 0 && joysticks && static_cast<int>(joysticks->size()) > port &&
joysticks->at(port)) {
if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) {
return joysticks->at(port)->GetHatDirection(hat, direction);
}
for (const auto& joystick : *joysticks) {
@ -517,8 +515,7 @@ public:
trigger_if_greater(trigger_if_greater_), isController(isController_), port(port_) {}
bool GetStatus() const override {
if (port >= 0 && joysticks && static_cast<int>(joysticks->size()) > port &&
joysticks->at(port)) {
if (port >= 0 && joysticks && joysticks->size() > port && joysticks->at(port)) {
return joysticks->at(port)->GetAxis(axis, isController);
}
for (const auto& joystick : *joysticks) {
@ -551,8 +548,7 @@ public:
std::tuple<float, float> GetStatus() const override {
float rMax = 0.0f, xMax = 0.0f, yMax = 0.0f;
if (port >= 0 && joysticks && static_cast<int>(joysticks->size()) > port &&
joysticks->at(port)) {
if (port >= 0 && joysticks && 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) {
@ -667,6 +663,7 @@ 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", "");
@ -733,8 +730,7 @@ public:
auto joysticks = state.GetJoysticksByGUID(guid);
if (joysticks->empty())
return std::make_unique<SDLMotion>(nullptr);
auto joystick =
static_cast<int>(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0);
auto joystick = joysticks->size() > port ? joysticks->at(port) : joysticks->at(0);
return std::make_unique<SDLMotion>(joystick);
}
@ -759,8 +755,7 @@ public:
const int port = params.Get("port", 0);
const int touchpad = params.Get("touchpad", 0);
auto joysticks = state.GetJoysticksByGUID(guid);
auto joystick =
static_cast<int>(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0);
auto joystick = joysticks->size() > port ? joysticks->at(port) : joysticks->at(0);
return std::make_unique<SDLTouch>(joystick, touchpad);
}
@ -980,6 +975,7 @@ 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: {