mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-03-12 05:25:23 -07:00
Add Option to disable Motion on Android
This commit is contained in:
parent
bae081d5b3
commit
28f017d640
android/app/src/main
java/com/metallic/chiaki
res
@ -78,6 +78,11 @@ class Preferences(context: Context)
|
||||
get() = sharedPreferences.getBoolean(rumbleEnabledKey, true)
|
||||
set(value) { sharedPreferences.edit().putBoolean(rumbleEnabledKey, value).apply() }
|
||||
|
||||
val motionEnabledKey get() = resources.getString(R.string.preferences_motion_enabled_key)
|
||||
var motionEnabled
|
||||
get() = sharedPreferences.getBoolean(motionEnabledKey, true)
|
||||
set(value) { sharedPreferences.edit().putBoolean(motionEnabledKey, value).apply() }
|
||||
|
||||
val logVerboseKey get() = resources.getString(R.string.preferences_log_verbose_key)
|
||||
var logVerbose
|
||||
get() = sharedPreferences.getBoolean(logVerboseKey, false)
|
||||
|
@ -86,7 +86,7 @@ class StreamInput(val context: Context, val preferences: Preferences)
|
||||
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {}
|
||||
}
|
||||
|
||||
private val lifecycleObserver = object: LifecycleObserver {
|
||||
private val motionLifecycleObserver = object: LifecycleObserver {
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
fun onResume()
|
||||
{
|
||||
@ -111,7 +111,8 @@ class StreamInput(val context: Context, val preferences: Preferences)
|
||||
|
||||
fun observe(lifecycleOwner: LifecycleOwner)
|
||||
{
|
||||
lifecycleOwner.lifecycle.addObserver(lifecycleObserver)
|
||||
if(preferences.motionEnabled)
|
||||
lifecycleOwner.lifecycle.addObserver(motionLifecycleObserver)
|
||||
}
|
||||
|
||||
private fun controllerStateUpdated()
|
||||
|
@ -26,6 +26,7 @@ class DataStore(val preferences: Preferences): PreferenceDataStore()
|
||||
preferences.logVerboseKey -> preferences.logVerbose
|
||||
preferences.swapCrossMoonKey -> preferences.swapCrossMoon
|
||||
preferences.rumbleEnabledKey -> preferences.rumbleEnabled
|
||||
preferences.motionEnabledKey -> preferences.motionEnabled
|
||||
else -> defValue
|
||||
}
|
||||
|
||||
@ -36,6 +37,7 @@ class DataStore(val preferences: Preferences): PreferenceDataStore()
|
||||
preferences.logVerboseKey -> preferences.logVerbose = value
|
||||
preferences.swapCrossMoonKey -> preferences.swapCrossMoon = value
|
||||
preferences.rumbleEnabledKey -> preferences.rumbleEnabled = value
|
||||
preferences.motionEnabledKey -> preferences.motionEnabled = value
|
||||
}
|
||||
}
|
||||
|
||||
|
9
android/app/src/main/res/drawable/ic_motion.xml
Normal file
9
android/app/src/main/res/drawable/ic_motion.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?android:attr/textColorPrimary"
|
||||
android:pathData="M16.48,2.52c3.27,1.55 5.61,4.72 5.97,8.48h1.5C23.44,4.84 18.29,0 12,0l-0.66,0.03 3.81,3.81 1.33,-1.32zM10.23,1.75c-0.59,-0.59 -1.54,-0.59 -2.12,0L1.75,8.11c-0.59,0.59 -0.59,1.54 0,2.12l12.02,12.02c0.59,0.59 1.54,0.59 2.12,0l6.36,-6.36c0.59,-0.59 0.59,-1.54 0,-2.12L10.23,1.75zM14.83,21.19L2.81,9.17l6.36,-6.36 12.02,12.02 -6.36,6.36zM7.52,21.48C4.25,19.94 1.91,16.76 1.55,13L0.05,13C0.56,19.16 5.71,24 12,24l0.66,-0.03 -3.81,-3.81 -1.33,1.32z"/>
|
||||
</vector>
|
@ -90,6 +90,8 @@
|
||||
<string name="preferences_swap_cross_moon_summary">Swap face buttons if default mapping is incorrect (e.g. for 8BitDo controllers)</string>
|
||||
<string name="preferences_rumble_enabled_title">Rumble</string>
|
||||
<string name="preferences_rumble_enabled_summary">Use phone vibration motor for rumble</string>
|
||||
<string name="preferences_motion_enabled_title">Motion</string>
|
||||
<string name="preferences_motion_enabled_summary">Use device\'s motion sensors for controller motion</string>
|
||||
<string name="alert_message_delete_registered_host">Are you sure you want to delete the registered console %s with ID %s?</string>
|
||||
<string name="alert_message_delete_manual_host">Are you sure you want to delete the console entry for %s?</string>
|
||||
<string name="action_keep">Keep</string>
|
||||
@ -105,6 +107,7 @@
|
||||
<string name="preferences_on_screen_controls_enabled_key">on_screen_controls_enabled</string>
|
||||
<string name="preferences_touchpad_only_enabled_key">touchpad_only_enabled</string>
|
||||
<string name="preferences_rumble_enabled_key">rumble_enabled</string>
|
||||
<string name="preferences_motion_enabled_key">motion_enabled</string>
|
||||
<string name="preferences_log_verbose_key">log_verbose</string>
|
||||
<string name="preferences_import_settings_key">import_settings</string>
|
||||
<string name="preferences_export_settings_key">export_settings</string>
|
||||
|
@ -25,6 +25,12 @@
|
||||
app:summary="@string/preferences_rumble_enabled_summary"
|
||||
app:icon="@drawable/ic_rumble" />
|
||||
|
||||
<SwitchPreference
|
||||
app:key="@string/preferences_motion_enabled_key"
|
||||
app:title="@string/preferences_motion_enabled_title"
|
||||
app:summary="@string/preferences_motion_enabled_summary"
|
||||
app:icon="@drawable/ic_motion" />
|
||||
|
||||
<SwitchPreference
|
||||
app:key="@string/preferences_log_verbose_key"
|
||||
app:title="@string/preferences_log_verbose_title"
|
||||
|
Loading…
x
Reference in New Issue
Block a user