mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 23:59:21 -04:00
Feat[Gyro]: Allow to swap axis
This commit is contained in:
parent
281bb92b2d
commit
64d271a8af
@ -98,6 +98,8 @@ public class GyroControl implements SensorEventListener, GrabListener{
|
|||||||
xFactor = -1;
|
xFactor = -1;
|
||||||
yFactor = 1;
|
yFactor = 1;
|
||||||
}
|
}
|
||||||
|
if(LauncherPreferences.PREF_GYRO_INVERT_X) xFactor *= -1;
|
||||||
|
if(LauncherPreferences.PREF_GYRO_INVERT_Y) yFactor *= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,10 @@ public class LauncherPreferences {
|
|||||||
public static float PREF_GYRO_SENSITIVITY = 100;
|
public static float PREF_GYRO_SENSITIVITY = 100;
|
||||||
public static int PREF_GYRO_SAMPLE_RATE = 16;
|
public static int PREF_GYRO_SAMPLE_RATE = 16;
|
||||||
|
|
||||||
|
public static boolean PREF_GYRO_INVERT_X = false;
|
||||||
|
|
||||||
|
public static boolean PREF_GYRO_INVERT_Y = false;
|
||||||
|
|
||||||
|
|
||||||
public static void loadPreferences(Context ctx) {
|
public static void loadPreferences(Context ctx) {
|
||||||
//Required for the data folder.
|
//Required for the data folder.
|
||||||
@ -93,6 +97,8 @@ public class LauncherPreferences {
|
|||||||
PREF_ENALBE_GYRO = DEFAULT_PREF.getBoolean("enableGyro", false);
|
PREF_ENALBE_GYRO = DEFAULT_PREF.getBoolean("enableGyro", false);
|
||||||
PREF_GYRO_SENSITIVITY = ((float)DEFAULT_PREF.getInt("gyroSensitivity", 100))/100f;
|
PREF_GYRO_SENSITIVITY = ((float)DEFAULT_PREF.getInt("gyroSensitivity", 100))/100f;
|
||||||
PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16);
|
PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16);
|
||||||
|
PREF_GYRO_INVERT_X = DEFAULT_PREF.getBoolean("gyroInvertX", false);
|
||||||
|
PREF_GYRO_INVERT_Y = DEFAULT_PREF.getBoolean("gyroInvertY", false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) {
|
if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) {
|
||||||
|
@ -6,6 +6,7 @@ import android.hardware.Sensor;
|
|||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import net.kdt.pojavlaunch.R;
|
import net.kdt.pojavlaunch.R;
|
||||||
@ -51,8 +52,9 @@ public class LauncherPreferenceControlFragment extends LauncherPreferenceFragmen
|
|||||||
if(context != null) {
|
if(context != null) {
|
||||||
mGyroAvailable = ((SensorManager)context.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null;
|
mGyroAvailable = ((SensorManager)context.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null;
|
||||||
}
|
}
|
||||||
SwitchPreference gyroSwitch = findPreference("enableGyro");
|
PreferenceCategory gyroCategory = (PreferenceCategory) findPreference("gyroCategory");
|
||||||
gyroSwitch.setVisible(mGyroAvailable);
|
gyroCategory.setVisible(mGyroAvailable);
|
||||||
|
|
||||||
CustomSeekBarPreference gyroSensitivitySeek = findPreference("gyroSensitivity");
|
CustomSeekBarPreference gyroSensitivitySeek = findPreference("gyroSensitivity");
|
||||||
gyroSensitivitySeek.setRange(25, 300);
|
gyroSensitivitySeek.setRange(25, 300);
|
||||||
gyroSensitivitySeek.setValue((int) (gyroSpeed*100f));
|
gyroSensitivitySeek.setValue((int) (gyroSpeed*100f));
|
||||||
@ -71,12 +73,11 @@ public class LauncherPreferenceControlFragment extends LauncherPreferenceFragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void computeVisibility(){
|
private void computeVisibility(){
|
||||||
CustomSeekBarPreference seek2 = findPreference("timeLongPressTrigger");
|
findPreference("timeLongPressTrigger").setVisible(!LauncherPreferences.PREF_DISABLE_GESTURES);
|
||||||
seek2.setVisible(!LauncherPreferences.PREF_DISABLE_GESTURES);
|
findPreference("gyroSensitivity").setVisible(LauncherPreferences.PREF_ENALBE_GYRO);
|
||||||
CustomSeekBarPreference gyroSensitivitySeek = findPreference("gyroSensitivity");
|
findPreference("gyroSampleRate").setVisible(LauncherPreferences.PREF_ENALBE_GYRO);
|
||||||
gyroSensitivitySeek.setVisible(mGyroAvailable && LauncherPreferences.PREF_ENALBE_GYRO);
|
findPreference("gyroInvertX").setVisible(LauncherPreferences.PREF_ENALBE_GYRO);
|
||||||
CustomSeekBarPreference gyroSampleRateSeek = findPreference("gyroSampleRate");
|
findPreference("gyroInvertY").setVisible(LauncherPreferences.PREF_ENALBE_GYRO);
|
||||||
gyroSampleRateSeek.setVisible(mGyroAvailable && LauncherPreferences.PREF_ENALBE_GYRO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -289,6 +289,14 @@
|
|||||||
<string name="preference_edit_controls_title">Edit custom controls</string>
|
<string name="preference_edit_controls_title">Edit custom controls</string>
|
||||||
<string name="preference_edit_controls_summary">Tweak the control scheme to fit your needs</string>
|
<string name="preference_edit_controls_summary">Tweak the control scheme to fit your needs</string>
|
||||||
|
|
||||||
|
<string name="preference_category_gyro_controls">Gyro controls</string>
|
||||||
|
<string name="preference_category_virtual_mouse">Virtual mouse</string>
|
||||||
|
|
||||||
|
<string name="preference_gyro_invert_x_axis">Invert X axis</string>
|
||||||
|
<string name="preference_gyro_invert_y_axis">Invert Y axis</string>
|
||||||
|
<string name="preference_gyro_invert_x_axis_description">Invert the horizontal axis</string>
|
||||||
|
<string name="preference_gyro_invert_y_axis_description">Invert the vertical axis</string>
|
||||||
|
|
||||||
<string name="preference_back_title">Back to the last screen</string>
|
<string name="preference_back_title">Back to the last screen</string>
|
||||||
<string name="gles_hack_title">GL4ES Shrink hack</string>
|
<string name="gles_hack_title">GL4ES Shrink hack</string>
|
||||||
<string name="gles_hack_none">Don\'t shrink textures</string>
|
<string name="gles_hack_none">Don\'t shrink textures</string>
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="Virtual mouse">
|
android:title="@string/preference_category_virtual_mouse">
|
||||||
|
|
||||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||||
android:key="mousescale"
|
android:key="mousescale"
|
||||||
@ -77,6 +77,12 @@
|
|||||||
android:title="@string/preference_mouse_start_title"
|
android:title="@string/preference_mouse_start_title"
|
||||||
android:summary="@string/preference_mouse_start_description"
|
android:summary="@string/preference_mouse_start_description"
|
||||||
/>
|
/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="gyroCategory"
|
||||||
|
android:title="@string/preference_category_gyro_controls"
|
||||||
|
>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="enableGyro"
|
android:key="enableGyro"
|
||||||
android:title="@string/preference_enable_gyro_title"
|
android:title="@string/preference_enable_gyro_title"
|
||||||
@ -94,6 +100,15 @@
|
|||||||
android:summary="@string/preference_gyro_sample_rate_description"
|
android:summary="@string/preference_gyro_sample_rate_description"
|
||||||
app2:selectable="false"
|
app2:selectable="false"
|
||||||
app2:showSeekBarValue="true"/>
|
app2:showSeekBarValue="true"/>
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="gyroInvertX"
|
||||||
|
android:title="@string/preference_gyro_invert_x_axis"
|
||||||
|
android:summary="@string/preference_gyro_invert_x_axis_description"/>
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="gyroInvertY"
|
||||||
|
android:title="@string/preference_gyro_invert_y_axis"
|
||||||
|
android:summary="@string/preference_gyro_invert_y_axis_description"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user