Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/gamepad/profiles/default_overlay.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@
}
}
]
},
}
]
}
41 changes: 8 additions & 33 deletions core/systems/input/overlay_mode_input_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -116,38 +116,13 @@ func _input(event: InputEvent) -> void:
_audio_input(event)
return

# Handle guide action release events
# Release active Guide actions when the combo ends, even if Guide is released first.
if event.is_action_released("ogui_guide_action"):
logger.debug("Additional action as guide is released.")
# Steam OSK
if event.is_action_released("ogui_north_ov"):
action_release(dbus_path, "ogui_osk_ov")
get_viewport().set_input_as_handled()
return

# Steam QAM
if event.is_action_released("ogui_south_ov"):
action_release(dbus_path, "ogui_qam_ov")
get_viewport().set_input_as_handled()
return

# Steam Video Capture
if event.is_action_released("ogui_west_ov"):
action_release(dbus_path, "ogui_vc_ov")
get_viewport().set_input_as_handled()
return

# Steam Screenshot
if event.is_action_released("ogui_rb_ov"):
action_release(dbus_path, "ogui_sc_ov")
get_viewport().set_input_as_handled()
return

# Quick Bar
if event.is_action_released("ogui_east_ov"):
action_release(dbus_path, "ogui_qb_ov")
get_viewport().set_input_as_handled()
return
for action: String in ["ogui_osk_ov", "ogui_qam_ov", "ogui_vc_ov", "ogui_sc_ov", "ogui_qb_ov"]:
if Input.is_action_pressed(action):
action_release(dbus_path, action)
get_viewport().set_input_as_handled()
return

# Handle inputs when the guide button is being held
if Input.is_action_pressed("ogui_guide_ov"):
Expand Down Expand Up @@ -195,7 +170,7 @@ func _input(event: InputEvent) -> void:
action_release(dbus_path, "ogui_vc_ov")

# Steam Screenshot
if event.is_action_pressed("ogui_rb_ov"):
if event.is_action_released("ogui_rb_ov"):
action_release(dbus_path, "ogui_sc_ov")

# Quick Bar
Expand Down Expand Up @@ -257,7 +232,7 @@ func _find_focus() -> Node:


## Handle guide button events and determine whether this is a guide action
## (e.g. guide + A to open the Quick Bar), or if it's just a normal guide button press.
## (Guide+B to open the Quick Bar), or if it's just a normal guide button press.
func _guide_input(event: InputEvent) -> void:
var dbus_path := event.get_meta("dbus_path", "") as String
# Only act on release events
Expand Down
68 changes: 68 additions & 0 deletions core/systems/input/overlay_mode_input_manager_test.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
extends GutTest

const GUIDE_ACTIONS := ["ogui_osk_ov", "ogui_qam_ov", "ogui_vc_ov", "ogui_sc_ov", "ogui_qb_ov"]

var manager: RecordingManager


class RecordingManager extends OverlayInputManager:
var released_actions: Array[String] = []

func _ready() -> void:
set_process_input(false)

func action_release(_dbus_path: String, action: String, _strength: float = 1.0) -> void:
Input.action_release(action)
released_actions.append(action)


func before_each() -> void:
_clear_actions()
manager = RecordingManager.new()
add_child_autofree(manager)


func after_each() -> void:
_clear_actions()


func _clear_actions() -> void:
for action: String in GUIDE_ACTIONS:
Input.action_release(action)
Input.action_release("ogui_guide_ov")
Input.action_release("ogui_guide_action")


func _release_event(action: String) -> InputEventAction:
var event := InputEventAction.new()
event.action = action
event.pressed = false
event.set_meta("dbus_path", "/test/device")
return event


func test_guide_action_release_clears_all_active_actions() -> void:
for action: String in GUIDE_ACTIONS:
Input.action_press(action)

manager._input(_release_event("ogui_guide_action"))

assert_eq(manager.released_actions, GUIDE_ACTIONS)
for action: String in GUIDE_ACTIONS:
assert_false(Input.is_action_pressed(action), action + " should be released")


func test_guide_action_release_ignores_inactive_actions() -> void:
manager._input(_release_event("ogui_guide_action"))

assert_eq(manager.released_actions.size(), 0)


func test_rb_release_clears_screenshot_while_guide_is_held() -> void:
Input.action_press("ogui_guide_ov")
Input.action_press("ogui_sc_ov")

manager._input(_release_event("ogui_rb_ov"))

assert_eq(manager.released_actions, ["ogui_sc_ov"])
assert_false(Input.is_action_pressed("ogui_sc_ov"))
1 change: 1 addition & 0 deletions core/systems/input/overlay_mode_input_manager_test.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://dnowlapngyxug