Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/global/launch_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func set_gamepad_profile(profile_path: String, target_gamepad: String = "") -> v
if not target_gamepad.is_empty():
var target_devices := PackedStringArray([target_gamepad, "keyboard", "mouse"])
match target_gamepad:
"xb360", "xbox-series", "xbox-elite", "gamepad", "hori-steam":
"xb360", "xbox-series", "xbox-elite", "gamepad", "hori-steam", "deck", "deck-uhid":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the deck's build in touchpads should work as touchpads within steam and on the desktop when steam is running. What problem is this solving?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats the problem. if we just pass through the touchpad motions we get both sides acting as touchpads instead of how they are supposed to behave in the inputplumber driver, BUT since touchpad target is never passed through, they do nothing:

Expected from steam:
When inputplumber is running and deck or deck-uhid is NOT being used, we get SteamOS behavior. which is leftpad dpad right pad nothing.

Current problem:
When inputplumber is running and deck or deck-uhid IS being used, we're currently just passing the touchpad
motions through, which means both of them act like mouse touchpads, HOWEVER because ogui doesnt pass touchpad as a target device, neither touchpad works.

This fix:
When inputplumber is running and deck or deck-uhid IS being used, we pass both devices through as touchpad motion, and use our driver to map the left as a dpad, this is enhanced better than SteamOS because we also get right pad as a touchpad instead of nothing.

target_devices.append("touchpad")
_:
logger.debug(target_gamepad, "needs no additional target devices.")
Expand Down
60 changes: 46 additions & 14 deletions core/ui/card_ui/gamepad/gamepad_mapper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ func populate_gamepad_mappings_for(capabilities: PackedStringArray, gamepad_icon
if capability.begins_with("Gamepad:Gyro"):
gyro_events.append(capability)
continue
if capability.begins_with("TouchPad:"):
if capability.begins_with("Touchpad:") or capability.begins_with("TouchPad:"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, we should fix that in InputPlumber...

touchpad_events.append(capability)
continue
logger.warn("Unhandled capability: " + capability)

# Create all the button mappings
var label := $%ButtonsLabel
label.visible = button_events.size() > 0
Expand Down Expand Up @@ -197,6 +197,10 @@ func populate_mouse_mappings_for(caps: PackedStringArray) -> void:
for capability in caps:
if capability.begins_with("Mouse:"):
mouse_capabilities.append(capability)
continue
if capability.begins_with("Touchpad:") or capability.begins_with("TouchPad:"):
mouse_capabilities.append(capability)
continue

logger.debug("Found target capabilities for mouse: " + str(mouse_capabilities))

Expand All @@ -209,13 +213,27 @@ func populate_mouse_mappings_for(caps: PackedStringArray) -> void:
var motion_events := PackedStringArray()
for capability: String in mouse_capabilities:
logger.debug("Capability: " + capability)

# Mouse native
if capability.begins_with("Mouse:Button"):
button_events.append(capability)
continue
if capability.begins_with("Mouse:Motion"):
motion_events.append(capability)
continue

# Touchpad -> treat as mouse-like sources
if capability.begins_with("Touchpad:") or capability.begins_with("TouchPad:"):
if capability.find(":Touch:Motion") != -1:
motion_events.append(capability)
continue
if capability.find(":Touch:Button:Press") != -1:
button_events.append(capability)
continue
if capability.find(":Touch:Button:Touch") != -1:
button_events.append(capability)
continue

# Delete any old buttons
for child in mouse_input_container.get_children():
if child is CardInputIconButton or child is CardButton:
Expand All @@ -241,18 +259,32 @@ func _add_button_for_capability(capability: String, parent: Node, neighbor: Node

var button := card_button_scene.instantiate() as CardInputIconButton
button.name = capability
var on_button_ready := func():
button.input_icon.max_width = 64
button.set_target_device_icon_mapping(gamepad_icons_type)
button.input_icon.force_type = 1 # Force type to keyboard/mouse
var button_parent := button.get_parent()
if button.set_target_icon(capability) != OK:
logger.debug("Failed to set icon for capability: " + capability)
button_parent.remove_child(button)
button.queue_free()
if button.input_icon.textures.is_empty():
button_parent.remove_child(button)
button.queue_free()
var on_button_ready := func():
button.input_icon.max_width = 64
button.set_target_device_icon_mapping(gamepad_icons_type)

# Only force keyboard/mouse icons for the Mouse tab (you pass "" there)
if gamepad_icons_type.is_empty():
button.input_icon.force_type = 1 # keyboard/mouse
else:
# Let it behave normally for gamepad icon mapping / dropdown
# (do NOT set force_type at all, or set it to the default value if your widget needs it)
pass

var button_parent := button.get_parent()

# Keep the original behavior: if we cannot render an icon at all, remove the row
if button.set_target_icon(capability) != OK:
logger.debug("Failed to set icon for capability: " + capability)
button_parent.remove_child(button)
button.queue_free()
return

if button.input_icon.textures.is_empty():
button_parent.remove_child(button)
button.queue_free()
return

button.ready.connect(on_button_ready)

# Update the mapping with the selected capability
Expand Down