From dbdb5bec66cf9f60ee82cb9288247a6fd1021d95 Mon Sep 17 00:00:00 2001 From: "Derek J. Clark" Date: Fri, 28 Jun 2024 16:12:14 -0700 Subject: [PATCH] fix(Target Device): Update target devices to latest InputPlumber version. --- assets/gamepad/icon_mappings/xbox360.tres | 2 +- assets/gamepad/icon_mappings/xboxone.tres | 2 +- core/systems/input/input_plumber_profile.gd | 14 +++++------ core/ui/card_ui/gamepad/gamepad_settings.gd | 27 +++++++++++---------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/assets/gamepad/icon_mappings/xbox360.tres b/assets/gamepad/icon_mappings/xbox360.tres index eea21dc6..e9968380 100644 --- a/assets/gamepad/icon_mappings/xbox360.tres +++ b/assets/gamepad/icon_mappings/xbox360.tres @@ -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") diff --git a/assets/gamepad/icon_mappings/xboxone.tres b/assets/gamepad/icon_mappings/xboxone.tres index 2e853b14..99bd09f8 100644 --- a/assets/gamepad/icon_mappings/xboxone.tres +++ b/assets/gamepad/icon_mappings/xboxone.tres @@ -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") diff --git a/core/systems/input/input_plumber_profile.gd b/core/systems/input/input_plumber_profile.gd index 27a62e55..04b61e0b 100644 --- a/core/systems/input/input_plumber_profile.gd +++ b/core/systems/input/input_plumber_profile.gd @@ -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 @@ -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": @@ -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 @@ -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: @@ -115,6 +113,8 @@ 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 @@ -122,8 +122,6 @@ static func get_target_device_string(target_device: TargetDevice) -> 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": @@ -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 diff --git a/core/ui/card_ui/gamepad/gamepad_settings.gd b/core/ui/card_ui/gamepad/gamepad_settings.gd index f7ecc487..5d07a48f 100644 --- a/core/ui/card_ui/gamepad/gamepad_settings.gd +++ b/core/ui/card_ui/gamepad/gamepad_settings.gd @@ -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 @@ -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 @@ -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.