Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to control drag analog behaviour #15048

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ static ConfigSetting controlSettings[] = {
#endif

ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false, true, true),
ConfigSetting("TouchAnalogBehaviour", &g_Config.iTouchAnalogBehaviour, 0, true, true),

ConfigSetting("GamepadOnlyFocused", &g_Config.bGamepadOnlyFocused, false, true, true),
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1, true, true),
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
Expand Down
10 changes: 10 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ enum ChatPositions {
CENTER_RIGHT = 7,
};

enum TouchAnalogBehaviour {
IGNORE_ALL = 0,
IGNORE_DPAD = 1,
PRESS_ALL = 2,
};

namespace http {
class Download;
class Downloader;
Expand Down Expand Up @@ -334,6 +340,10 @@ struct Config {
// Disable diagonals
bool bDisableDpadDiagonals;
bool bGamepadOnlyFocused;

// Drag analog behaviour
int iTouchAnalogBehaviour;

// Control Style
int iTouchButtonStyle;
int iTouchButtonOpacity;
Expand Down
5 changes: 5 additions & 0 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,11 @@ void GameSettingsScreen::CreateViews() {

CheckBox *disableDiags = controlsSettings->Add(new CheckBox(&g_Config.bDisableDpadDiagonals, co->T("Disable D-Pad diagonals (4-way touch)")));
disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);

static const char *analogBehaviors[] = {"Don't press other button", "Don't press DPAD only", "Press all button" };
PopupMultiChoice *analogBehaviour = controlsSettings->Add(new PopupMultiChoice(&g_Config.iTouchAnalogBehaviour, co->T("Touch Analog Drag Behaviour"), analogBehaviors, 0, ARRAY_SIZE(analogBehaviors), co->GetName(), screenManager()));
analogBehaviour->SetEnabledPtr(&g_Config.bShowTouchControls);

PopupSliderChoice *opacity = controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, co->T("Button Opacity"), screenManager(), "%"));
opacity->SetEnabledPtr(&g_Config.bShowTouchControls);
opacity->SetFormat("%i%%");
Expand Down
4 changes: 2 additions & 2 deletions UI/GamepadEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void MultiTouchButton::Touch(const TouchInput &input) {
usedPointerMask |= 1 << input.id;
}
if (input.flags & TOUCH_MOVE) {
if (bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id)))
if (bounds_.Contains(input.x, input.y) && (!(analogPointerMask & (1 << input.id)) || g_Config.iTouchAnalogBehaviour != IGNORE_ALL))
pointerDownMask_ |= 1 << input.id;
else
pointerDownMask_ &= ~(1 << input.id);
Expand Down Expand Up @@ -242,7 +242,7 @@ void PSPDpad::Touch(const TouchInput &input) {
}
}
if (input.flags & TOUCH_MOVE) {
if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id))) {
if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y) && (!(analogPointerMask & (1 << input.id)) || g_Config.iTouchAnalogBehaviour == PRESS_ALL)) {
dragPointerId_ = input.id;
}
if (input.id == dragPointerId_) {
Expand Down