Add option to disable touch dpad diagonals.

Makes some games a lot more playable with touch screen.
This commit is contained in:
Henrik Rydgård 2013-12-02 15:50:09 +01:00
parent cfbd1b07e8
commit c3dfbbeff9
5 changed files with 32 additions and 14 deletions

View file

@ -256,6 +256,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
control->Get("DeadzoneRadius", &fDeadzoneRadius, 0.35);
#endif
control->Get("DisableDpadDiagonals", &bDisableDpadDiagonals, false);
control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
//set these to -1 if not initialized. initializing these
//requires pixel coordinates which is not known right now.
@ -514,6 +515,8 @@ void Config::Save() {
control->Set("TiltSensitivityY", iTiltSensitivityY);
control->Set("DeadzoneRadius", fDeadzoneRadius);
#endif
control->Set("DisableDpadDiagonals", bDisableDpadDiagonals);
control->Set("TouchButtonOpacity", iTouchButtonOpacity);
control->Set("ActionButtonScale", fActionButtonScale);
control->Set("ActionButtonSpacing2", fActionButtonSpacing);

View file

@ -145,6 +145,8 @@ public:
bool bGridView2;
bool bGridView3;
// Disable diagonals
bool bDisableDpadDiagonals;
// Control Positions
int iTouchButtonOpacity;
//space between PSP buttons
@ -192,10 +194,10 @@ public:
bool bShowTouchLTrigger;
bool bShowTouchRTrigger;
bool bShowTouchAnalogStick;
bool bShowTouchDpad;
bool bHapticFeedback;
// GLES backend-specific hacks. Not saved to the ini file, do not add checkboxes. Will be made into

View file

@ -242,6 +242,8 @@ void GameSettingsScreen::CreateViews() {
layoutEditorChoice_ = controlsSettings->Add(new Choice(c->T("Custom layout...")));
layoutEditorChoice_->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout);
layoutEditorChoice_->SetEnabledPtr(&g_Config.bShowTouchControls);
CheckBox *disableDiags = controlsSettings->Add(new CheckBox(&g_Config.bDisableDpadDiagonals, c->T("Disable D-Pad diagonals (4-way touch)")));
disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);
controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager()));
// System

View file

@ -98,7 +98,6 @@ bool PSPButton::IsDown() {
return (__CtrlPeekButtons() & pspButtonBit_) != 0;
}
PSPDpad::PSPDpad(int arrowIndex, int overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams)
: UI::View(layoutParams), arrowIndex_(arrowIndex), overlayIndex_(overlayIndex),
scale_(scale), spacing_(spacing), dragPointerId_(-1), down_(0) {
@ -145,16 +144,28 @@ void PSPDpad::ProcessTouch(float x, float y, bool down) {
int ctrlMask = 0;
int lastDown = down_;
if (down) {
int direction = (int)(floorf((atan2f(dy, dx) / (2 * M_PI) * 8) + 0.5f)) & 7;
switch (direction) {
case 0: ctrlMask |= CTRL_RIGHT; break;
case 1: ctrlMask |= CTRL_RIGHT | CTRL_DOWN; break;
case 2: ctrlMask |= CTRL_DOWN; break;
case 3: ctrlMask |= CTRL_DOWN | CTRL_LEFT; break;
case 4: ctrlMask |= CTRL_LEFT; break;
case 5: ctrlMask |= CTRL_UP | CTRL_LEFT; break;
case 6: ctrlMask |= CTRL_UP; break;
case 7: ctrlMask |= CTRL_UP | CTRL_RIGHT; break;
if (g_Config.bDisableDpadDiagonals) {
int direction = (int)(floorf((atan2f(dy, dx) / (2 * M_PI) * 4) + 0.5f)) & 3;
switch (direction) {
case 0: ctrlMask |= CTRL_RIGHT; break;
case 1: ctrlMask |= CTRL_DOWN; break;
case 2: ctrlMask |= CTRL_LEFT; break;
case 3: ctrlMask |= CTRL_UP; break;
}
// 4 way pad
} else {
// 8 way pad
int direction = (int)(floorf((atan2f(dy, dx) / (2 * M_PI) * 8) + 0.5f)) & 7;
switch (direction) {
case 0: ctrlMask |= CTRL_RIGHT; break;
case 1: ctrlMask |= CTRL_RIGHT | CTRL_DOWN; break;
case 2: ctrlMask |= CTRL_DOWN; break;
case 3: ctrlMask |= CTRL_DOWN | CTRL_LEFT; break;
case 4: ctrlMask |= CTRL_LEFT; break;
case 5: ctrlMask |= CTRL_UP | CTRL_LEFT; break;
case 6: ctrlMask |= CTRL_UP; break;
case 7: ctrlMask |= CTRL_UP | CTRL_RIGHT; break;
}
}
}

2
lang

@ -1 +1 @@
Subproject commit 056b48b3568ba3d6cddcde04830dec84a9fdeaea
Subproject commit a55d07fa7d8240f79ab4b8c75ad0239033875107