2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

Add scroll sensitivity option for MousePadPlugin

Added a seekbar to adjust the scrolling speed of the touchpad

BUG: 407293
This commit is contained in:
Matteo Princisgh
2024-01-18 22:15:24 +00:00
committed by Albert Vaca Cintora
parent 7ffc6a742c
commit 3cacafad29
3 changed files with 15 additions and 1 deletions

View File

@@ -80,6 +80,8 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<string name="mousepad_acceleration_profile_key" translatable="false">mousepad_acceleration_profile_key</string>
<string name="mousepad_scroll_direction_title">Reverse Scrolling Direction</string>
<string name="mousepad_scroll_direction" translatable="false">mousepad_scroll_direction</string>
<string name="mousepad_scroll_sensitivity" translatable="false">mousepad_scroll_sensitivity</string>
<string name="mousepad_scroll_sensitivity_title">Scroll sensitivity</string>
<string name="gyro_mouse_enabled" translatable="false">gyro_mouse_enabled</string>
<string name="mousepad_mouse_buttons_enabled_pref" translatable="false">mouse_buttons_enabled</string>
<string name="gyro_mouse_enabled_title">Enable gyroscope mouse</string>

View File

@@ -63,6 +63,13 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
android:key="@string/mousepad_scroll_direction"
android:title="@string/mousepad_scroll_direction_title" />
<SeekBarPreference
android:id="@+id/mousepad_scroll_sensitivity_pref"
android:defaultValue="100"
android:key="@string/mousepad_scroll_sensitivity"
android:title="@string/mousepad_scroll_sensitivity_title"
android:layout_width="wrap_content" />
<SwitchPreference
android:id="@+id/gyro_mouse_enabled"

View File

@@ -53,6 +53,7 @@ public class MousePadActivity
private float mCurrentSensitivity;
private float displayDpiMultiplier;
private int scrollDirection = 1;
private double scrollCoefficient = 1.0;
private boolean allowGyro = false;
private boolean gyroEnabled = false;
private int gyroscopeSensitivity = 100;
@@ -364,7 +365,7 @@ public class MousePadActivity
isScrolling = true;
accumulatedDistanceY += distanceY;
accumulatedDistanceY += distanceY * scrollCoefficient;
if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll) {
sendScroll(scrollDirection * accumulatedDistanceY);
@@ -520,6 +521,10 @@ public class MousePadActivity
scrollDirection = 1;
}
int scrollSensitivity = prefs.getInt(getString(R.string.mousepad_scroll_sensitivity), 100);
if (scrollSensitivity == 0) scrollSensitivity = 1;
scrollCoefficient = Math.pow((scrollSensitivity / 100f), 1.5);
allowGyro = isGyroSensorAvailable() && prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false);
if (allowGyro) gyroscopeSensitivity = prefs.getInt(getString(R.string.gyro_mouse_sensitivity), 100);