mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-07 14:19:19 +00:00
Merge pull request #16450 from unknownbrackets/touch-right-analog
UI: Fix right analog with single button
This commit is contained in:
commit
f2b5f06dac
@ -602,7 +602,20 @@ bool PSPCustomStick::Touch(const TouchInput &input) {
|
||||
}
|
||||
|
||||
void PSPCustomStick::ProcessTouch(float x, float y, bool down) {
|
||||
static const int button[16] = {CTRL_LTRIGGER, CTRL_RTRIGGER, CTRL_SQUARE, CTRL_TRIANGLE, CTRL_CIRCLE, CTRL_CROSS, CTRL_UP, CTRL_DOWN, CTRL_LEFT, CTRL_RIGHT, CTRL_START, CTRL_SELECT};
|
||||
static const int buttons[] = {0, CTRL_LTRIGGER, CTRL_RTRIGGER, CTRL_SQUARE, CTRL_TRIANGLE, CTRL_CIRCLE, CTRL_CROSS, CTRL_UP, CTRL_DOWN, CTRL_LEFT, CTRL_RIGHT, CTRL_START, CTRL_SELECT};
|
||||
|
||||
u32 press = 0;
|
||||
u32 release = 0;
|
||||
|
||||
auto toggle = [&](int config, bool simpleCheck, bool diagCheck = true) {
|
||||
if (config <= 0 || (size_t)config >= ARRAY_SIZE(buttons))
|
||||
return;
|
||||
|
||||
if (simpleCheck && (!g_Config.bRightAnalogDisableDiagonal || diagCheck))
|
||||
press |= buttons[config];
|
||||
else
|
||||
release |= buttons[config];
|
||||
};
|
||||
|
||||
if (down && centerX_ >= 0.0f) {
|
||||
float inv_stick_size = 1.0f / (stick_size_ * scale_);
|
||||
@ -613,51 +626,30 @@ void PSPCustomStick::ProcessTouch(float x, float y, bool down) {
|
||||
dx = std::min(1.0f, std::max(-1.0f, dx));
|
||||
dy = std::min(1.0f, std::max(-1.0f, dy));
|
||||
|
||||
if (g_Config.iRightAnalogRight != 0) {
|
||||
if (dx > 0.5f && (!g_Config.bRightAnalogDisableDiagonal || fabs(dx) > fabs(dy)))
|
||||
__CtrlButtonDown(button[g_Config.iRightAnalogRight-1]);
|
||||
else
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogRight-1]);
|
||||
}
|
||||
if (g_Config.iRightAnalogLeft != 0) {
|
||||
if (dx < -0.5f && (!g_Config.bRightAnalogDisableDiagonal || fabs(dx) > fabs(dy)))
|
||||
__CtrlButtonDown(button[g_Config.iRightAnalogLeft-1]);
|
||||
else
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogLeft-1]);
|
||||
}
|
||||
if (g_Config.iRightAnalogUp != 0) {
|
||||
if (dy < -0.5f && (!g_Config.bRightAnalogDisableDiagonal || fabs(dx) <= fabs(dy)))
|
||||
__CtrlButtonDown(button[g_Config.iRightAnalogUp-1]);
|
||||
else
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogUp-1]);
|
||||
}
|
||||
if (g_Config.iRightAnalogDown != 0) {
|
||||
if (dy > 0.5f && (!g_Config.bRightAnalogDisableDiagonal || fabs(dx) <= fabs(dy)))
|
||||
__CtrlButtonDown(button[g_Config.iRightAnalogDown-1]);
|
||||
else
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogDown-1]);
|
||||
}
|
||||
if (g_Config.iRightAnalogPress != 0)
|
||||
__CtrlButtonDown(button[g_Config.iRightAnalogPress-1]);
|
||||
toggle(g_Config.iRightAnalogRight, dx > 0.5f, fabs(dx) > fabs(dy));
|
||||
toggle(g_Config.iRightAnalogLeft, dx < -0.5f, fabs(dx) > fabs(dy));
|
||||
toggle(g_Config.iRightAnalogUp, dy < -0.5f, fabs(dx) <= fabs(dy));
|
||||
toggle(g_Config.iRightAnalogDown, dy > 0.5f, fabs(dx) <= fabs(dy));
|
||||
toggle(g_Config.iRightAnalogPress, true);
|
||||
|
||||
posX_ = dx;
|
||||
posY_ = dy;
|
||||
|
||||
} else {
|
||||
if (g_Config.iRightAnalogUp != 0)
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogUp-1]);
|
||||
if (g_Config.iRightAnalogDown != 0)
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogDown-1]);
|
||||
if (g_Config.iRightAnalogLeft != 0)
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogLeft-1]);
|
||||
if (g_Config.iRightAnalogRight != 0)
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogRight-1]);
|
||||
if (g_Config.iRightAnalogPress != 0)
|
||||
__CtrlButtonUp(button[g_Config.iRightAnalogPress-1]);
|
||||
toggle(g_Config.iRightAnalogRight, false);
|
||||
toggle(g_Config.iRightAnalogLeft, false);
|
||||
toggle(g_Config.iRightAnalogUp, false);
|
||||
toggle(g_Config.iRightAnalogDown, false);
|
||||
toggle(g_Config.iRightAnalogPress, false);
|
||||
|
||||
posX_ = 0.0f;
|
||||
posY_ = 0.0f;
|
||||
}
|
||||
|
||||
if (release != 0)
|
||||
__CtrlButtonUp(release);
|
||||
if (press != 0)
|
||||
__CtrlButtonDown(press);
|
||||
}
|
||||
|
||||
void InitPadLayout(float xres, float yres, float globalScale) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user