-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Gamepad Settings): add mouse handling for gamepad settings button #430
Open
ShadowApex
wants to merge
1
commit into
main
Choose a base branch
from
shadowapex/general-gamepad-button
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 38 additions & 1 deletion
39
core/ui/card_ui/settings/general_controller_settings_menu.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
extends Control | ||
|
||
var input_plumber := load("res://core/systems/input/input_plumber.tres") as InputPlumberInstance | ||
var state_machine := load("res://assets/state/state_machines/menu_state_machine.tres") as StateMachine | ||
var state := load("res://assets/state/states/gamepad_settings.tres") as State | ||
|
||
@onready var gamepad_button := $%GamepadSettingsButton as CardButton | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass | ||
gamepad_button.gui_input.connect(_on_button_input) | ||
|
||
|
||
# If the user presses the gamepad settings button with a non-gamepad input method, | ||
# open the settings for the first detected controller. | ||
# TODO: Add a controller select pop-up to select a gamepad to configure | ||
func _on_button_input(event: InputEvent) -> void: | ||
if event is InputEventMouseButton: | ||
if (event as InputEventMouseButton).button_index != MOUSE_BUTTON_LEFT: | ||
return | ||
if (event as InputEventMouseButton).pressed: | ||
return | ||
_open_menu_default_gamepad() | ||
return | ||
|
||
if event is InputEventKey: | ||
if !event.is_action("ui_accept"): | ||
return | ||
if event.pressed: | ||
return | ||
_open_menu_default_gamepad() | ||
|
||
|
||
# Push the gamepad config menu for the first detected controller. | ||
func _open_menu_default_gamepad() -> void: | ||
state.set_meta("dbus_path", "") | ||
var devices := input_plumber.get_composite_devices() | ||
if !devices.is_empty(): | ||
var device := devices[0] | ||
state.set_meta("dbus_path", device.dbus_path) | ||
|
||
state_machine.push_state(state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should prioritize this soon, along with gamepad ordering. This shouldn't be exclusive to mouse/touch input though, I think it would be reasonable to configure multiple gamepads with player 1 for example .