mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-25 11:56:18 +00:00
Replace Back Button Behaviour with a rebindable solution (#3114)
This commit is contained in:
parent
43321fb45a
commit
e214ca6884
7 changed files with 46 additions and 81 deletions
|
@ -42,7 +42,6 @@ static std::string logFilter;
|
|||
static std::string logType = "sync";
|
||||
static std::string userName = "shadPS4";
|
||||
static std::string chooseHomeTab;
|
||||
static std::string backButtonBehavior = "left";
|
||||
static bool useSpecialPad = false;
|
||||
static int specialPadClass = 1;
|
||||
static bool isMotionControlsEnabled = true;
|
||||
|
@ -205,10 +204,6 @@ std::string getChooseHomeTab() {
|
|||
return chooseHomeTab;
|
||||
}
|
||||
|
||||
std::string getBackButtonBehavior() {
|
||||
return backButtonBehavior;
|
||||
}
|
||||
|
||||
bool getUseSpecialPad() {
|
||||
return useSpecialPad;
|
||||
}
|
||||
|
@ -424,10 +419,6 @@ void setChooseHomeTab(const std::string& type) {
|
|||
chooseHomeTab = type;
|
||||
}
|
||||
|
||||
void setBackButtonBehavior(const std::string& type) {
|
||||
backButtonBehavior = type;
|
||||
}
|
||||
|
||||
void setUseSpecialPad(bool use) {
|
||||
useSpecialPad = use;
|
||||
}
|
||||
|
@ -582,7 +573,6 @@ void load(const std::filesystem::path& path) {
|
|||
|
||||
cursorState = toml::find_or<int>(input, "cursorState", HideCursorState::Idle);
|
||||
cursorHideTimeout = toml::find_or<int>(input, "cursorHideTimeout", 5);
|
||||
backButtonBehavior = toml::find_or<std::string>(input, "backButtonBehavior", "left");
|
||||
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
|
||||
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
|
||||
isMotionControlsEnabled = toml::find_or<bool>(input, "isMotionControlsEnabled", true);
|
||||
|
@ -737,7 +727,6 @@ void save(const std::filesystem::path& path) {
|
|||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||
data["Input"]["cursorState"] = cursorState;
|
||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
||||
data["Input"]["useSpecialPad"] = useSpecialPad;
|
||||
data["Input"]["specialPadClass"] = specialPadClass;
|
||||
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
|
||||
|
@ -828,7 +817,6 @@ void setDefaultValues() {
|
|||
cursorState = HideCursorState::Idle;
|
||||
cursorHideTimeout = 5;
|
||||
trophyNotificationDuration = 6.0;
|
||||
backButtonBehavior = "left";
|
||||
useSpecialPad = false;
|
||||
specialPadClass = 1;
|
||||
isDebugDump = false;
|
||||
|
@ -874,7 +862,7 @@ l3 = x
|
|||
r3 = m
|
||||
|
||||
options = enter
|
||||
touchpad = space
|
||||
touchpad_center = space
|
||||
|
||||
pad_up = up
|
||||
pad_down = down
|
||||
|
@ -906,7 +894,7 @@ r2 = r2
|
|||
r3 = r3
|
||||
|
||||
options = options
|
||||
touchpad = back
|
||||
touchpad_center = back
|
||||
|
||||
pad_up = pad_up
|
||||
pad_down = pad_down
|
||||
|
|
|
@ -102,7 +102,6 @@ bool getCompatibilityEnabled();
|
|||
bool getCheckCompatibilityOnStartup();
|
||||
std::string getUserName();
|
||||
std::string getChooseHomeTab();
|
||||
std::string getBackButtonBehavior();
|
||||
bool GetUseUnifiedInputConfig();
|
||||
void SetUseUnifiedInputConfig(bool use);
|
||||
bool GetOverrideControllerColor();
|
||||
|
@ -116,7 +115,6 @@ void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
|
|||
void setSaveDataPath(const std::filesystem::path& path);
|
||||
void setCompatibilityEnabled(bool use);
|
||||
void setCheckCompatibilityOnStartup(bool use);
|
||||
void setBackButtonBehavior(const std::string& type);
|
||||
// Gui
|
||||
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
|
||||
void removeGameInstallDir(const std::filesystem::path& dir);
|
||||
|
|
|
@ -77,7 +77,9 @@ auto output_array = std::array{
|
|||
ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER), // R1
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_STICK), // R3
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_START), // Options
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD), // TouchPad
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT), // TouchPad
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER), // TouchPad
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT), // TouchPad
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_UP), // Up
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_DOWN), // Down
|
||||
ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_LEFT), // Left
|
||||
|
@ -130,6 +132,12 @@ static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
|
|||
return OPBDO::Options;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
return OPBDO::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT:
|
||||
return OPBDO::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER:
|
||||
return OPBDO::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT:
|
||||
return OPBDO::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_BACK:
|
||||
return OPBDO::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
|
||||
|
@ -499,14 +507,21 @@ void ControllerOutput::FinalizeUpdate() {
|
|||
}
|
||||
old_button_state = new_button_state;
|
||||
old_param = *new_param;
|
||||
float touchpad_x = 0;
|
||||
if (button != SDL_GAMEPAD_BUTTON_INVALID) {
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
||||
: 0.5f;
|
||||
controller->SetTouchpadState(0, new_button_state, touchpad_x, 0.5f);
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT:
|
||||
LOG_INFO(Input, "Topuchpad left");
|
||||
controller->SetTouchpadState(0, new_button_state, 0.25f, 0.5f);
|
||||
controller->CheckButton(0, SDLGamepadToOrbisButton(button), new_button_state);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER:
|
||||
LOG_INFO(Input, "Topuchpad center");
|
||||
controller->SetTouchpadState(0, new_button_state, 0.50f, 0.5f);
|
||||
controller->CheckButton(0, SDLGamepadToOrbisButton(button), new_button_state);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT:
|
||||
LOG_INFO(Input, "Topuchpad right");
|
||||
controller->SetTouchpadState(0, new_button_state, 0.75f, 0.5f);
|
||||
controller->CheckButton(0, SDLGamepadToOrbisButton(button), new_button_state);
|
||||
break;
|
||||
case LEFTJOYSTICK_HALFMODE:
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#define SDL_MOUSE_WHEEL_LEFT SDL_EVENT_MOUSE_WHEEL + 5
|
||||
#define SDL_MOUSE_WHEEL_RIGHT SDL_EVENT_MOUSE_WHEEL + 7
|
||||
|
||||
#define SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT SDL_GAMEPAD_BUTTON_COUNT + 1
|
||||
#define SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER SDL_GAMEPAD_BUTTON_COUNT + 2
|
||||
#define SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT SDL_GAMEPAD_BUTTON_COUNT + 3
|
||||
|
||||
// idk who already used what where so I just chose a big number
|
||||
#define SDL_EVENT_MOUSE_WHEEL_OFF SDL_EVENT_USER + 10
|
||||
|
||||
|
@ -98,7 +102,9 @@ const std::map<std::string, u32> string_to_cbutton_map = {
|
|||
{"options", SDL_GAMEPAD_BUTTON_START},
|
||||
|
||||
// these are outputs only (touchpad can only be bound to itself)
|
||||
{"touchpad", SDL_GAMEPAD_BUTTON_TOUCHPAD},
|
||||
{"touchpad_left", SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT},
|
||||
{"touchpad_center", SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER},
|
||||
{"touchpad_right", SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT},
|
||||
{"leftjoystick_halfmode", LEFTJOYSTICK_HALFMODE},
|
||||
{"rightjoystick_halfmode", RIGHTJOYSTICK_HALFMODE},
|
||||
|
||||
|
|
|
@ -133,6 +133,8 @@ Controller:
|
|||
'options', touchpad', 'up', 'down', 'left', 'right'
|
||||
Input-only:
|
||||
'lpaddle_low', 'lpaddle_high'
|
||||
Output-only:
|
||||
'touchpad_left', 'touchpad_center', 'touchpad_right'
|
||||
Axes if you bind them to a button input:
|
||||
'axis_left_x_plus', 'axis_left_x_minus', 'axis_left_y_plus', 'axis_left_y_minus',
|
||||
'axis_right_x_plus', ..., 'axis_right_y_minus',
|
||||
|
|
|
@ -123,11 +123,6 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
|
|||
ui->hideCursorComboBox->addItem(tr("Idle"));
|
||||
ui->hideCursorComboBox->addItem(tr("Always"));
|
||||
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Left"), "left");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Center"), "center");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Right"), "right");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("None"), "none");
|
||||
|
||||
InitializeEmulatorLanguages();
|
||||
LoadValuesFromConfig();
|
||||
|
||||
|
@ -366,7 +361,6 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
|
|||
// Input
|
||||
ui->hideCursorGroupBox->installEventFilter(this);
|
||||
ui->idleTimeoutGroupBox->installEventFilter(this);
|
||||
ui->backButtonBehaviorGroupBox->installEventFilter(this);
|
||||
|
||||
// Graphics
|
||||
ui->graphicsAdapterGroupBox->installEventFilter(this);
|
||||
|
@ -534,10 +528,6 @@ void SettingsDialog::LoadValuesFromConfig() {
|
|||
indexTab = 0;
|
||||
ui->tabWidgetSettings->setCurrentIndex(indexTab);
|
||||
|
||||
QString backButtonBehavior = QString::fromStdString(
|
||||
toml::find_or<std::string>(data, "Input", "backButtonBehavior", "left"));
|
||||
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
|
||||
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
|
||||
ui->motionControlsCheckBox->setChecked(
|
||||
toml::find_or<bool>(data, "Input", "isMotionControlsEnabled", true));
|
||||
|
||||
|
@ -666,8 +656,6 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
|
|||
text = tr("Hide Cursor:\\nChoose when the cursor will disappear:\\nNever: You will always see the mouse.\\nidle: Set a time for it to disappear after being idle.\\nAlways: you will never see the mouse.");
|
||||
} else if (elementName == "idleTimeoutGroupBox") {
|
||||
text = tr("Hide Idle Cursor Timeout:\\nThe duration (seconds) after which the cursor that has been idle hides itself.");
|
||||
} else if (elementName == "backButtonBehaviorGroupBox") {
|
||||
text = tr("Back Button Behavior:\\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad.");
|
||||
}
|
||||
|
||||
// Graphics
|
||||
|
@ -745,8 +733,6 @@ bool SettingsDialog::eventFilter(QObject* obj, QEvent* event) {
|
|||
|
||||
void SettingsDialog::UpdateSettings() {
|
||||
|
||||
const QVector<std::string> TouchPadIndex = {"left", "center", "right", "none"};
|
||||
Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]);
|
||||
Config::setIsFullscreen(screenModeMap.value(ui->displayModeComboBox->currentText()) !=
|
||||
"Windowed");
|
||||
Config::setFullscreenMode(
|
||||
|
|
|
@ -1613,36 +1613,6 @@
|
|||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="backButtonBehaviorGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Back Button Behavior</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="BackButtonLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="backButtonBehaviorComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="motionControlsCheckBox">
|
||||
<property name="text">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue