mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 04:35:56 +00:00
Merge 50067ffadf
into 4f99f304e6
This commit is contained in:
commit
892dd6023f
8 changed files with 548 additions and 255 deletions
|
@ -75,6 +75,7 @@ static bool compatibilityData = false;
|
||||||
static bool checkCompatibilityOnStartup = false;
|
static bool checkCompatibilityOnStartup = false;
|
||||||
static std::string trophyKey;
|
static std::string trophyKey;
|
||||||
static bool isPSNSignedIn = false;
|
static bool isPSNSignedIn = false;
|
||||||
|
static std::string defaultControllerID = "";
|
||||||
|
|
||||||
// Gui
|
// Gui
|
||||||
static bool load_game_size = true;
|
static bool load_game_size = true;
|
||||||
|
@ -546,6 +547,14 @@ void setPSNSignedIn(bool sign) {
|
||||||
isPSNSignedIn = sign;
|
isPSNSignedIn = sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getDefaultControllerID() {
|
||||||
|
return defaultControllerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDefaultControllerID(std::string id) {
|
||||||
|
defaultControllerID = id;
|
||||||
|
}
|
||||||
|
|
||||||
void load(const std::filesystem::path& path) {
|
void load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
|
@ -584,6 +593,7 @@ void load(const std::filesystem::path& path) {
|
||||||
checkCompatibilityOnStartup =
|
checkCompatibilityOnStartup =
|
||||||
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
|
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
|
||||||
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", "Release");
|
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", "Release");
|
||||||
|
defaultControllerID = toml::find_or<std::string>(general, "defaultControllerID", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Input")) {
|
if (data.contains("Input")) {
|
||||||
|
@ -745,6 +755,7 @@ void save(const std::filesystem::path& path) {
|
||||||
data["General"]["sideTrophy"] = isSideTrophy;
|
data["General"]["sideTrophy"] = isSideTrophy;
|
||||||
data["General"]["compatibilityEnabled"] = compatibilityData;
|
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||||
|
data["General"]["defaultControllerID"] = defaultControllerID;
|
||||||
data["Input"]["cursorState"] = cursorState;
|
data["Input"]["cursorState"] = cursorState;
|
||||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||||
data["Input"]["useSpecialPad"] = useSpecialPad;
|
data["Input"]["useSpecialPad"] = useSpecialPad;
|
||||||
|
|
|
@ -97,6 +97,8 @@ bool isDevKitConsole(); // no set
|
||||||
bool vkValidationGpuEnabled(); // no set
|
bool vkValidationGpuEnabled(); // no set
|
||||||
bool getIsMotionControlsEnabled();
|
bool getIsMotionControlsEnabled();
|
||||||
void setIsMotionControlsEnabled(bool use);
|
void setIsMotionControlsEnabled(bool use);
|
||||||
|
std::string getDefaultControllerID();
|
||||||
|
void setDefaultControllerID(std::string id);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
bool GetLoadGameSizeEnabled();
|
bool GetLoadGameSizeEnabled();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "core/debug_state.h"
|
#include "core/debug_state.h"
|
||||||
#include "imgui_impl_sdl3.h"
|
#include "imgui_impl_sdl3.h"
|
||||||
|
#include "sdl_window.h"
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
@ -730,8 +731,14 @@ static void UpdateGamepads() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
SdlData* bd = GetBackendData();
|
SdlData* bd = GetBackendData();
|
||||||
|
|
||||||
|
SDL_Gamepad* SDLGamepad = Input::m_gamepad;
|
||||||
|
if (SDLGamepad) {
|
||||||
|
bd->gamepads.push_back(SDLGamepad);
|
||||||
|
bd->want_update_gamepads_list = false;
|
||||||
|
} else {
|
||||||
// Update list of gamepads to use
|
// Update list of gamepads to use
|
||||||
if (bd->want_update_gamepads_list && bd->gamepad_mode != ImGui_ImplSDL3_GamepadMode_Manual) {
|
if (bd->want_update_gamepads_list &&
|
||||||
|
bd->gamepad_mode != ImGui_ImplSDL3_GamepadMode_Manual) {
|
||||||
CloseGamepads();
|
CloseGamepads();
|
||||||
int sdl_gamepads_count = 0;
|
int sdl_gamepads_count = 0;
|
||||||
const SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
const SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
||||||
|
@ -743,6 +750,7 @@ static void UpdateGamepads() {
|
||||||
}
|
}
|
||||||
bd->want_update_gamepads_list = false;
|
bd->want_update_gamepads_list = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
|
|
|
@ -9,8 +9,11 @@
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "control_settings.h"
|
#include "control_settings.h"
|
||||||
#include "input/input_handler.h"
|
#include "input/input_handler.h"
|
||||||
|
#include "sdl_window.h"
|
||||||
#include "ui_control_settings.h"
|
#include "ui_control_settings.h"
|
||||||
|
|
||||||
|
std::string ControllerSelect::ActiveGamepad = "";
|
||||||
|
|
||||||
ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
||||||
std::string GameRunningSerial, QWidget* parent)
|
std::string GameRunningSerial, QWidget* parent)
|
||||||
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
||||||
|
@ -21,7 +24,6 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
||||||
if (!GameRunning) {
|
if (!GameRunning) {
|
||||||
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
||||||
CheckGamePad();
|
|
||||||
} else {
|
} else {
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
}
|
}
|
||||||
|
@ -29,6 +31,8 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
||||||
AddBoxItems();
|
AddBoxItems();
|
||||||
SetUIValuestoMappings();
|
SetUIValuestoMappings();
|
||||||
UpdateLightbarColor();
|
UpdateLightbarColor();
|
||||||
|
CheckGamePad();
|
||||||
|
ResetActiveControllerBox();
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
ButtonsList = {ui->CrossButton,
|
ButtonsList = {ui->CrossButton,
|
||||||
|
@ -118,6 +122,33 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
||||||
[this]() { CheckMapping(MappingButton); });
|
[this]() { CheckMapping(MappingButton); });
|
||||||
connect(this, &ControlSettings::AxisChanged, this,
|
connect(this, &ControlSettings::AxisChanged, this,
|
||||||
[this]() { ConnectAxisInputs(MappingButton); });
|
[this]() { ConnectAxisInputs(MappingButton); });
|
||||||
|
connect(ui->ActiveGamepadBox, &QComboBox::currentIndexChanged, this,
|
||||||
|
&ControlSettings::ActiveControllerChanged);
|
||||||
|
|
||||||
|
connect(ui->DefaultGamepadButton, &QPushButton::clicked, this, [this]() {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[ui->ActiveGamepadBox->currentIndex()]),
|
||||||
|
pszGUID, 33);
|
||||||
|
ui->DefaultGamepadName->setText(ui->ActiveGamepadBox->currentText());
|
||||||
|
ui->DefaultGamepadLabel->setText(tr("ID: ") +
|
||||||
|
QString::fromStdString(std::string(pszGUID)).right(16));
|
||||||
|
Config::setDefaultControllerID(std::string(pszGUID));
|
||||||
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
|
QMessageBox::information(this, tr("Default Controller Selected"),
|
||||||
|
tr("Active controller set as default"));
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->RemoveDefaultGamepadButton, &QPushButton::clicked, this, [this]() {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[ui->ActiveGamepadBox->currentIndex()]),
|
||||||
|
pszGUID, 33);
|
||||||
|
ui->DefaultGamepadName->setText(tr("No default selected"));
|
||||||
|
ui->DefaultGamepadLabel->setText(tr("n/a"));
|
||||||
|
Config::setDefaultControllerID("");
|
||||||
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
|
QMessageBox::information(this, tr("Default Controller Removed"),
|
||||||
|
tr("No default controller currently selected"));
|
||||||
|
});
|
||||||
|
|
||||||
RemapWrapper = SdlEventWrapper::Wrapper::GetInstance();
|
RemapWrapper = SdlEventWrapper::Wrapper::GetInstance();
|
||||||
SdlEventWrapper::Wrapper::wrapperActive = true;
|
SdlEventWrapper::Wrapper::wrapperActive = true;
|
||||||
|
@ -129,6 +160,110 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlSettings::ActiveControllerChanged(int value) {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[value]), pszGUID, 33);
|
||||||
|
QString GUID = QString::fromStdString(std::string(pszGUID)).right(16);
|
||||||
|
ui->ActiveGamepadLabel->setText("ID: " + GUID);
|
||||||
|
ControllerSelect::ActiveGamepad = std::string(pszGUID);
|
||||||
|
|
||||||
|
if (!GameRunning) {
|
||||||
|
if (gamepad) {
|
||||||
|
SDL_CloseGamepad(gamepad);
|
||||||
|
gamepad = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
gamepads = SDL_GetGamepads(&gamepad_count);
|
||||||
|
if (!gamepads) {
|
||||||
|
LOG_ERROR(Input, "Cannot get gamepad list: {}", SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == ControllerSelect::ActiveGamepad) {
|
||||||
|
gamepad = SDL_OpenGamepad(gamepads[i]);
|
||||||
|
LOG_WARNING(Input, "Opened gamepad: {}", i);
|
||||||
|
if (!gamepad) {
|
||||||
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gamepad) {
|
||||||
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlSettings::ResetActiveControllerBox() {
|
||||||
|
SDL_free(gamepads);
|
||||||
|
gamepads = SDL_GetGamepads(&gamepad_count);
|
||||||
|
if (!gamepads) {
|
||||||
|
LOG_ERROR(Input, "Cannot get gamepad list: {}", SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gamepad_count == 0) {
|
||||||
|
ui->ActiveGamepadBox->addItem("No gamepads detected");
|
||||||
|
ui->ActiveGamepadBox->setCurrentIndex(0);
|
||||||
|
LOG_INFO(Input, "No gamepad found!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
QString name = SDL_GetGamepadNameForID(gamepads[i]);
|
||||||
|
ui->ActiveGamepadBox->addItem(QString("%1: %2").arg(QString::number(i + 1), name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char pszGUID[33];
|
||||||
|
int defaultIndex;
|
||||||
|
QString defaultID = "";
|
||||||
|
|
||||||
|
if (Config::getDefaultControllerID() != "") {
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == Config::getDefaultControllerID()) {
|
||||||
|
defaultIndex = i;
|
||||||
|
defaultID = QString::fromStdString(std::string(pszGUID)).right(16);
|
||||||
|
ui->DefaultGamepadName->setText(SDL_GetGamepadNameForID(gamepads[i]));
|
||||||
|
ui->DefaultGamepadLabel->setText(tr("ID: ") + defaultID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultID == "")
|
||||||
|
ui->DefaultGamepadName->setText("Default controller not connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ControllerSelect::ActiveGamepad != "") {
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == ControllerSelect::ActiveGamepad) {
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
QString GUID = QString::fromStdString(std::string(pszGUID)).right(16);
|
||||||
|
ui->ActiveGamepadLabel->setText(tr("ID: ") + GUID);
|
||||||
|
ui->ActiveGamepadBox->setCurrentIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Config::getDefaultControllerID() != "") {
|
||||||
|
ui->ActiveGamepadLabel->setText(defaultID);
|
||||||
|
ui->ActiveGamepadBox->setCurrentIndex(defaultIndex);
|
||||||
|
} else {
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[0]), pszGUID, 33);
|
||||||
|
QString GUID = QString::fromStdString(std::string(pszGUID)).right(16);
|
||||||
|
ui->ActiveGamepadLabel->setText("ID: " + GUID);
|
||||||
|
ui->ActiveGamepadBox->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
||||||
QList<QPushButton*> list;
|
QList<QPushButton*> list;
|
||||||
list << ui->RStickUpButton << ui->RStickRightButton << ui->LStickUpButton
|
list << ui->RStickUpButton << ui->RStickRightButton << ui->LStickUpButton
|
||||||
|
@ -640,38 +775,42 @@ void ControlSettings::UpdateLightbarColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSettings::CheckGamePad() {
|
void ControlSettings::CheckGamePad() {
|
||||||
if (GameRunning)
|
if ((gamepad)) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (gamepad) {
|
|
||||||
SDL_CloseGamepad(gamepad);
|
SDL_CloseGamepad(gamepad);
|
||||||
gamepad = nullptr;
|
gamepad = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gamepad_count;
|
gamepads = SDL_GetGamepads(&gamepad_count);
|
||||||
SDL_JoystickID* gamepads = SDL_GetGamepads(&gamepad_count);
|
|
||||||
|
|
||||||
if (!gamepads) {
|
if (!gamepads) {
|
||||||
LOG_ERROR(Input, "Cannot get gamepad list: {}", SDL_GetError());
|
LOG_ERROR(Input, "Cannot get gamepad list: {}", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamepad_count == 0) {
|
if (!GameRunning) {
|
||||||
LOG_INFO(Input, "No gamepad found!");
|
if (ControllerSelect::ActiveGamepad != "") {
|
||||||
SDL_free(gamepads);
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
return;
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == ControllerSelect::ActiveGamepad) {
|
||||||
|
gamepad = SDL_OpenGamepad(gamepads[i]);
|
||||||
|
LOG_WARNING(Input, "Opened gamepad: {}", i);
|
||||||
|
if (!gamepad) {
|
||||||
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
||||||
gamepad = SDL_OpenGamepad(gamepads[0]);
|
gamepad = SDL_OpenGamepad(gamepads[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!gamepad) {
|
if (!gamepad) {
|
||||||
LOG_ERROR(Input, "Failed to open gamepad 0: {}", SDL_GetError());
|
LOG_ERROR(Input, "Failed to open gamepad 0: {}", SDL_GetError());
|
||||||
SDL_free(gamepads);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SDL_free(gamepads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSettings::DisableMappingButtons() {
|
void ControlSettings::DisableMappingButtons() {
|
||||||
|
@ -914,6 +1053,8 @@ void ControlSettings::pollSDLEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == SDL_EVENT_GAMEPAD_ADDED) {
|
if (event.type == SDL_EVENT_GAMEPAD_ADDED) {
|
||||||
|
ui->ActiveGamepadBox->clear();
|
||||||
|
ResetActiveControllerBox();
|
||||||
CheckGamePad();
|
CheckGamePad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,8 +1064,12 @@ void ControlSettings::pollSDLEvents() {
|
||||||
|
|
||||||
void ControlSettings::Cleanup() {
|
void ControlSettings::Cleanup() {
|
||||||
SdlEventWrapper::Wrapper::wrapperActive = false;
|
SdlEventWrapper::Wrapper::wrapperActive = false;
|
||||||
if (gamepad)
|
if (gamepad) {
|
||||||
SDL_CloseGamepad(gamepad);
|
SDL_CloseGamepad(gamepad);
|
||||||
|
gamepad = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_free(gamepads);
|
||||||
|
|
||||||
if (!GameRunning) {
|
if (!GameRunning) {
|
||||||
SDL_Event quitLoop{};
|
SDL_Event quitLoop{};
|
||||||
|
@ -937,6 +1082,9 @@ void ControlSettings::Cleanup() {
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
} else {
|
} else {
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||||
|
SDL_Event checkGamepad{};
|
||||||
|
checkGamepad.type = SDL_EVENT_CHANGE_CONTROLLER;
|
||||||
|
SDL_PushEvent(&checkGamepad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
#pragma once
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_gamepad.h>
|
#include <SDL3/SDL_gamepad.h>
|
||||||
|
@ -29,6 +29,7 @@ private Q_SLOTS:
|
||||||
void CheckMapping(QPushButton*& button);
|
void CheckMapping(QPushButton*& button);
|
||||||
void StartTimer(QPushButton*& button, bool isButton);
|
void StartTimer(QPushButton*& button, bool isButton);
|
||||||
void ConnectAxisInputs(QPushButton*& button);
|
void ConnectAxisInputs(QPushButton*& button);
|
||||||
|
void ActiveControllerChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::ControlSettings> ui;
|
std::unique_ptr<Ui::ControlSettings> ui;
|
||||||
|
@ -45,6 +46,7 @@ private:
|
||||||
void DisableMappingButtons();
|
void DisableMappingButtons();
|
||||||
void EnableMappingButtons();
|
void EnableMappingButtons();
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
void ResetActiveControllerBox();
|
||||||
|
|
||||||
QList<QPushButton*> ButtonsList;
|
QList<QPushButton*> ButtonsList;
|
||||||
QList<QPushButton*> AxisList;
|
QList<QPushButton*> AxisList;
|
||||||
|
@ -59,9 +61,11 @@ private:
|
||||||
bool MappingCompleted = false;
|
bool MappingCompleted = false;
|
||||||
QString mapping;
|
QString mapping;
|
||||||
int MappingTimer;
|
int MappingTimer;
|
||||||
|
int gamepad_count;
|
||||||
QTimer* timer;
|
QTimer* timer;
|
||||||
QPushButton* MappingButton;
|
QPushButton* MappingButton;
|
||||||
SDL_Gamepad* gamepad = nullptr;
|
SDL_Gamepad* gamepad = nullptr;
|
||||||
|
SDL_JoystickID* gamepads;
|
||||||
SdlEventWrapper::Wrapper* RemapWrapper;
|
SdlEventWrapper::Wrapper* RemapWrapper;
|
||||||
QFuture<void> Polling;
|
QFuture<void> Polling;
|
||||||
|
|
||||||
|
@ -81,3 +85,7 @@ protected:
|
||||||
Cleanup();
|
Cleanup();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace ControllerSelect {
|
||||||
|
extern std::string ActiveGamepad;
|
||||||
|
} // namespace ControllerSelect
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1114</width>
|
<width>1124</width>
|
||||||
<height>794</height>
|
<height>847</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -33,8 +33,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1094</width>
|
<width>1104</width>
|
||||||
<height>744</height>
|
<height>797</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
@ -42,8 +42,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1091</width>
|
<width>1101</width>
|
||||||
<height>741</height>
|
<height>791</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="RemapLayout">
|
<layout class="QHBoxLayout" name="RemapLayout">
|
||||||
|
@ -246,14 +246,82 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_5">
|
||||||
|
<property name="title">
|
||||||
|
<string>L1 and L2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_l2">
|
||||||
|
<property name="title">
|
||||||
|
<string>L2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_l2_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="L2Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_l1">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>L1</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_l1_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="L1Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Policy::Maximum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
|
@ -512,7 +580,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_middle" stretch="0,0,0,0,0">
|
<layout class="QVBoxLayout" name="verticalLayout_middle" stretch="0,0,0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -598,48 +666,41 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_middle_top">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="spacing">
|
<property name="font">
|
||||||
<number>0</number>
|
<font>
|
||||||
</property>
|
<pointsize>9</pointsize>
|
||||||
<item>
|
<bold>true</bold>
|
||||||
<layout class="QVBoxLayout" name="layout_system_buttons">
|
</font>
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gb_l1">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>L1</string>
|
<string>Active Gamepad</string>
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="gb_l1_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="L1Button">
|
<widget class="QComboBox" name="ActiveGamepadBox">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="ActiveGamepadLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>unmapped</string>
|
<string>Gamepad ID</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -647,81 +708,37 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="orientation">
|
<property name="font">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<font>
|
||||||
</property>
|
<pointsize>9</pointsize>
|
||||||
<property name="sizeType">
|
<bold>true</bold>
|
||||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
</font>
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>133</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gb_r1">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>R1</string>
|
<string>Default Gamepad</string>
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="gb_r1_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="R1Button">
|
<widget class="QLabel" name="DefaultGamepadName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>unmapped</string>
|
<string>No default selected</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
<widget class="QLabel" name="DefaultGamepadLabel">
|
||||||
<item>
|
<property name="font">
|
||||||
<widget class="QGroupBox" name="gb_l2">
|
<font>
|
||||||
<property name="title">
|
<pointsize>9</pointsize>
|
||||||
<string>L2</string>
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="gb_l2_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="L2Button">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>unmapped</string>
|
<string>n/a</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -729,69 +746,38 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_start">
|
<layout class="QHBoxLayout" name="horizontalLayout_19">
|
||||||
<property name="title">
|
|
||||||
<string>Options</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="gb_start_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="OptionsButton">
|
<widget class="QPushButton" name="DefaultGamepadButton">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>unmapped</string>
|
<string>Set Active Gamepad as Default</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_r2">
|
<widget class="QPushButton" name="RemoveDefaultGamepadButton">
|
||||||
<property name="title">
|
<property name="font">
|
||||||
<string>R2</string>
|
<font>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="gb_r2_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="R2Button">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>unmapped</string>
|
<string>Remove Default Gamepad</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget_controller" native="true">
|
<widget class="QWidget" name="widget_controller" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -880,20 +866,32 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QGroupBox" name="gb_start">
|
||||||
<property name="orientation">
|
<property name="title">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<string>Options</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<layout class="QVBoxLayout" name="gb_start_layout">
|
||||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="topMargin">
|
||||||
<size>
|
<number>5</number>
|
||||||
<width>133</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="OptionsButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_r3">
|
<widget class="QGroupBox" name="gb_r3">
|
||||||
|
@ -1338,13 +1336,84 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_6">
|
||||||
|
<property name="title">
|
||||||
|
<string>R1 and R2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_r2">
|
||||||
|
<property name="title">
|
||||||
|
<string>R2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_r2_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="R2Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_r1">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>R1</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_r1_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="R1Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<property name="sizeType">
|
||||||
<enum>QSizePolicy::Policy::Maximum</enum>
|
<enum>QSizePolicy::Policy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "video_core/renderdoc.h"
|
#include "video_core/renderdoc.h"
|
||||||
|
|
||||||
#ifdef ENABLE_QT_GUI
|
#ifdef ENABLE_QT_GUI
|
||||||
|
#include "qt_gui/control_settings.h"
|
||||||
#include "qt_gui/sdl_event_wrapper.h"
|
#include "qt_gui/sdl_event_wrapper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@
|
||||||
|
|
||||||
namespace Input {
|
namespace Input {
|
||||||
|
|
||||||
|
SDL_Gamepad* m_gamepad = nullptr;
|
||||||
|
|
||||||
using Libraries::Pad::OrbisPadButtonDataOffset;
|
using Libraries::Pad::OrbisPadButtonDataOffset;
|
||||||
|
|
||||||
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
|
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
|
||||||
|
@ -100,6 +103,7 @@ void SDLInputEngine::Init() {
|
||||||
if (m_gamepad) {
|
if (m_gamepad) {
|
||||||
SDL_CloseGamepad(m_gamepad);
|
SDL_CloseGamepad(m_gamepad);
|
||||||
m_gamepad = nullptr;
|
m_gamepad = nullptr;
|
||||||
|
LOG_WARNING(Input, "closed gamepad");
|
||||||
}
|
}
|
||||||
|
|
||||||
int gamepad_count;
|
int gamepad_count;
|
||||||
|
@ -114,13 +118,52 @@ void SDLInputEngine::Init() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string activeGamepad = "";
|
||||||
|
std::string defaultGamepad = Config::getDefaultControllerID();
|
||||||
|
#ifdef ENABLE_QT_GUI
|
||||||
|
activeGamepad = ControllerSelect::ActiveGamepad;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// If user selects an active gamepad, use that, otherwise, try the default
|
||||||
|
if (!m_gamepad) {
|
||||||
|
if (activeGamepad != "") {
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == activeGamepad) {
|
||||||
|
m_gamepad = SDL_OpenGamepad(gamepads[i]);
|
||||||
|
if (!m_gamepad) {
|
||||||
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Config::getDefaultControllerID() != "") {
|
||||||
|
for (int i = 0; i < gamepad_count; i++) {
|
||||||
|
char pszGUID[33];
|
||||||
|
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[i]), pszGUID, 33);
|
||||||
|
std::string currentGUID = std::string(pszGUID);
|
||||||
|
if (currentGUID == Config::getDefaultControllerID()) {
|
||||||
|
m_gamepad = SDL_OpenGamepad(gamepads[i]);
|
||||||
|
if (!m_gamepad) {
|
||||||
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_gamepad) {
|
||||||
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
||||||
m_gamepad = SDL_OpenGamepad(gamepads[0]);
|
m_gamepad = SDL_OpenGamepad(gamepads[0]);
|
||||||
if (!m_gamepad) {
|
if (!m_gamepad) {
|
||||||
LOG_ERROR(Input, "Failed to open gamepad 0: {}", SDL_GetError());
|
LOG_ERROR(Input, "Failed to open gamepad: {}", SDL_GetError());
|
||||||
SDL_free(gamepads);
|
SDL_free(gamepads);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Joystick* joystick = SDL_GetGamepadJoystick(m_gamepad);
|
SDL_Joystick* joystick = SDL_GetGamepadJoystick(m_gamepad);
|
||||||
Uint16 vendor = SDL_GetJoystickVendor(joystick);
|
Uint16 vendor = SDL_GetJoystickVendor(joystick);
|
||||||
|
@ -426,6 +469,9 @@ void WindowSDL::WaitEvent() {
|
||||||
DebugState.PauseGuestThreads();
|
DebugState.PauseGuestThreads();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SDL_EVENT_CHANGE_CONTROLLER:
|
||||||
|
controller->GetEngine()->Init();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "string"
|
#include "string"
|
||||||
#define SDL_EVENT_TOGGLE_FULLSCREEN (SDL_EVENT_USER + 1)
|
#define SDL_EVENT_TOGGLE_FULLSCREEN (SDL_EVENT_USER + 1)
|
||||||
#define SDL_EVENT_TOGGLE_PAUSE (SDL_EVENT_USER + 2)
|
#define SDL_EVENT_TOGGLE_PAUSE (SDL_EVENT_USER + 2)
|
||||||
|
#define SDL_EVENT_CHANGE_CONTROLLER (SDL_EVENT_USER + 3)
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Gamepad;
|
struct SDL_Gamepad;
|
||||||
|
@ -16,6 +17,8 @@ union SDL_Event;
|
||||||
|
|
||||||
namespace Input {
|
namespace Input {
|
||||||
|
|
||||||
|
extern SDL_Gamepad* m_gamepad;
|
||||||
|
|
||||||
class SDLInputEngine : public Engine {
|
class SDLInputEngine : public Engine {
|
||||||
public:
|
public:
|
||||||
~SDLInputEngine() override;
|
~SDLInputEngine() override;
|
||||||
|
@ -27,8 +30,6 @@ public:
|
||||||
State ReadState() override;
|
State ReadState() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Gamepad* m_gamepad = nullptr;
|
|
||||||
|
|
||||||
float m_gyro_poll_rate = 0.0f;
|
float m_gyro_poll_rate = 0.0f;
|
||||||
float m_accel_poll_rate = 0.0f;
|
float m_accel_poll_rate = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue