mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 05:37:43 +00:00
Adjust the touchpad sensitivity
This commit is contained in:
parent
a75db516ec
commit
e3c5ac9228
@ -33,8 +33,10 @@
|
||||
<string name="mousepad_info">Move a finger on the screen to move the mouse cursor. Tap for a click, and use two/three fingers for right and middle buttons. Use a long press to drag\'n drop.</string>
|
||||
<string name="mousepad_double_tap_settings_title">Set two finger tap action</string>
|
||||
<string name="mousepad_triple_tap_settings_title">Set three finger tap action</string>
|
||||
<string name="mousepad_sensitivity_settings_title">Set touchpad sensitivity</string>
|
||||
<string name="mousepad_double_tap_key" translatable="false">mousepad_double_tap_key</string>
|
||||
<string name="mousepad_triple_tap_key" translatable="false">mousepad_triple_tap_key</string>
|
||||
<string name="mousepad_sensitivity_key" translatable="false">mousepad_sensitivity_key</string>
|
||||
<string name="mousepad_scroll_direction_title">Reverse Scrolling Direction</string>
|
||||
<string name="mousepad_scroll_direction" translatable="false">mousepad_scroll_direction</string>
|
||||
<string-array name="mousepad_tap_entries">
|
||||
@ -44,11 +46,26 @@
|
||||
</string-array>
|
||||
<string name="mousepad_double_default">right</string>
|
||||
<string name="mousepad_triple_default">middle</string>
|
||||
<string name="mousepad_sensitivity_default">default</string>
|
||||
<string-array name="mousepad_tap_values" translatable="false">
|
||||
<item>right</item>
|
||||
<item>middle</item>
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
<string-array name="mousepad_sensitivity_entries">
|
||||
<item>Slowest</item>
|
||||
<item>Above Slowest</item>
|
||||
<item>Default</item>
|
||||
<item>Above Default</item>
|
||||
<item>Fastest</item>
|
||||
</string-array>
|
||||
<string-array name="mousepad_sensitivity_values" translatable="false">
|
||||
<item>slowest</item>
|
||||
<item>aboveSlowest</item>
|
||||
<item>default</item>
|
||||
<item>aboveDefault</item>
|
||||
<item>fastest</item>
|
||||
</string-array>
|
||||
<string name="category_connected_devices">Connected devices</string>
|
||||
<string name="category_not_paired_devices">Available devices</string>
|
||||
<string name="category_remembered_devices">Remembered devices</string>
|
||||
|
@ -20,6 +20,16 @@
|
||||
android:entries="@array/mousepad_tap_entries"
|
||||
android:entryValues="@array/mousepad_tap_values"
|
||||
android:defaultValue="@string/mousepad_triple_default" />
|
||||
|
||||
<ListPreference
|
||||
android:id="@+id/mousepad_sensitivity_preference"
|
||||
android:key="@string/mousepad_sensitivity_key"
|
||||
android:title="@string/mousepad_sensitivity_settings_title"
|
||||
android:summary="%s"
|
||||
android:entries="@array/mousepad_sensitivity_entries"
|
||||
android:entryValues="@array/mousepad_sensitivity_values"
|
||||
android:defaultValue="@string/mousepad_sensitivity_default" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:id="@+id/mousepad_scroll_preference"
|
||||
android:key="@string/mousepad_scroll_direction"
|
||||
|
@ -40,7 +40,6 @@ import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
public class MousePadActivity extends ActionBarActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, MousePadGestureDetector.OnGestureListener {
|
||||
|
||||
String deviceId;
|
||||
|
||||
private final static float MinDistanceToSendScroll = 2.5f;
|
||||
@ -49,6 +48,7 @@ public class MousePadActivity extends ActionBarActivity implements GestureDetect
|
||||
private float mPrevY;
|
||||
private float mCurrentX;
|
||||
private float mCurrentY;
|
||||
private float mCurrentSensitivity;
|
||||
private int scrollDirection = 1;
|
||||
|
||||
boolean isScrolling = false;
|
||||
@ -99,10 +99,32 @@ public class MousePadActivity extends ActionBarActivity implements GestureDetect
|
||||
getString(R.string.mousepad_double_default));
|
||||
String tripleTapSetting = prefs.getString(getString(R.string.mousepad_triple_tap_key),
|
||||
getString(R.string.mousepad_triple_default));
|
||||
String sensitivitySetting = prefs.getString(getString(R.string.mousepad_sensitivity_key),
|
||||
getString(R.string.mousepad_sensitivity_default));
|
||||
|
||||
doubleTapAction = ClickType.fromString(doubleTapSetting);
|
||||
tripleTapAction = ClickType.fromString(tripleTapSetting);
|
||||
|
||||
switch (sensitivitySetting){
|
||||
case "slowest":
|
||||
mCurrentSensitivity = 0.2f;
|
||||
break;
|
||||
case "aboveSlowest":
|
||||
mCurrentSensitivity = 0.5f;
|
||||
break;
|
||||
case "default":
|
||||
mCurrentSensitivity = 1.0f;
|
||||
break;
|
||||
case "aboveDefault":
|
||||
mCurrentSensitivity = 1.5f;
|
||||
break;
|
||||
case "fastest":
|
||||
mCurrentSensitivity = 2.0f;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
|
||||
@ -190,7 +212,7 @@ public class MousePadActivity extends ActionBarActivity implements GestureDetect
|
||||
Device device = service.getDevice(deviceId);
|
||||
MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class);
|
||||
if (mousePadPlugin == null) return;
|
||||
mousePadPlugin.sendMouseDelta(mCurrentX - mPrevX, mCurrentY - mPrevY);
|
||||
mousePadPlugin.sendMouseDelta(mCurrentX - mPrevX, mCurrentY - mPrevY, mCurrentSensitivity);
|
||||
mPrevX = mCurrentX;
|
||||
mPrevY = mCurrentY;
|
||||
}
|
||||
|
@ -78,10 +78,12 @@ public class MousePadPlugin extends Plugin {
|
||||
return context.getString(R.string.open_mousepad);
|
||||
}
|
||||
|
||||
public void sendMouseDelta(float dx, float dy) {
|
||||
public void sendMouseDelta(float dx, float dy, float sensitivity) {
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MOUSEPAD);
|
||||
np.set("dx", dx);
|
||||
np.set("dy", dy);
|
||||
|
||||
np.set("dx", dx*sensitivity);
|
||||
np.set("dy", dy*sensitivity);
|
||||
|
||||
device.sendPackage(np);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user