Merge pull request #117198 from uno1982/Feat--Android-Editor-Hapic-Feedback

Android: Add haptic feedback on long-press right-click in the editor
This commit is contained in:
Rémi Verschelde
2026-03-14 12:16:13 +01:00
5 changed files with 39 additions and 0 deletions
+4
View File
@@ -1266,6 +1266,10 @@
If [code]true[/code], increases the scrollbar touch area, enables a larger dragger for split containers, and increases PopupMenu vertical separation to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
</member>
<member name="interface/touchscreen/haptic_on_long_press" type="bool" setter="" getter="">
If [code]true[/code], the device will vibrate when a long-press gesture triggers a right-click context menu in the editor.
[b]Note:[/b] Only has an effect on devices with haptic feedback hardware. Defaults to [code]true[/code] on touchscreen devices.
</member>
<member name="interface/touchscreen/scale_gizmo_handles" type="float" setter="" getter="">
Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
+1
View File
@@ -627,6 +627,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_touch_optimizations", is_native_touchscreen, "")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_long_press_as_right_click", is_native_touchscreen, "")
set_restart_if_changed("interface/touchscreen/enable_long_press_as_right_click", true);
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/haptic_on_long_press", is_native_touchscreen, "")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_pan_and_scale_gestures", has_touchscreen_ui, "")
set_restart_if_changed("interface/touchscreen/enable_pan_and_scale_gestures", true);
@@ -450,6 +450,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
val longPressEnabled = enableLongPressGestures()
val panScaleEnabled = enablePanAndScaleGestures()
val overrideVolumeButtonsEnabled = overrideVolumeButtons()
val hapticEnabled = enableHapticOnLongPress()
runOnUiThread {
// Enable long press, panning and scaling gestures
@@ -457,6 +458,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
enableLongPress(longPressEnabled)
enablePanningAndScalingGestures(panScaleEnabled)
setOverrideVolumeButtons(overrideVolumeButtonsEnabled)
enableHapticFeedback(hapticEnabled)
}
}
}
@@ -721,6 +723,12 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
protected open fun enableLongPressGestures() =
java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_long_press_as_right_click"))
/**
* Enable haptic feedback on long-press right-click for the Godot Android editor.
*/
protected open fun enableHapticOnLongPress() =
java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/haptic_on_long_press"))
/**
* Disable scroll deadzone for the Godot Android editor.
*/
@@ -57,6 +57,11 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
var scrollDeadzoneDisabled = false
/**
* Enable haptic feedback on long-press right-click
*/
var hapticFeedbackEnabled = false
private var nextDownIsDoubleTap = false
private var dragInProgress = false
private var scaleInProgress = false
@@ -80,6 +85,9 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
override fun onLongPress(event: MotionEvent) {
val toolType = GodotInputHandler.getEventToolType(event)
if (toolType != MotionEvent.TOOL_TYPE_MOUSE) {
if (hapticFeedbackEnabled) {
inputHandler.performHapticFeedback()
}
contextClickRouter(event)
}
}
@@ -47,6 +47,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.GestureDetector;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -133,6 +134,23 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
this.godotGestureHandler.setScrollDeadzoneDisabled(disable);
}
/**
* Enable haptic feedback (vibration) when a long-press right-click is triggered.
*/
public void enableHapticFeedback(boolean enable) {
this.godotGestureHandler.setHapticFeedbackEnabled(enable);
}
/**
* Perform haptic feedback on the render view.
*/
void performHapticFeedback() {
GodotRenderView view = godot.getRenderView();
if (view != null) {
view.getView().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
}
/**
* Enable multi-fingers pan & scale gestures. This is false by default.
* <p>