mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-06-03 21:55:00 -06:00
Compare commits
6 Commits
b927c51346
...
6f7ab5869a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f7ab5869a | ||
|
|
7680a3253d | ||
|
|
354b8d765a | ||
|
|
81602a89a4 | ||
|
|
fa379a4a3c | ||
|
|
c9aaec5469 |
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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<QWidget*>(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;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// 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"
|
||||
@ -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") {
|
||||
|
||||
@ -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<int>(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<int>(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<int>(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<float, float> 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<int>(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<SDLMotion>(nullptr);
|
||||
auto joystick = joysticks->size() > port ? joysticks->at(port) : joysticks->at(0);
|
||||
auto joystick =
|
||||
static_cast<int>(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0);
|
||||
return std::make_unique<SDLMotion>(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<int>(joysticks->size()) > port ? joysticks->at(port) : joysticks->at(0);
|
||||
return std::make_unique<SDLTouch>(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: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user