Use origin value for touch joysticks if pythagorean result is 0

This commit is contained in:
Aaron Culliney 2019-11-09 17:10:54 -08:00
parent f654fb0825
commit bf4f76a142
2 changed files with 8 additions and 8 deletions

View File

@ -204,7 +204,13 @@ static void _touchjoy_buttonMove(int dx, int dy) {
touchjoy_button_type_t theButtonChar = joys.touchDownChar;
int c = (int)sqrtf(dx * dx + dy * dy);
if (c >= joyglobals.switchThreshold) {
if (!c || c < joyglobals.switchThreshold) {
// 2019/04/20 NOTE: originally we did not re-zero back to touchDownChar ... this allowed a progression between
// southChar/northChar (or vice-versa)
//
// touchDownChar should be fired on a tap or long-press (once we swipe beyond the threshold, we should only switch
// between northChar and southChar)
} else {
// unambiguous intent : user swiped beyond threshold
shouldFire = true;
@ -218,12 +224,6 @@ static void _touchjoy_buttonMove(int dx, int dy) {
// prefer x axis ...
theButtonChar = (xChar != TOUCH_NONE) ? xChar : yChar;
}
} else {
// 2019/04/20 NOTE: originally we did not re-zero back to touchDownChar ... this allowed a progression between
// southChar/northChar (or vice-versa)
//
// touchDownChar should be fired on a tap or long-press (once we swipe beyond the threshold, we should only switch
// between northChar and southChar)
}
if (shouldFire) {

View File

@ -267,7 +267,7 @@ static void _subvariant_touchMove(subvariant_s *subvariant, int dx, int dy, bool
keypad_octant_t lastOctant = subvariant->currentOctant;
do {
int c = (int)sqrtf(dx * dx + dy * dy);
if (c < joyglobals.switchThreshold) {
if (!c || c < joyglobals.switchThreshold) {
if (lastOctant != ORIGIN) {
// unambiguous intent : user swiped beyond origin, then re-zeroed
subvariant->currentOctant = ORIGIN;