Skip to content

Commit

Permalink
Prevent duplicate gamepad input by not listening for ANY gamepad events
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Mar 23, 2023
1 parent 339c8d9 commit 432c04d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
8 changes: 4 additions & 4 deletions core/ui/menu/home/home_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[ext_resource type="Resource" uid="uid://boq501bigx8kl" path="res://assets/state/states/library.tres" id="11_lws2k"]
[ext_resource type="Shader" path="res://assets/shaders/outline.gdshader" id="12_fa67h"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_83ncj"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_mlwy3"]
resource_local_to_scene = true
shader = ExtResource("12_fa67h")
shader_parameter/on = false
Expand Down Expand Up @@ -56,7 +56,7 @@ launch_items = [SubResource("Resource_gsruu")]
tags = null
categories = null

[sub_resource type="ShaderMaterial" id="ShaderMaterial_ugpmw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ltggi"]
resource_local_to_scene = true
shader = ExtResource("12_fa67h")
shader_parameter/on = false
Expand Down Expand Up @@ -174,7 +174,7 @@ layout_mode = 2
theme_override_constants/separation = 16

[node name="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/MarginContainer/HBoxContainer" instance=ExtResource("4_k6kif")]
material = SubResource("ShaderMaterial_83ncj")
material = SubResource("ShaderMaterial_mlwy3")
custom_minimum_size = Vector2(200.2, 301)
layout_mode = 2
text = "vkCube"
Expand All @@ -185,7 +185,7 @@ layout_scale = 1.4
library_item = SubResource("Resource_icex7")

[node name="LibraryPoster" parent="MarginContainer/VBoxContainer/ScrollContainer/MarginContainer/HBoxContainer" instance=ExtResource("4_k6kif")]
material = SubResource("ShaderMaterial_ugpmw")
material = SubResource("ShaderMaterial_ltggi")
custom_minimum_size = Vector2(200.2, 301)
layout_mode = 2
texture_normal = null
Expand Down
9 changes: 9 additions & 0 deletions core/ui/menu/navigation/context_bar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ var state_machine := (
)
var logger := Log.get_logger("ContextBar")

@onready var accept_icon := $%AcceptButtonIcon as ControllerTextureRect
@onready var back_icon := $%BackButtonIcon as ControllerTextureRect
@onready var qam_mod_icon := $%QAMModifierIcon as ControllerTextureRect
@onready var qam_button_icon := $%QAMButtonIcon as ControllerTextureRect


# Called when the node enters the scene tree for the first time.
Expand Down Expand Up @@ -35,6 +38,12 @@ func _on_state_changed(from: State, to: State):
# Update the icons in the context bar based on input type
func _on_input_type_changed(input_type: ControllerIcons.InputType) -> void:
if input_type == ControllerIcons.InputType.CONTROLLER:
accept_icon.path = "joypad/a"
back_icon.path = "joypad/b"
qam_mod_icon.path = "joypad/home"
qam_button_icon.path = "joypad/a"
else:
accept_icon.path = "ui_accept"
back_icon.path = "ogui_east"
qam_mod_icon.path = "key/ctrl"
qam_button_icon.path = "ogui_guide_action_qam"
6 changes: 5 additions & 1 deletion core/ui/menu/navigation/context_bar.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=7 format=3 uid="uid://dpajbxrv14ehk"]
[gd_scene load_steps=8 format=3 uid="uid://dpajbxrv14ehk"]

[ext_resource type="Theme" uid="uid://bko0q7gp1hwjp" path="res://assets/themes/dracula.tres" id="1_ylil8"]
[ext_resource type="Script" path="res://core/ui/menu/navigation/context_bar.gd" id="2_jserv"]
[ext_resource type="Texture2D" uid="uid://cnghdqiitl0fu" path="res://addons/controller_icons/assets/key/esc.png" id="3_pwpba"]
[ext_resource type="Script" path="res://addons/controller_icons/objects/TextureRect.gd" id="3_vjpxr"]
[ext_resource type="Texture2D" uid="uid://bp58drjdgvxsi" path="res://addons/controller_icons/assets/key/enter_alt.png" id="5_wisqw"]
[ext_resource type="Texture2D" uid="uid://doih0kf30x8db" path="res://addons/controller_icons/assets/xbox360/home.png" id="6_lel3f"]
[ext_resource type="Texture2D" uid="uid://cebpb6c42ooem" path="res://addons/controller_icons/assets/key/f2.png" id="7_ebva3"]

[node name="ContextBar" type="Control" groups=["menu"]]
custom_minimum_size = Vector2(0, 40)
Expand Down Expand Up @@ -51,6 +52,7 @@ layout_mode = 2
text = "Accept"

[node name="AcceptButtonIcon" type="TextureRect" parent="MarginContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
texture = ExtResource("5_wisqw")
Expand All @@ -63,6 +65,7 @@ layout_mode = 2
text = "Back"

[node name="BackButtonIcon" type="TextureRect" parent="MarginContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
texture = ExtResource("3_pwpba")
Expand Down Expand Up @@ -94,6 +97,7 @@ text = "+"
unique_name_in_owner = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
texture = ExtResource("7_ebva3")
expand_mode = 1
script = ExtResource("3_vjpxr")
path = "ogui_guide_action_qam"
49 changes: 17 additions & 32 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -52,71 +52,60 @@ ui_accept={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":4194309,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":4194310,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
ui_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":4194319,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, null, null, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
, null, null]
}
ui_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":4194321,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":4194320,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":4194322,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
ogui_guide={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":5,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_tab_right={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_tab_left={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_south={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_north={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_west={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
"events": []
}
ogui_east={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ogui_guide_action={
Expand Down Expand Up @@ -146,24 +135,20 @@ ogui_back={
}
ogui_left_trigger={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)
]
"events": []
}
ogui_right_trigger={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null)
]
"events": []
}
ogui_modifier={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":5,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ogui_guide_action_qam={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194333,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194333,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ogui_power={
Expand Down

0 comments on commit 432c04d

Please sign in to comment.