Skip to content

Commit 244f54c

Browse files
committed
chore: update sound_manager and input_helper via gd-plug
1 parent f2fc656 commit 244f54c

17 files changed

+406
-414
lines changed

addons/input_helper/device_tester.gd

-48
This file was deleted.

addons/input_helper/device_tester.tscn

-61
This file was deleted.

addons/input_helper/input_helper.gd

+34-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const DEVICE_SWITCH_JOYCON_RIGHT_CONTROLLER = "switch_right_joycon"
1515
const DEVICE_PLAYSTATION_CONTROLLER = "playstation"
1616
const DEVICE_GENERIC = "generic"
1717

18+
const XBOX_BUTTON_LABELS = ["A", "B", "X", "Y", "Back", "Home", "Menu", "Left Stick", "Right Stick", "Left Shoulder", "Right Shoulder", "Up", "Down", "Left", "Right", "Share"]
19+
const SWITCH_BUTTON_LABELS = ["B", "A", "Y", "X", "-", "", "+", "Left Stick", "Right Stick", "Left Shoulder", "Right Shoulder", "Up", "Down", "Left", "Right", "Capture"]
20+
const PLAYSTATION_BUTTON_LABELS = ["Cross", "Circle", "Square", "Triangle", "Select", "PS", "Options", "L3", "R3", "L1", "R1", "Up", "Down", "Left", "Right", "Microphone"]
21+
1822

1923
@onready var device: String = guess_device_name()
2024
@onready var device_index: int = 0 if has_joypad() else -1
@@ -33,7 +37,7 @@ func _input(event: InputEvent) -> void:
3337
var next_device_index: int = device_index
3438

3539
# Did we just press a key on the keyboard?
36-
if event is InputEventKey or event is InputEventMouse:
40+
if event is InputEventKey or event is InputEventMouseButton:
3741
next_device = DEVICE_KEYBOARD
3842
next_device_index = -1
3943

@@ -139,6 +143,7 @@ func get_label_for_input(input: InputEvent) -> String:
139143
return OS.get_keycode_string(input.keycode)
140144
else:
141145
return input.as_text()
146+
142147
elif input is InputEventMouseButton:
143148
match input.button_index:
144149
MOUSE_BUTTON_LEFT:
@@ -149,6 +154,30 @@ func get_label_for_input(input: InputEvent) -> String:
149154
return "Mouse Right Button"
150155
return "Mouse Button %d" % input
151156

157+
elif input is InputEventJoypadButton:
158+
match device:
159+
DEVICE_XBOX_CONTROLLER, DEVICE_GENERIC:
160+
return "%s Button" % XBOX_BUTTON_LABELS[input.button_index]
161+
DEVICE_SWITCH_CONTROLLER, DEVICE_SWITCH_JOYCON_LEFT_CONTROLLER, DEVICE_SWITCH_JOYCON_RIGHT_CONTROLLER:
162+
return "%s Button" % SWITCH_BUTTON_LABELS[input.button_index]
163+
DEVICE_PLAYSTATION_CONTROLLER:
164+
return "%s Button" % PLAYSTATION_BUTTON_LABELS[input.button_index]
165+
elif input is InputEventJoypadMotion:
166+
var motion: InputEventJoypadMotion = input as InputEventJoypadMotion
167+
match motion.axis:
168+
JOY_AXIS_LEFT_X:
169+
return "Left Stick %s" % ("Left" if motion.axis_value < 0 else "Right")
170+
JOY_AXIS_LEFT_Y:
171+
return "Left Stick %s" % ("Up" if motion.axis_value < 0 else "Down")
172+
JOY_AXIS_RIGHT_X:
173+
return "Right Stick %s" % ("Left" if motion.axis_value < 0 else "Right")
174+
JOY_AXIS_RIGHT_Y:
175+
return "Right Stick %s" % ("Up" if motion.axis_value < 0 else "Down")
176+
JOY_AXIS_TRIGGER_LEFT:
177+
return "Left Trigger"
178+
JOY_AXIS_TRIGGER_RIGHT:
179+
return "Right Trigger"
180+
152181
return input.as_text()
153182

154183

@@ -334,7 +363,7 @@ func _update_input_for_action(action: String, input: InputEvent, swap_if_taken:
334363

335364
# Find the key based event for the target action
336365
var action_events: Array[InputEvent] = InputMap.action_get_events(action)
337-
var did_change: bool = false
366+
var is_replacing: bool = false
338367
for i in range(0, action_events.size()):
339368
var event: InputEvent = action_events[i]
340369
if check_is_valid.call(event):
@@ -347,11 +376,11 @@ func _update_input_for_action(action: String, input: InputEvent, swap_if_taken:
347376

348377
# Replace the event
349378
action_events[i] = input
350-
did_change = true
379+
is_replacing = true
351380
break
352381

353382
# If we were trying to replace something but didn't find it then just add it to the end
354-
if not did_change:
383+
if not is_replacing:
355384
action_events.append(input)
356385

357386
# Apply the changes
@@ -360,8 +389,7 @@ func _update_input_for_action(action: String, input: InputEvent, swap_if_taken:
360389
if event != null:
361390
InputMap.action_add_event(action, event)
362391

363-
if did_change:
364-
did_change_signal.emit(action, input)
392+
did_change_signal.emit(action, input)
365393

366394
return OK
367395

addons/input_helper/plugin.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="Input Helper"
44
description="Detect which input device the player is using and manage input actions"
55
author="Nathan Hoad"
6-
version="4.3.1"
6+
version="4.3.3"
77
script="plugin.gd"

addons/input_helper/remap.gd

-61
This file was deleted.

addons/input_helper/remap.tscn

-37
This file was deleted.

0 commit comments

Comments
 (0)