mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 07:35:08 +00:00
Add separate sensitivity for gyroscope in plugin MousePad
This commit is contained in:
@@ -73,6 +73,9 @@
|
||||
<string name="mousepad_scroll_direction_title">Reverse Scrolling 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_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">
|
||||
<item>Left click</item>
|
||||
<item>Right click</item>
|
||||
|
@@ -61,7 +61,14 @@
|
||||
android:id="@+id/gyro_mouse_enabled"
|
||||
android:defaultValue="false"
|
||||
android:key="@string/gyro_mouse_enabled"
|
||||
android:title="Gyro mouse" />
|
||||
android:title="@string/gyro_mouse_enabled_title"/>
|
||||
|
||||
<SeekBarPreference
|
||||
android:id="@+id/mousepad_gyro_sensitivity"
|
||||
android:defaultValue="false"
|
||||
android:key="@string/gyro_mouse_sensitivity"
|
||||
android:title="@string/gyro_mouse_sensitivity_title" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
||||
<org.kde.kdeconnect.Helpers.LongSummaryPreferenceCategory
|
||||
|
@@ -50,6 +50,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
private int scrollDirection = 1;
|
||||
private boolean allowGyro = false;
|
||||
private boolean gyroEnabled = false;
|
||||
private int gyroscopeSensitivity = 100;
|
||||
private boolean isScrolling = false;
|
||||
private float accumulatedDistanceY = 0;
|
||||
|
||||
@@ -89,19 +90,19 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
float[] values = event.values;
|
||||
|
||||
float X = -values[2] * 70 * mCurrentSensitivity * displayDpiMultiplier;
|
||||
float Y = -values[0] * 70 * mCurrentSensitivity * displayDpiMultiplier;
|
||||
float X = -values[2] * 70 * (gyroscopeSensitivity/100.0f);
|
||||
float Y = -values[0] * 70 * (gyroscopeSensitivity/100.0f);
|
||||
|
||||
if (X < 0.25 && X > -0.25) {
|
||||
X = 0;
|
||||
} else {
|
||||
X = X * mCurrentSensitivity * displayDpiMultiplier;
|
||||
X = X * (gyroscopeSensitivity/100.0f);
|
||||
}
|
||||
|
||||
if (Y < 0.25 && Y > -0.25) {
|
||||
Y = 0;
|
||||
} else {
|
||||
Y = Y * mCurrentSensitivity * displayDpiMultiplier;
|
||||
Y = Y * (gyroscopeSensitivity/100.0f);
|
||||
}
|
||||
|
||||
final float nX = X;
|
||||
@@ -143,7 +144,9 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
}
|
||||
if ((prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false)) && (mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null)) {
|
||||
allowGyro = true;
|
||||
gyroscopeSensitivity = prefs.getInt(getString(R.string.gyro_mouse_sensitivity),100);
|
||||
}
|
||||
|
||||
String singleTapSetting = prefs.getString(getString(R.string.mousepad_single_tap_key),
|
||||
getString(R.string.mousepad_default_single));
|
||||
String doubleTapSetting = prefs.getString(getString(R.string.mousepad_double_tap_key),
|
||||
@@ -476,4 +479,3 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user