Skip to content

Commit

Permalink
fix(Platform): Support asus-hid patches.
Browse files Browse the repository at this point in the history
- Detect board_name revision for newer ROG Ally.
- Adjust keymap for ROG Ally to align with hid-asus.
  • Loading branch information
pastaq authored and Derek J. Clark committed Feb 3, 2024
1 parent 70e5de0 commit faef66e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 125 deletions.
2 changes: 1 addition & 1 deletion core/global/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func _read_dmi() -> PLATFORM:
return PLATFORM.AOKZOE_GEN2

# ASUS
elif product_name == "ROG Ally RC71L_RC71L" and vendor_name == "ASUSTeK COMPUTER INC.":
elif product_name.contains("ROG Ally RC71L") and vendor_name == "ASUSTeK COMPUTER INC.":
logger.debug("Detected ROG Ally Gen 1 platform")
return PLATFORM.ALLY_GEN1

Expand Down
6 changes: 5 additions & 1 deletion core/platform/handheld/asus/rog_ally_gen1.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extends HandheldPlatform
class_name ROGAllyPlatform


const GAMEPAD_ADDRESS_LIST : PackedStringArray =[
'usb-0000:08:00.3-2/input0',
'usb-0000:09:00.3-2/input0',
Expand All @@ -12,6 +11,11 @@ const GAMEPAD_ADDRESS_LIST : PackedStringArray =[
## Detects the phys_path of the gamepad. This changes depending on BIOS
## version and if some hardware is enabled.
func identify_controller_phys() -> void:
# The asus-his driver needs some time to switch to gamepad mode after initializing. Hiding the
# event file descriptors before this happens will cause the action to fail. Wait a moment.
logger.debug("Waiting 5s for ROG Ally controller to be ready...")
await OS.delay_msec(5000)

var sysfs_devices := SysfsDevice.get_all()
for sysfs_device in sysfs_devices:
if sysfs_device.name != gamepad.name:
Expand Down
134 changes: 11 additions & 123 deletions core/platform/handheld/asus/rog_ally_gen1.tres
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
[gd_resource type="Resource" script_class="ROGAllyPlatform" load_steps=58 format=3 uid="uid://2r4kb0gdossd"]
[gd_resource type="Resource" script_class="ROGAllyPlatform" load_steps=33 format=3 uid="uid://2r4kb0gdossd"]

[ext_resource type="Script" path="res://core/systems/input/sysfs_device.gd" id="1_axpce"]
[ext_resource type="Script" path="res://core/systems/input/events/evdev_key_event.gd" id="2_erkly"]
[ext_resource type="Script" path="res://core/platform/handheld_event_mapping.gd" id="2_i7tm2"]
[ext_resource type="Script" path="res://core/platform/handheld/asus/rog_ally_gen1.gd" id="4_d478u"]

[sub_resource type="Resource" id="Resource_jig00"]
script = ExtResource("2_erkly")
code = "KEY_F15"

[sub_resource type="Resource" id="Resource_cftpj"]
script = ExtResource("2_erkly")
code = "KEY_F18"
Expand Down Expand Up @@ -46,7 +42,7 @@ code = "KEY_DELETE"

[sub_resource type="Resource" id="Resource_c0ufj"]
script = ExtResource("2_erkly")
code = "BTN_MODE"
code = "KEY_KEYBOARD"

[sub_resource type="Resource" id="Resource_8y4kr"]
script = ExtResource("2_i7tm2")
Expand Down Expand Up @@ -84,140 +80,32 @@ emits = SubResource("Resource_xvlh1")

[sub_resource type="Resource" id="Resource_u82fj"]
script = ExtResource("2_erkly")
code = "KEY_F12"
code = "KEY_F14"

[sub_resource type="Resource" id="Resource_prvjy"]
script = ExtResource("2_erkly")
code = "KEY_F13"
code = "BTN_THUMBL"

[sub_resource type="Resource" id="Resource_3m31m"]
script = ExtResource("2_i7tm2")
name = "Paddle + D Pad UP"
name = "LPaddle"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_u82fj")])
emits = SubResource("Resource_prvjy")

[sub_resource type="Resource" id="Resource_deocj"]
script = ExtResource("2_erkly")
code = "KEY_D"

[sub_resource type="Resource" id="Resource_ji0t3"]
script = ExtResource("2_erkly")
code = "KEY_LEFTMETA"
code = "KEY_F15"

[sub_resource type="Resource" id="Resource_jt7iy"]
script = ExtResource("2_erkly")
code = "KEY_F14"
code = "BTN_THUMBR"

[sub_resource type="Resource" id="Resource_ylk53"]
script = ExtResource("2_i7tm2")
name = "Paddle + D Pad LEFT"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_deocj"), SubResource("Resource_ji0t3")])
name = "RPaddle"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_ji0t3")])
emits = SubResource("Resource_jt7iy")

[sub_resource type="Resource" id="Resource_qog3q"]
script = ExtResource("2_erkly")
code = "KEY_TAB"

[sub_resource type="Resource" id="Resource_p64sj"]
script = ExtResource("2_erkly")
code = "KEY_LEFTMETA"

[sub_resource type="Resource" id="Resource_cn41b"]
script = ExtResource("2_erkly")
code = "KEY_F15"

[sub_resource type="Resource" id="Resource_q7p5v"]
script = ExtResource("2_i7tm2")
name = "Paddle + D Pad RIGHT"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_qog3q"), SubResource("Resource_p64sj")])
emits = SubResource("Resource_cn41b")

[sub_resource type="Resource" id="Resource_sjsp6"]
script = ExtResource("2_erkly")
code = "KEY_ESC"

[sub_resource type="Resource" id="Resource_sltd6"]
script = ExtResource("2_erkly")
code = "KEY_LEFTCTRL"

[sub_resource type="Resource" id="Resource_qfdt5"]
script = ExtResource("2_erkly")
code = "KEY_LEFTSHIFT"

[sub_resource type="Resource" id="Resource_feewq"]
script = ExtResource("2_erkly")
code = "KEY_F16"

[sub_resource type="Resource" id="Resource_mpcxg"]
script = ExtResource("2_i7tm2")
name = "Paddle + D Pad DOWN"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_sjsp6"), SubResource("Resource_sltd6"), SubResource("Resource_qfdt5")])
emits = SubResource("Resource_feewq")

[sub_resource type="Resource" id="Resource_d4thf"]
script = ExtResource("2_erkly")
code = "KEY_F14"

[sub_resource type="Resource" id="Resource_6cjhh"]
script = ExtResource("2_erkly")
code = "KEY_PRINT"

[sub_resource type="Resource" id="Resource_newxp"]
script = ExtResource("2_i7tm2")
name = "Paddle + Y"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_d4thf")])
emits = SubResource("Resource_6cjhh")

[sub_resource type="Resource" id="Resource_0dbxl"]
script = ExtResource("2_erkly")
code = "KEY_P"

[sub_resource type="Resource" id="Resource_35k2h"]
script = ExtResource("2_erkly")
code = "KEY_LEFTMETA"

[sub_resource type="Resource" id="Resource_g70rx"]
script = ExtResource("2_erkly")
code = "KEY_KEYBOARD"

[sub_resource type="Resource" id="Resource_0k5rj"]
script = ExtResource("2_i7tm2")
name = "Paddle + X"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_0dbxl"), SubResource("Resource_35k2h")])
emits = SubResource("Resource_g70rx")

[sub_resource type="Resource" id="Resource_r1be2"]
script = ExtResource("2_erkly")
code = "KEY_N"

[sub_resource type="Resource" id="Resource_26b40"]
script = ExtResource("2_erkly")
code = "KEY_LEFTMETA"

[sub_resource type="Resource" id="Resource_2jh33"]
script = ExtResource("2_erkly")
code = "KEY_F17"

[sub_resource type="Resource" id="Resource_js4wk"]
script = ExtResource("2_i7tm2")
name = "Paddle + B"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_r1be2"), SubResource("Resource_26b40")])
emits = SubResource("Resource_2jh33")

[sub_resource type="Resource" id="Resource_usy36"]
script = ExtResource("2_erkly")
code = "KEY_F10"

[sub_resource type="Resource" id="Resource_gtox1"]
script = ExtResource("2_erkly")
code = "KEY_F18"

[sub_resource type="Resource" id="Resource_tivas"]
script = ExtResource("2_i7tm2")
name = "Paddle + A"
activation_keys = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_usy36")])
emits = SubResource("Resource_gtox1")

[sub_resource type="Resource" id="Resource_2ns7h"]
script = ExtResource("1_axpce")
phys_path = "usb-0000:08:00.3-3/input0"
Expand Down Expand Up @@ -250,8 +138,8 @@ name = "Asus Keyboard"

[resource]
script = ExtResource("4_d478u")
key_map = Array[ExtResource("2_i7tm2")]([SubResource("Resource_dwdqb"), SubResource("Resource_8y4kr"), SubResource("Resource_mw23h"), SubResource("Resource_cjdu4"), SubResource("Resource_3m31m"), SubResource("Resource_ylk53"), SubResource("Resource_q7p5v"), SubResource("Resource_mpcxg"), SubResource("Resource_newxp"), SubResource("Resource_0k5rj"), SubResource("Resource_js4wk"), SubResource("Resource_tivas")])
filtered_events = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_jig00"), SubResource("Resource_cftpj")])
key_map = Array[ExtResource("2_i7tm2")]([SubResource("Resource_dwdqb"), SubResource("Resource_8y4kr"), SubResource("Resource_mw23h"), SubResource("Resource_cjdu4"), SubResource("Resource_3m31m"), SubResource("Resource_ylk53")])
filtered_events = Array[Resource("res://core/systems/input/events/evdev_event.gd")]([SubResource("Resource_cftpj")])
keypads = Array[ExtResource("1_axpce")]([SubResource("Resource_2ns7h"), SubResource("Resource_wg8mr"), SubResource("Resource_0bqvh"), SubResource("Resource_rvkws"), SubResource("Resource_vrwpa"), SubResource("Resource_f5xpk")])
gamepad = SubResource("Resource_4p6pj")
icon_mappings = Array[Resource("res://core/platform/handheld/handheld_icon_mapping.gd")]([])
Expand Down

0 comments on commit faef66e

Please sign in to comment.