diff --git a/app/src/main/java/xtr/keymapper/fragment/SettingsFragment.java b/app/src/main/java/xtr/keymapper/fragment/SettingsFragment.java index c4de5b81..441889b3 100644 --- a/app/src/main/java/xtr/keymapper/fragment/SettingsFragment.java +++ b/app/src/main/java/xtr/keymapper/fragment/SettingsFragment.java @@ -79,6 +79,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat return false; }); mouseAimActions(); + loadTouchpadInputSettings(); setDefaultVisibilty(); binding.sliders.setVisibility(View.VISIBLE); } @@ -137,6 +138,13 @@ private void mouseAimActions() { ((MaterialAutoCompleteTextView)binding.mouseAimAction).setSimpleItems(mouseAimActions); } + private void loadTouchpadInputSettings() { + binding.touchpadInputMode.setText(keymapConfig.touchpadInputMode); + + final String[] touchpadInputModes = {KeymapConfig.TOUCHPAD_DIRECT, KeymapConfig.TOUCHPAD_RELATIVE, KeymapConfig.TOUCHPAD_DISABLED}; + ((MaterialAutoCompleteTextView)binding.touchpadInputMode).setSimpleItems(touchpadInputModes); + } + public boolean onKey(View view, int keyCode, KeyEvent event) { String key = String.valueOf(event.getDisplayLabel()); if ( key.matches("[a-zA-Z0-9]+" )) ((EditText) view).setText(key); @@ -177,6 +185,7 @@ private void saveKeyboardShortcuts() { public void onDestroyView() { saveKeyboardShortcuts(); keymapConfig.mouseAimToggle = binding.mouseAimAction.getText().toString().equals(KeymapConfig.TOGGLE); + keymapConfig.touchpadInputMode = binding.touchpadInputMode.getText().toString(); keymapConfig.mouseSensitivity = binding.sliderMouse.getValue(); keymapConfig.scrollSpeed = binding.sliderScrollSpeed.getValue(); diff --git a/app/src/main/java/xtr/keymapper/keymap/KeymapConfig.java b/app/src/main/java/xtr/keymapper/keymap/KeymapConfig.java index fda5053f..8492c8af 100644 --- a/app/src/main/java/xtr/keymapper/keymap/KeymapConfig.java +++ b/app/src/main/java/xtr/keymapper/keymap/KeymapConfig.java @@ -22,12 +22,12 @@ public class KeymapConfig implements Parcelable { public static final String KEY_CTRL = "Ctrl", KEY_ALT = "Alt"; public static final String TOGGLE = "Toggle", HOLD = "Hold"; - public static final int TOUCHPAD_DIRECT = 0; - public static final int TOUCHPAD_RELATIVE = 1; - public static final int TOUCHPAD_DISABLED = 2; + public static final String TOUCHPAD_DIRECT = "Direct"; + public static final String TOUCHPAD_RELATIVE = "Relative"; + public static final String TOUCHPAD_DISABLED = "Disabled"; public int mouseAimShortcutKey; public boolean mouseAimToggle; - public int touchpadInputMode; + public String touchpadInputMode; public KeymapConfig(Context context) { sharedPref = context.getSharedPreferences("settings", MODE_PRIVATE); @@ -64,7 +64,7 @@ protected KeymapConfig(Parcel in) { mouseAimShortcutKey = in.readInt(); mouseAimToggle = in.readByte() != 0; disableAutoProfiling = in.readByte() != 0; - touchpadInputMode = in.readInt(); + touchpadInputMode = in.readString(); } public static final Creator CREATOR = new Creator<>() { @@ -102,7 +102,7 @@ private void loadSharedPrefs() { swipeDelayMs = sharedPref.getInt("swipe_delay_ms", 0); dpadRadiusMultiplier = sharedPref.getFloat("dpad_radius", 1f); - touchpadInputMode = sharedPref.getInt("touchpad_input_mode", TOUCHPAD_RELATIVE); + touchpadInputMode = sharedPref.getString("touchpad_input_mode", TOUCHPAD_RELATIVE); } public void applySharedPrefs() { @@ -122,8 +122,8 @@ public void applySharedPrefs() { .putString("pause_resume_shortcut_modifier", pauseResumeShortcutKeyModifier) .putString("launch_editor_shortcut_modifier", launchEditorShortcutKeyModifier) .putString("switch_profile_shortcut_modifier", switchProfileShortcutKeyModifier) + .putString("touchpad_input_mode", touchpadInputMode) .putInt("swipe_delay_ms", swipeDelayMs) - .putInt("touchpad_input_mode", touchpadInputMode) .apply(); } @@ -166,6 +166,6 @@ public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mouseAimShortcutKey); dest.writeByte((byte) (mouseAimToggle ? 1 : 0)); dest.writeByte((byte) (disableAutoProfiling ? 1 : 0)); - dest.writeInt(touchpadInputMode); + dest.writeString(touchpadInputMode); } } diff --git a/app/src/main/res/layout/fragment_settings_dialog.xml b/app/src/main/res/layout/fragment_settings_dialog.xml index ad4b2457..688e4a25 100644 --- a/app/src/main/res/layout/fragment_settings_dialog.xml +++ b/app/src/main/res/layout/fragment_settings_dialog.xml @@ -319,6 +319,34 @@ android:layout_height="match_parent" android:checked="true" android:text="@string/disable_auto_profile" /> + + + + + + + + + + + + + + Root access not found Root access is required for the keymapper to function. \n Please grant root access to XtMapper from KernelSU manager app: Disable auto profiling + Touchpad Input \ No newline at end of file