Merge pull request #12823 from iota97/analog-rot-square
Auto rotate over a square
This commit is contained in:
commit
30eebe2f1d
2 changed files with 8 additions and 6 deletions
|
@ -1186,12 +1186,13 @@ void EmuScreen::update() {
|
||||||
|
|
||||||
if (autoRotatingAnalogCW_) {
|
if (autoRotatingAnalogCW_) {
|
||||||
const float now = time_now_d();
|
const float now = time_now_d();
|
||||||
__CtrlSetAnalogX(cos(now*-g_Config.fAnalogAutoRotSpeed), 0);
|
// Clamp to a square
|
||||||
__CtrlSetAnalogY(sin(now*-g_Config.fAnalogAutoRotSpeed), 0);
|
__CtrlSetAnalogX(std::min(1.0f, std::max(-1.0f, 1.42f*cosf(now*-g_Config.fAnalogAutoRotSpeed))), 0);
|
||||||
|
__CtrlSetAnalogY(std::min(1.0f, std::max(-1.0f, 1.42f*sinf(now*-g_Config.fAnalogAutoRotSpeed))), 0);
|
||||||
} else if (autoRotatingAnalogCCW_) {
|
} else if (autoRotatingAnalogCCW_) {
|
||||||
const float now = time_now_d();
|
const float now = time_now_d();
|
||||||
__CtrlSetAnalogX(cos(now*g_Config.fAnalogAutoRotSpeed), 0);
|
__CtrlSetAnalogX(std::min(1.0f, std::max(-1.0f, 1.42f*cosf(now*g_Config.fAnalogAutoRotSpeed))), 0);
|
||||||
__CtrlSetAnalogY(sin(now*g_Config.fAnalogAutoRotSpeed), 0);
|
__CtrlSetAnalogY(std::min(1.0f, std::max(-1.0f, 1.42f*sinf(now*g_Config.fAnalogAutoRotSpeed))), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is here to support the iOS on screen back button.
|
// This is here to support the iOS on screen back button.
|
||||||
|
|
|
@ -202,8 +202,9 @@ void AnalogRotationButton::Update() {
|
||||||
|
|
||||||
if (autoRotating_) {
|
if (autoRotating_) {
|
||||||
float speed = clockWise_ ? -g_Config.fAnalogAutoRotSpeed : g_Config.fAnalogAutoRotSpeed;
|
float speed = clockWise_ ? -g_Config.fAnalogAutoRotSpeed : g_Config.fAnalogAutoRotSpeed;
|
||||||
__CtrlSetAnalogX(cos(now*speed), 0);
|
// Clamp to a square
|
||||||
__CtrlSetAnalogY(sin(now*speed), 0);
|
__CtrlSetAnalogX(std::min(1.0f, std::max(-1.0f, 1.42f*cosf(now*speed))), 0);
|
||||||
|
__CtrlSetAnalogY(std::min(1.0f, std::max(-1.0f, 1.42f*sinf(now*speed))), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue