Skip to content

Edge scrolling in Touchpad mode#2478

Open
stanissay wants to merge 9 commits intoHeliBorg:mainfrom
stanissay:touchpad_autoscroll
Open

Edge scrolling in Touchpad mode#2478
stanissay wants to merge 9 commits intoHeliBorg:mainfrom
stanissay:touchpad_autoscroll

Conversation

@stanissay
Copy link
Copy Markdown
Contributor

Summary

  • Edge Scrolling: Implemented automatic vertical and horizontal scrolling when reaching the edges of the keyboard in Touchpad mode.
  • Settings: Added a toggle in settings to enable or disable this feature.
  • Haptic Feedback: Added haptic feedback upon Touchpad mode activation (after debounce).
    Note: I implemented this using KeyboardActionListener.onCustomRequest. I am open to suggestions if there is a more direct or "cleaner" architectural approach to handle haptic feedback.

How it works

  • Enabled: While in Touchpad mode, move your finger to the edge of the keyboard area (Top – suggestion/tool row, Bottom – near the spacebar, Left/Right edges) to trigger auto-scrolling in that direction. Moving the finger away from the edge resumes manual cursor control.
  • Disabled: Manual cursor control remains active across the entire screen area.

Demo
See the attached video demonstrating the auto-scroll functionality
https://github.com/user-attachments/assets/240e3fa3-e3f3-465e-9ce3-a5736af38d54

@Helium314
Copy link
Copy Markdown
Collaborator

Thanks for the upgrade, this is working nicely!
Can you add some acceleration based on time spent in the edge area? On first glance it might be a rather simple change, but I didn't investigate further.


int keyboardHeight = currentKeyboard.mBaseHeight;
int keyboardWidth = currentKeyboard.mBaseWidth;
int threshold = 50;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in pixels, right? It would be better to use dp, or maybe some percentage of the keyboard size so behavior is the same for low and high resolution devices.

@stanissay
Copy link
Copy Markdown
Contributor Author

@Helium314 Calculating screen edges based on percentages is a great idea! I’ve implemented this change.

I also added acceleration during auto-scrolling:

  • I linked the initial scroll delay to the "touchpad sensitivity" setting. If the user has high sensitivity, the initial step is faster; with lower sensitivity, the cursor starts more slowly.

  • I implemented acceleration using an exponential decay factor (currently set to 0.95f).

I initially considered using a linear approach (subtracting a fixed value). I even linked that value to the TOUCHPAD_ACCELERATION_FACTOR used for cursor control, but the exponential acceleration feels much smoother, so I decided to stick with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants