Prepare Android controller and export support
This commit is contained in:
parent
c84f305c34
commit
d24f2f50c0
9 changed files with 192 additions and 11 deletions
53
tests/android_readiness_validation.gd
Normal file
53
tests/android_readiness_validation.gd
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
extends SceneTree
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
assert(
|
||||
ProjectSettings.get_setting("display/window/handheld/orientation", -1) == 0
|
||||
)
|
||||
assert(
|
||||
ProjectSettings.get_setting(
|
||||
"input_devices/pointing/emulate_mouse_from_touch", false
|
||||
)
|
||||
)
|
||||
assert(_has_joypad_motion(&"move_forward", JOY_AXIS_LEFT_Y, -1.0))
|
||||
assert(_has_joypad_motion(&"move_backward", JOY_AXIS_LEFT_Y, 1.0))
|
||||
assert(_has_joypad_motion(&"move_left", JOY_AXIS_LEFT_X, -1.0))
|
||||
assert(_has_joypad_motion(&"move_right", JOY_AXIS_LEFT_X, 1.0))
|
||||
assert(_has_joypad_button(&"jump", JOY_BUTTON_A))
|
||||
assert(_has_joypad_button(&"interact", JOY_BUTTON_X))
|
||||
assert(_has_joypad_motion(&"fish_primary", JOY_AXIS_TRIGGER_RIGHT, 1.0))
|
||||
assert(_has_joypad_button(&"sprint", JOY_BUTTON_LEFT_STICK))
|
||||
assert(_has_joypad_button(&"camera_zoom_out", JOY_BUTTON_LEFT_SHOULDER))
|
||||
assert(_has_joypad_button(&"camera_zoom_in", JOY_BUTTON_RIGHT_SHOULDER))
|
||||
assert(_has_joypad_button(&"hotbar_previous", JOY_BUTTON_DPAD_LEFT))
|
||||
assert(_has_joypad_button(&"hotbar_next", JOY_BUTTON_DPAD_RIGHT))
|
||||
assert(_has_joypad_button(&"open_backpack", JOY_BUTTON_BACK))
|
||||
assert(_has_joypad_button(&"open_system_menu", JOY_BUTTON_START))
|
||||
assert(_has_joypad_button(&"open_emotes", JOY_BUTTON_DPAD_UP))
|
||||
print("android readiness validation passed")
|
||||
quit()
|
||||
|
||||
|
||||
func _has_joypad_button(action: StringName, button_index: JoyButton) -> bool:
|
||||
for event: InputEvent in InputMap.action_get_events(action):
|
||||
var button_event: InputEventJoypadButton = event as InputEventJoypadButton
|
||||
if button_event != null and button_event.button_index == button_index:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _has_joypad_motion(
|
||||
action: StringName,
|
||||
axis: JoyAxis,
|
||||
direction: float,
|
||||
) -> bool:
|
||||
for event: InputEvent in InputMap.action_get_events(action):
|
||||
var motion_event: InputEventJoypadMotion = event as InputEventJoypadMotion
|
||||
if (
|
||||
motion_event != null
|
||||
and motion_event.axis == axis
|
||||
and is_equal_approx(motion_event.axis_value, direction)
|
||||
):
|
||||
return true
|
||||
return false
|
||||
1
tests/android_readiness_validation.gd.uid
Normal file
1
tests/android_readiness_validation.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cbqyx4mntux7l
|
||||
Loading…
Add table
Add a link
Reference in a new issue