mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Add acceleration to remote input cursor
Summary: This patch adds cursor acceleration to KDEConnect's remote input plugin. The cursor movement is now scaled down if the movement is slow, and scaled up if the movement is fast. The acceleration is implemented on the android side. An additional setting was added to the android app's Remote Control plugin preferences, allowing the user to choose the strength of the acceleration, or to disable the acceleration completely. Test Plan: After installing this revision on your android device, go to the remote input page and start using the mousepad. Cursor acceleration should be enabled by default. Check if the cursor acceleration is intuitive and easy to use. Also, try tweaking the acceleration in the Remote input settings in the Plugin settings menu. Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: albertvaka, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D14720
This commit is contained in:
committed by
Albert Vaca
parent
c6603029ec
commit
6db7ffd1db
@@ -60,6 +60,9 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
|
||||
private GestureDetector mDetector;
|
||||
private MousePadGestureDetector mMousePadGestureDetector;
|
||||
private PointerAccelerationProfile mPointerAccelerationProfile;
|
||||
|
||||
private PointerAccelerationProfile.MouseDelta mouseDelta; // to be reused on every touch move event
|
||||
|
||||
KeyListenerView keyListenerView;
|
||||
|
||||
@@ -111,6 +114,11 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
String sensitivitySetting = prefs.getString(getString(R.string.mousepad_sensitivity_key),
|
||||
getString(R.string.mousepad_default_sensitivity));
|
||||
|
||||
String accelerationProfileName=prefs.getString(getString(R.string.mousepad_acceleration_profile_key),
|
||||
getString(R.string.mousepad_default_acceleration_profile));
|
||||
|
||||
mPointerAccelerationProfile = PointerAccelerationProfileFactory.getProfileWithName(accelerationProfileName);
|
||||
|
||||
doubleTapAction = ClickType.fromString(doubleTapSetting);
|
||||
tripleTapAction = ClickType.fromString(tripleTapSetting);
|
||||
|
||||
@@ -221,10 +229,16 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
Device device = service.getDevice(deviceId);
|
||||
MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class);
|
||||
if (mousePadPlugin == null) return;
|
||||
mousePadPlugin.sendMouseDelta(
|
||||
(mCurrentX - mPrevX) * displayDpiMultiplier,
|
||||
(mCurrentY - mPrevY) * displayDpiMultiplier,
|
||||
mCurrentSensitivity);
|
||||
|
||||
float deltaX = (mCurrentX - mPrevX) * displayDpiMultiplier * mCurrentSensitivity;
|
||||
float deltaY = (mCurrentY - mPrevY) * displayDpiMultiplier * mCurrentSensitivity;
|
||||
|
||||
// Run the mouse delta through the pointer acceleration profile
|
||||
mPointerAccelerationProfile.touchMoved(deltaX, deltaY, event.getEventTime());
|
||||
mouseDelta = mPointerAccelerationProfile.commitAcceleratedMouseDelta(mouseDelta);
|
||||
|
||||
mousePadPlugin.sendMouseDelta(mouseDelta.x,mouseDelta.y);
|
||||
|
||||
mPrevX = mCurrentX;
|
||||
mPrevY = mCurrentY;
|
||||
});
|
||||
|
Reference in New Issue
Block a user