Skip to content

Commit

Permalink
fix(Target Device): Update target devices to latest InputPlumber vers…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
pastaq committed Jun 29, 2024
1 parent 7d74ab6 commit dbdb5be
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion assets/gamepad/icon_mappings/xbox360.tres
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[resource]
script = ExtResource("5_qsuka")
name = "XBox 360"
device_names = PackedStringArray("Xbox 360 Controller")
device_names = PackedStringArray("Xbox 360 Controller", "Microsoft X-Box 360 pad")
diagram = ExtResource("1_ivcim")
north = ExtResource("4_yf7fg")
south = ExtResource("6_kekiu")
Expand Down
2 changes: 1 addition & 1 deletion assets/gamepad/icon_mappings/xboxone.tres
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[resource]
script = ExtResource("1_lckpp")
name = "XBox One"
device_names = PackedStringArray("Xbox One", "X-Box One", "Xbox Wireless Controller")
device_names = PackedStringArray("Xbox One", "X-Box One", "Xbox Wireless Controller", "Microsoft X-Box One pad", "Microsoft X-Box One Elite pad")
diagram = ExtResource("1_7rqq5")
north = ExtResource("17_wbg38")
south = ExtResource("28_e6a35")
Expand Down
14 changes: 7 additions & 7 deletions core/systems/input/input_plumber_profile.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class_name InputPlumberProfile

## Supported target devices to emulate
enum TargetDevice {
Gamepad,
Mouse,
Keyboard,
DualSense,
DualSenseEdge,
SteamDeck,
XBox360,
XBoxElite,
}

## Version of the config
Expand Down Expand Up @@ -61,8 +61,6 @@ static func from_dict(dict: Dictionary) -> InputPlumberProfile:
for target_device_str: String in target_devices_strs:
var target_device: TargetDevice
match target_device_str:
"gamepad":
target_device = TargetDevice.Gamepad
"mouse":
target_device = TargetDevice.Mouse
"keyboard":
Expand All @@ -75,6 +73,8 @@ static func from_dict(dict: Dictionary) -> InputPlumberProfile:
target_device = TargetDevice.SteamDeck
"xb360":
target_device = TargetDevice.XBox360
"xbox-elite":
target_device = TargetDevice.XBoxElite
devices.append(target_device)
obj.target_devices = devices

Expand All @@ -101,8 +101,6 @@ static func from_json(json: String) -> InputPlumberProfile:
static func get_target_device_string(target_device: TargetDevice) -> String:
var target_device_str: String = ""
match target_device:
TargetDevice.Gamepad:
target_device_str = "gamepad"
TargetDevice.Mouse:
target_device_str = "mouse"
TargetDevice.Keyboard:
Expand All @@ -115,15 +113,15 @@ static func get_target_device_string(target_device: TargetDevice) -> String:
target_device_str = "deck"
TargetDevice.XBox360:
target_device_str = "xb360"
TargetDevice.XBoxElite:
target_device_str = "xbox-elite"
return target_device_str


## Return the target device for the given target device string
static func get_target_device(target_device_str: String) -> TargetDevice:
var target_device: TargetDevice
match target_device_str:
"gamepad":
target_device = TargetDevice.Gamepad
"mouse":
target_device = TargetDevice.Mouse
"keyboard":
Expand All @@ -136,6 +134,8 @@ static func get_target_device(target_device_str: String) -> TargetDevice:
target_device = TargetDevice.SteamDeck
"xb360":
target_device = TargetDevice.XBox360
"xbox-elite":
target_device = TargetDevice.XBoxElite
return target_device


Expand Down
27 changes: 14 additions & 13 deletions core/ui/card_ui/gamepad/gamepad_settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var gamepad: InputPlumber.CompositeDevice
var profile: InputPlumberProfile
var profile_gamepad: String
var library_item: LibraryItem
var gamepad_types := ["Generic Gamepad", "DualSense Edge"]#"XBox 360", "DualSense", "Steam Deck"
var gamepad_types_icons := ["XBox 360", "PS5"] #"XBox 360", "PS5", "Steam Deck" From res://assets/gamepad/icon_mappings
var gamepad_types := ["Xbox 360", "XBox One Elite" ,"DualSense Edge"]# "DualSense", "Steam Deck"
var gamepad_types_icons := ["XBox 360", "Xbox One", "PS5"] # "PS5", "Steam Deck" From res://assets/gamepad/icon_mappings
var gamepad_type_selected := 0
var mapping_elements: Dictionary = {}
var logger := Log.get_logger("GamepadSettings", Log.LEVEL.INFO)
var logger := Log.get_logger("GamepadSettings", Log.LEVEL.DEBUG)

@onready var in_game_panel := $%InGamePanel as Control
@onready var gamepad_label := $%GamepadLabel as Label
Expand Down Expand Up @@ -548,18 +548,18 @@ func _on_mapping_selected(mapping: InputPlumberMapping) -> void:
func get_selected_target_gamepad() -> InputPlumberProfile.TargetDevice:
var selected_gamepad := self.gamepad_types[self.gamepad_type_selected] as String
match selected_gamepad:
"Generic Gamepad":
return InputPlumberProfile.TargetDevice.Gamepad
"XBox 360":
return InputPlumberProfile.TargetDevice.XBox360
"XBox One Elite":
return InputPlumberProfile.TargetDevice.XBoxElite
"DualSense":
return InputPlumberProfile.TargetDevice.DualSenseEdge
"DualSense Edge":
return InputPlumberProfile.TargetDevice.DualSenseEdge
"Steam Deck":
return InputPlumberProfile.TargetDevice.SteamDeck

return InputPlumberProfile.TargetDevice.Gamepad
logger.error(selected_gamepad + " not found. Using XBox360")
return InputPlumberProfile.TargetDevice.XBox360


## Returns the name of the gamepad icon map to use for target capabilities
Expand All @@ -571,18 +571,19 @@ func get_selected_target_gamepad_icon_map() -> String:
## Returns the gamepad type text for the given InputPlumber gamepad string
func get_target_gamepad_text(gamepad_type: InputPlumberProfile.TargetDevice) -> String:
match gamepad_type:
InputPlumberProfile.TargetDevice.Gamepad:
return "Generic Gamepad"
InputPlumberProfile.TargetDevice.XBox360:
return "XBox 360"
InputPlumberProfile.TargetDevice.DualSense:
return "DualSense"
InputPlumberProfile.TargetDevice.DualSenseEdge:
return "DualSense Edge"
InputPlumberProfile.TargetDevice.SteamDeck:
return "Steam Deck"

return "Generic Gamepad"
InputPlumberProfile.TargetDevice.XBox360:
return "XBox 360"
InputPlumberProfile.TargetDevice.XBoxElite:
return "XBox One Elite"

logger.error("Gamepad Type: " + str(gamepad_type) + " not found. Using XBox360")
return "XBox 360"


# Set the given profile for the given composte device.
Expand Down

0 comments on commit dbdb5be

Please sign in to comment.