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

fix(web): longpress shortcut activation should only consider northward part #11306

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion web/src/engine/osk/src/input/gestures/specsForLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ export function longpressContactModel(params: GestureParams, enabledFlicks: bool
* each side of due N in total.
*/
if((enabledFlicks && spec.permitsFlick(stats.lastSample.item)) && (stats.cardinalDirection?.indexOf('n') != -1 ?? false)) {
if(stats.netDistance > spec.flickDist) {
const baseDistance = stats.netDistance;
const angle = stats.angle; // from <0, -1> (straight up) going clockwise.
const verticalDistance = baseDistance * Math.cos(angle);
if(verticalDistance > spec.flickDist) {
return 'resolve';
}
} else if(resetForRoaming) {
Expand Down
12 changes: 10 additions & 2 deletions web/src/engine/osk/src/visualKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1298,9 +1298,17 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
Note: longpress.flickDist needs to be no greater than flick.startDist.
Otherwise, the longpress up-flick shortcut will not work on keys that
support flick gestures. (Such as sil_euro_latin 3.0+)

Since it's also based on the purely northward component, it's best to
have it be slightly lower. 80% of flick.startDist gives a range of
about 37 degrees to each side before a flick-start would win, while
70.7% gives 45 degrees.

(The range _will_ be notably tighter on keys with both longpresses and
flicks as a result.)
*/
this.gestureParams.longpress.flickDist = 0.25 * this.currentLayer.rowHeight;
this.gestureParams.flick.startDist = 0.25 * this.currentLayer.rowHeight;
this.gestureParams.longpress.flickDist = 0.24 * this.currentLayer.rowHeight;
this.gestureParams.flick.startDist = 0.30 * this.currentLayer.rowHeight;
this.gestureParams.flick.dirLockDist = 0.35 * this.currentLayer.rowHeight;
this.gestureParams.flick.triggerDist = 0.75 * this.currentLayer.rowHeight;
}
Expand Down
Loading