2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-02 07:05:09 +00:00

Merge remote-tracking branch 'kubawis/master' into mouse_pad_prefs_fix

# Conflicts:
#	res/values/strings.xml
#	res/xml/mousepadplugin_preferences.xml
#	src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java
This commit is contained in:
Dmitry Yudin
2023-04-25 01:41:51 +02:00
2 changed files with 10 additions and 7 deletions

View File

@@ -75,6 +75,9 @@
<string name="mousepad_scroll_direction" translatable="false">mousepad_scroll_direction</string> <string name="mousepad_scroll_direction" translatable="false">mousepad_scroll_direction</string>
<string name="gyro_mouse_enabled" translatable="false">gyro_mouse_enabled</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="mousepad_mouse_buttons_enabled_pref" translatable="false">mouse_buttons_enabled</string>
<string name="gyro_mouse_enabled_title">Enable gyroscope mouse</string>
<string name="gyro_mouse_sensitivity_title">Gyroscope sensitivity</string>
<string name="gyro_mouse_sensitivity" translatable="false">gyro_mouse_sensitivity</string>
<string-array name="mousepad_tap_entries"> <string-array name="mousepad_tap_entries">
<item>Left click</item> <item>Left click</item>
<item>Right click</item> <item>Right click</item>

View File

@@ -55,6 +55,7 @@ public class MousePadActivity
private int scrollDirection = 1; private int scrollDirection = 1;
private boolean allowGyro = false; private boolean allowGyro = false;
private boolean gyroEnabled = false; private boolean gyroEnabled = false;
private int gyroscopeSensitivity = 100;
private boolean isScrolling = false; private boolean isScrolling = false;
private float accumulatedDistanceY = 0; private float accumulatedDistanceY = 0;
@@ -98,27 +99,25 @@ public class MousePadActivity
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
float[] values = event.values; float[] values = event.values;
float X = -values[2] * 70 * mCurrentSensitivity * displayDpiMultiplier; float X = -values[2] * 70 * (gyroscopeSensitivity/100.0f);
float Y = -values[0] * 70 * mCurrentSensitivity * displayDpiMultiplier; float Y = -values[0] * 70 * (gyroscopeSensitivity/100.0f);
if (X < 0.25 && X > -0.25) { if (X < 0.25 && X > -0.25) {
X = 0; X = 0;
} else { } else {
X = X * mCurrentSensitivity * displayDpiMultiplier; X = X * (gyroscopeSensitivity/100.0f);
} }
if (Y < 0.25 && Y > -0.25) { if (Y < 0.25 && Y > -0.25) {
Y = 0; Y = 0;
} else { } else {
Y = Y * mCurrentSensitivity * displayDpiMultiplier; Y = Y * (gyroscopeSensitivity/100.0f);
} }
final float nX = X; final float nX = X;
final float nY = Y; final float nY = Y;
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> { BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> plugin.sendMouseDelta(nX, nY));
plugin.sendMouseDelta(nX, nY);
});
} }
@Override @Override
@@ -479,6 +478,7 @@ public class MousePadActivity
} }
allowGyro = isGyroSensorAvailable() && prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false); allowGyro = isGyroSensorAvailable() && prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false);
if (allowGyro) gyroscopeSensitivity = prefs.getInt(getString(R.string.gyro_mouse_sensitivity),100);
String singleTapSetting = prefs.getString(getString(R.string.mousepad_single_tap_key), String singleTapSetting = prefs.getString(getString(R.string.mousepad_single_tap_key),
getString(R.string.mousepad_default_single)); getString(R.string.mousepad_default_single));