diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerAutoMapper.java b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerAutoMapper.java index 88be8a557..ae846ad79 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerAutoMapper.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerAutoMapper.java @@ -169,7 +169,6 @@ public class ControllerAutoMapper { editText.setText(log.toString()); editText.setInputType(InputType.TYPE_NULL | InputType.TYPE_TEXT_FLAG_MULTI_LINE); editText.setSingleLine(false); - editText.setMinLines(10); builder.setView(editText); builder.setPositiveButton(R.string.main_activity_ok, (dialog, which) -> dialog.dismiss()); @@ -222,13 +221,13 @@ public class ControllerAutoMapper { doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_L1}, null); break; case "L2": - doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_L2}, new int[][]{{MotionEvent.AXIS_LTRIGGER, 1}, {MotionEvent.AXIS_BRAKE, 1}}); + doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_L2}, new int[][]{{MotionEvent.AXIS_LTRIGGER, 1}, {MotionEvent.AXIS_Z, 1}, {MotionEvent.AXIS_BRAKE, 1}}); break; case "R1": doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_R1}, null); break; case "R2": - doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_R2}, new int[][]{{MotionEvent.AXIS_RTRIGGER, 1}, {MotionEvent.AXIS_GAS, 1}}); + doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_R2}, new int[][]{{MotionEvent.AXIS_RTRIGGER, 1}, {MotionEvent.AXIS_RZ, 1}, {MotionEvent.AXIS_GAS, 1}}); break; case "L3": doAutoBindingButton(buttonName, new int[]{KeyEvent.KEYCODE_BUTTON_THUMBL}, null); @@ -262,10 +261,10 @@ public class ControllerAutoMapper { doAutoBindingAxis(axisName, new int[]{MotionEvent.AXIS_Y}); break; case "RightX": - doAutoBindingAxis(axisName, new int[]{MotionEvent.AXIS_Z, MotionEvent.AXIS_RX}); + doAutoBindingAxis(axisName, new int[]{MotionEvent.AXIS_RX, MotionEvent.AXIS_Z}); break; case "RightY": - doAutoBindingAxis(axisName, new int[]{MotionEvent.AXIS_RZ, MotionEvent.AXIS_RY}); + doAutoBindingAxis(axisName, new int[]{MotionEvent.AXIS_RY, MotionEvent.AXIS_RZ}); break; default: log("Axis '%s' not supported by auto mapping.", axisName); @@ -286,5 +285,10 @@ public class ControllerAutoMapper { log("Selected device has no vibrator, cannot bind vibration."); return; } + + log("Binding vibration to device '%s'.", device.getDescriptor()); + + final String key = String.format("%sRumble", keyBase); + editor.putString(key, device.getDescriptor()); } } diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingDialog.java b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingDialog.java index 237bff93f..d19c0c742 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingDialog.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/ControllerBindingDialog.java @@ -9,6 +9,7 @@ import android.util.ArraySet; import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; +import android.widget.Toast; import androidx.annotation.NonNull; @@ -72,16 +73,24 @@ public class ControllerBindingDialog extends AlertDialog { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - if (!EmulationSurfaceView.isBindableDevice(event.getDevice()) || !EmulationSurfaceView.isBindableKeyEvent(event)) { + final InputDevice device = event.getDevice(); + if (!EmulationSurfaceView.isBindableDevice(device) || !EmulationSurfaceView.isBindableKeyEvent(event)) { return super.onKeyDown(keyCode, event); } - if (mType == ControllerBindingPreference.Type.BUTTON) - mCurrentBinding = String.format("%s/Button%d", event.getDevice().getDescriptor(), event.getKeyCode()); - else if (mType == ControllerBindingPreference.Type.VIBRATION) - mCurrentBinding = event.getDevice().getDescriptor(); - else + if (mType == ControllerBindingPreference.Type.BUTTON) { + mCurrentBinding = String.format("%s/Button%d", device.getDescriptor(), event.getKeyCode()); + } else if (mType == ControllerBindingPreference.Type.VIBRATION) { + if (device.getVibrator() == null || !device.getVibrator().hasVibrator()) { + Toast.makeText(getContext(), getContext().getString(R.string.controller_settings_vibration_unsupported), Toast.LENGTH_LONG).show(); + dismiss(); + return true; + } + + mCurrentBinding = device.getDescriptor(); + } else { return super.onKeyDown(keyCode, event); + } updateMessage(); updateBinding(); @@ -135,8 +144,9 @@ public class ControllerBindingDialog extends AlertDialog { for (int axisIndex = 0; axisIndex < motionEventList.size(); axisIndex++) { final int axisCode = motionEventList.get(axisIndex).getAxis(); final float newValue = event.getAxisValue(axisCode); - if (Math.abs(newValue - axisValues[axisIndex]) >= DETECT_THRESHOLD) { - setAxisCode(event.getDevice(), axisCode, newValue >= 0.0f); + final float delta = newValue - axisValues[axisIndex]; + if (Math.abs(delta) >= DETECT_THRESHOLD) { + setAxisCode(event.getDevice(), axisCode, delta >= 0.0f); break; } } diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmptyGameListFragment.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmptyGameListFragment.java index 91008735d..e5b99c697 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmptyGameListFragment.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmptyGameListFragment.java @@ -10,7 +10,7 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; public class EmptyGameListFragment extends Fragment { - private static final String SUPPORTED_FORMATS_STRING = "bin/cue, iso, img, ecm, mds, chd, pbp"; + private static final String SUPPORTED_FORMATS_STRING = ".cue, .iso, .img, .ecm, .mds, .chd, .pbp"; private MainActivity parent; diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index ffc12fbf0..3b81d1a8e 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -312,6 +312,7 @@ Failed to import card \'%s\'. It may not be a supported format. Imported card \'%s\'. Choose Cover Image + The selected device does not support vibration. Perform Automatic Mapping Attempts to automatically bind all buttons/axes to a connected controller. Clear Bindings @@ -326,5 +327,5 @@ Add Game Directory Start File Update Notes - This DuckStation update includes support for multiple controllers, and binding devices such as keyboards/volume buttons.\n\nYou must re-bind your controllers, otherwise they will no longer function. Do you want to do this now? + This DuckStation update includes support for multiple controllers with vibration, and binding devices such as keyboards/volume buttons.\n\nYou must re-bind your controllers, otherwise they will no longer function. Do you want to do this now?