diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java b/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java index a53ea1fd2..e26f9b61b 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/AndroidHostInterface.java @@ -72,13 +72,17 @@ public class AndroidHostInterface { public static native int getControllerAxisCode(String controllerType, String axisName); public static native String[] getControllerButtonNames(String controllerType); + public static native String[] getControllerAxisNames(String controllerType); public native void handleControllerButtonEvent(int controllerIndex, int buttonIndex, boolean pressed); + public native void handleControllerAxisEvent(int controllerIndex, int axisIndex, float value); public native String[] getInputProfileNames(); + public native boolean loadInputProfile(String name); + public native boolean saveInputProfile(String name); public native HotkeyInfo[] getHotkeyInfoList(); @@ -90,6 +94,7 @@ public class AndroidHostInterface { public native GameListEntry getGameListEntry(String path); public native String getGameSettingValue(String path, String key); + public native void setGameSettingValue(String path, String key, String value); public native void resetSystem(); diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingPreference.java b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingPreference.java index cc9468bc8..01c4687ed 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingPreference.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingPreference.java @@ -89,16 +89,21 @@ public class ControllerBindingPreference extends Preference { public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); - ImageView iconView = ((ImageView)holder.findViewById(R.id.controller_binding_icon)); - TextView nameView = ((TextView)holder.findViewById(R.id.controller_binding_name)); - mValueView = ((TextView)holder.findViewById(R.id.controller_binding_value)); + ImageView iconView = ((ImageView) holder.findViewById(R.id.controller_binding_icon)); + TextView nameView = ((TextView) holder.findViewById(R.id.controller_binding_name)); + mValueView = ((TextView) holder.findViewById(R.id.controller_binding_value)); int drawableId = R.drawable.ic_baseline_radio_button_checked_24; - switch (mType) - { - case BUTTON: drawableId = getIconForButton(mBindingName); break; - case AXIS: drawableId = getIconForAxis(mBindingName); break; - case HOTKEY: drawableId = getIconForHotkey(mBindingName); break; + switch (mType) { + case BUTTON: + drawableId = getIconForButton(mBindingName); + break; + case AXIS: + drawableId = getIconForAxis(mBindingName); + break; + case HOTKEY: + drawableId = getIconForHotkey(mBindingName); + break; } iconView.setImageDrawable(ContextCompat.getDrawable(getContext(), drawableId)); diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java index 1256484a4..7be36c326 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java @@ -55,38 +55,38 @@ public class EmulationSurfaceView extends SurfaceView { } } - private static final int[] buttonKeyCodes = new int[] { - KeyEvent.KEYCODE_BUTTON_A, // 0/Cross - KeyEvent.KEYCODE_BUTTON_B, // 1/Circle - KeyEvent.KEYCODE_BUTTON_X, // 2/Square - KeyEvent.KEYCODE_BUTTON_Y, // 3/Triangle - KeyEvent.KEYCODE_BUTTON_SELECT, // 4/Select - KeyEvent.KEYCODE_BUTTON_MODE, // 5/Analog - KeyEvent.KEYCODE_BUTTON_START, // 6/Start - KeyEvent.KEYCODE_BUTTON_THUMBL, // 7/L3 - KeyEvent.KEYCODE_BUTTON_THUMBR, // 8/R3 - KeyEvent.KEYCODE_BUTTON_L1, // 9/L1 - KeyEvent.KEYCODE_BUTTON_R1, // 10/R1 - KeyEvent.KEYCODE_DPAD_UP, // 11/Up - KeyEvent.KEYCODE_DPAD_DOWN, // 12/Down - KeyEvent.KEYCODE_DPAD_LEFT, // 13/Left - KeyEvent.KEYCODE_DPAD_RIGHT, // 14/Right - KeyEvent.KEYCODE_BUTTON_L2, // 15 - KeyEvent.KEYCODE_BUTTON_R2, // 16 - KeyEvent.KEYCODE_BUTTON_C, // 17 - KeyEvent.KEYCODE_BUTTON_Z, // 18 + private static final int[] buttonKeyCodes = new int[]{ + KeyEvent.KEYCODE_BUTTON_A, // 0/Cross + KeyEvent.KEYCODE_BUTTON_B, // 1/Circle + KeyEvent.KEYCODE_BUTTON_X, // 2/Square + KeyEvent.KEYCODE_BUTTON_Y, // 3/Triangle + KeyEvent.KEYCODE_BUTTON_SELECT, // 4/Select + KeyEvent.KEYCODE_BUTTON_MODE, // 5/Analog + KeyEvent.KEYCODE_BUTTON_START, // 6/Start + KeyEvent.KEYCODE_BUTTON_THUMBL, // 7/L3 + KeyEvent.KEYCODE_BUTTON_THUMBR, // 8/R3 + KeyEvent.KEYCODE_BUTTON_L1, // 9/L1 + KeyEvent.KEYCODE_BUTTON_R1, // 10/R1 + KeyEvent.KEYCODE_DPAD_UP, // 11/Up + KeyEvent.KEYCODE_DPAD_DOWN, // 12/Down + KeyEvent.KEYCODE_DPAD_LEFT, // 13/Left + KeyEvent.KEYCODE_DPAD_RIGHT, // 14/Right + KeyEvent.KEYCODE_BUTTON_L2, // 15 + KeyEvent.KEYCODE_BUTTON_R2, // 16 + KeyEvent.KEYCODE_BUTTON_C, // 17 + KeyEvent.KEYCODE_BUTTON_Z, // 18 }; - private static final int[] axisCodes = new int[] { - MotionEvent.AXIS_X, // 0/LeftX - MotionEvent.AXIS_Y, // 1/LeftY - MotionEvent.AXIS_Z, // 2/RightX - MotionEvent.AXIS_RZ, // 3/RightY - MotionEvent.AXIS_LTRIGGER, // 4/L2 - MotionEvent.AXIS_RTRIGGER, // 5/R2 - MotionEvent.AXIS_RX, // 6 - MotionEvent.AXIS_RY, // 7 - MotionEvent.AXIS_HAT_X, // 8 - MotionEvent.AXIS_HAT_Y, // 9 + private static final int[] axisCodes = new int[]{ + MotionEvent.AXIS_X, // 0/LeftX + MotionEvent.AXIS_Y, // 1/LeftY + MotionEvent.AXIS_Z, // 2/RightX + MotionEvent.AXIS_RZ, // 3/RightY + MotionEvent.AXIS_LTRIGGER, // 4/L2 + MotionEvent.AXIS_RTRIGGER, // 5/R2 + MotionEvent.AXIS_RX, // 6 + MotionEvent.AXIS_RY, // 7 + MotionEvent.AXIS_HAT_X, // 8 + MotionEvent.AXIS_HAT_Y, // 9 }; public static int getButtonIndexForKeyCode(int keyCode) { diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/GamePropertiesActivity.java b/android/app/src/main/java/com/github/stenzek/duckstation/GamePropertiesActivity.java index 1062cf3b9..a82213304 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/GamePropertiesActivity.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/GamePropertiesActivity.java @@ -117,22 +117,22 @@ public class GamePropertiesActivity extends AppCompatActivity { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { final PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getContext()); - activity.createListGameSetting(ps, "CPUOverclock", R.string.settings_cpu_overclocking, R.array.settings_advanced_cpu_overclock_entries, R.array.settings_advanced_cpu_overclock_values); - activity.createListGameSetting(ps,"CDROMReadSpeedup", R.string.settings_cdrom_read_speedup, R.array.settings_cdrom_read_speedup_entries, R.array.settings_cdrom_read_speedup_values); + activity.createListGameSetting(ps, "CPUOverclock", R.string.settings_cpu_overclocking, R.array.settings_advanced_cpu_overclock_entries, R.array.settings_advanced_cpu_overclock_values); + activity.createListGameSetting(ps, "CDROMReadSpeedup", R.string.settings_cdrom_read_speedup, R.array.settings_cdrom_read_speedup_entries, R.array.settings_cdrom_read_speedup_values); activity.createListGameSetting(ps, "DisplayAspectRatio", R.string.settings_aspect_ratio, R.array.settings_display_aspect_ratio_names, R.array.settings_display_aspect_ratio_values); - activity.createListGameSetting(ps, "DisplayCropMode", R.string.settings_crop_mode,R.array.settings_display_crop_mode_entries,R.array.settings_display_crop_mode_values); - activity.createListGameSetting(ps,"GPUDownsampleMode", R.string.settings_downsample_mode, R.array.settings_downsample_mode_entries, R.array.settings_downsample_mode_values); + activity.createListGameSetting(ps, "DisplayCropMode", R.string.settings_crop_mode, R.array.settings_display_crop_mode_entries, R.array.settings_display_crop_mode_values); + activity.createListGameSetting(ps, "GPUDownsampleMode", R.string.settings_downsample_mode, R.array.settings_downsample_mode_entries, R.array.settings_downsample_mode_values); activity.createBooleanGameSetting(ps, "DisplayLinearUpscaling", R.string.settings_linear_upscaling); - activity.createBooleanGameSetting(ps,"DisplayIntegerUpscaling",R.string.settings_integer_upscaling); - activity.createBooleanGameSetting(ps,"DisplayForce4_3For24Bit",R.string.settings_force_4_3_for_24bit); + activity.createBooleanGameSetting(ps, "DisplayIntegerUpscaling", R.string.settings_integer_upscaling); + activity.createBooleanGameSetting(ps, "DisplayForce4_3For24Bit", R.string.settings_force_4_3_for_24bit); activity.createListGameSetting(ps, "GPUResolutionScale", R.string.settings_gpu_resolution_scale, R.array.settings_gpu_resolution_scale_entries, R.array.settings_gpu_resolution_scale_values); activity.createListGameSetting(ps, "GPUMSAA", R.string.settings_msaa, R.array.settings_gpu_msaa_entries, R.array.settings_gpu_msaa_values); activity.createBooleanGameSetting(ps, "GPUTrueColor", R.string.settings_true_color); - activity.createBooleanGameSetting(ps,"GPUScaledDithering",R.string.settings_scaled_dithering); + activity.createBooleanGameSetting(ps, "GPUScaledDithering", R.string.settings_scaled_dithering); activity.createListGameSetting(ps, "GPUTextureFilter", R.string.settings_texture_filtering, R.array.settings_gpu_texture_filter_names, R.array.settings_gpu_texture_filter_values); - activity.createBooleanGameSetting(ps,"GPUForceNTSCTimings",R.string.settings_force_ntsc_timings); + activity.createBooleanGameSetting(ps, "GPUForceNTSCTimings", R.string.settings_force_ntsc_timings); activity.createBooleanGameSetting(ps, "GPUWidescreenHack", R.string.settings_widescreen_hack); activity.createBooleanGameSetting(ps, "GPUPGXP", R.string.settings_pgxp_geometry_correction); activity.createBooleanGameSetting(ps, "GPUPGXPDepthBuffer", R.string.settings_pgxp_depth_buffer); @@ -193,11 +193,16 @@ public class GamePropertiesActivity extends AppCompatActivity { TabLayout tabLayout = view.findViewById(R.id.tab_layout); new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> { - switch (position) - { - case 0: tab.setText("Summary"); break; - case 1: tab.setText("Game Settings"); break; - case 2: tab.setText("Controller Settings"); break; + switch (position) { + case 0: + tab.setText("Summary"); + break; + case 1: + tab.setText("Game Settings"); + break; + case 2: + tab.setText("Controller Settings"); + break; } }).attach(); } @@ -214,8 +219,7 @@ public class GamePropertiesActivity extends AppCompatActivity { @NonNull @Override public Fragment createFragment(int position) { - switch (position) - { + switch (position) { case 0: { // Summary ListFragment lf = new ListFragment(); lf.setListAdapter(activity.getPropertyListAdapter()); diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/PreferenceHelpers.java b/android/app/src/main/java/com/github/stenzek/duckstation/PreferenceHelpers.java index 387b139a4..a76b984b0 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/PreferenceHelpers.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/PreferenceHelpers.java @@ -9,7 +9,8 @@ public class PreferenceHelpers { /** * Clears all preferences in the specified section (starting with sectionName/). * We really don't want to have to do this with JNI... - * @param prefs Preferences object. + * + * @param prefs Preferences object. * @param sectionName Section to clear keys for. */ public static void clearSection(SharedPreferences prefs, String sectionName) { @@ -43,8 +44,7 @@ public class PreferenceHelpers { return values; } - public static boolean addToStringList(SharedPreferences prefs, String keyName, String valueToAdd) - { + public static boolean addToStringList(SharedPreferences prefs, String keyName, String valueToAdd) { Set values = getStringSet(prefs, keyName); if (values == null) values = new ArraySet<>(); @@ -54,8 +54,7 @@ public class PreferenceHelpers { return result; } - public static boolean removeFromStringList(SharedPreferences prefs, String keyName, String valueToRemove) - { + public static boolean removeFromStringList(SharedPreferences prefs, String keyName, String valueToRemove) { Set values = getStringSet(prefs, keyName); if (values == null) return false; diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/PropertyListAdapter.java b/android/app/src/main/java/com/github/stenzek/duckstation/PropertyListAdapter.java index 9d2a73678..3f9a01565 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/PropertyListAdapter.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/PropertyListAdapter.java @@ -74,8 +74,8 @@ public class PropertyListAdapter extends BaseAdapter { .inflate(R.layout.layout_game_property_entry, parent, false); } - TextView titleView = (TextView)convertView.findViewById(R.id.property_title); - TextView valueView = (TextView)convertView.findViewById(R.id.property_value); + TextView titleView = (TextView) convertView.findViewById(R.id.property_title); + TextView valueView = (TextView) convertView.findViewById(R.id.property_value); Item prop = mItems.get(position); titleView.setText(prop.title); valueView.setText(prop.value); diff --git a/android/app/src/main/res/drawable/ic_baseline_category_24.xml b/android/app/src/main/res/drawable/ic_baseline_category_24.xml index b45741e54..dead295df 100644 --- a/android/app/src/main/res/drawable/ic_baseline_category_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_category_24.xml @@ -4,13 +4,13 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - - - + + + diff --git a/android/app/src/main/res/drawable/ic_baseline_folder_open_24.xml b/android/app/src/main/res/drawable/ic_baseline_folder_open_24.xml index f58b501e3..4a793654a 100644 --- a/android/app/src/main/res/drawable/ic_baseline_folder_open_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_folder_open_24.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - + diff --git a/android/app/src/main/res/drawable/ic_baseline_gamepad_24.xml b/android/app/src/main/res/drawable/ic_baseline_gamepad_24.xml index fcf518c3c..f4a8a8711 100644 --- a/android/app/src/main/res/drawable/ic_baseline_gamepad_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_gamepad_24.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - + diff --git a/android/app/src/main/res/drawable/ic_baseline_radio_button_checked_24.xml b/android/app/src/main/res/drawable/ic_baseline_radio_button_checked_24.xml index dc3833728..05a669ab2 100644 --- a/android/app/src/main/res/drawable/ic_baseline_radio_button_checked_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_radio_button_checked_24.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - + diff --git a/android/app/src/main/res/drawable/ic_baseline_radio_button_unchecked_24.xml b/android/app/src/main/res/drawable/ic_baseline_radio_button_unchecked_24.xml index bcb6fc9c5..2d5445cbe 100644 --- a/android/app/src/main/res/drawable/ic_baseline_radio_button_unchecked_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_radio_button_unchecked_24.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - + diff --git a/android/app/src/main/res/drawable/ic_baseline_save_24.xml b/android/app/src/main/res/drawable/ic_baseline_save_24.xml index 1a8d86d20..955858d7d 100644 --- a/android/app/src/main/res/drawable/ic_baseline_save_24.xml +++ b/android/app/src/main/res/drawable/ic_baseline_save_24.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> - + diff --git a/android/app/src/main/res/layout/layout_game_property_entry.xml b/android/app/src/main/res/layout/layout_game_property_entry.xml index 7a40786e4..47ede3ee3 100644 --- a/android/app/src/main/res/layout/layout_game_property_entry.xml +++ b/android/app/src/main/res/layout/layout_game_property_entry.xml @@ -1,6 +1,6 @@ - + android:title="Clear Bindings" /> \ No newline at end of file diff --git a/android/app/src/main/res/xml/controllers_preferences.xml b/android/app/src/main/res/xml/controllers_preferences.xml index 18d107d37..48493c987 100644 --- a/android/app/src/main/res/xml/controllers_preferences.xml +++ b/android/app/src/main/res/xml/controllers_preferences.xml @@ -29,9 +29,10 @@ app:title="@string/settings_controller_mapping" app:summary="@string/settings_controller_mapping_summary" app:iconSpaceReserved="false"> - +