From 8fbf9349cfae3b9f0d86e0f8282135f4b301e58b Mon Sep 17 00:00:00 2001 From: Joshwiker14 Date: Sat, 6 Jul 2024 19:12:18 -0600 Subject: [PATCH 1/3] Reset built-in controller after disconnect The built-in controller doesn't always work after disconnecting from a Virtualhere client, Reset the xhci driver for the usb hub connected to the built-in controller after disconnect. --- deckpad.sh | 2 ++ functions.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/deckpad.sh b/deckpad.sh index 47a91da..b7de3ea 100755 --- a/deckpad.sh +++ b/deckpad.sh @@ -21,6 +21,7 @@ function run_as_root() { # Start set_brightness_to_minimum disable_sleep + find_controller start_virtualhere # Run - Block until Tap on screen @@ -34,6 +35,7 @@ function run_as_root() { restore_brightness reenable_sleep stop_virtualhere + reset_controller wait quit_prompt_pid } diff --git a/functions.sh b/functions.sh index 5d9f6e2..e9fb87f 100644 --- a/functions.sh +++ b/functions.sh @@ -141,3 +141,22 @@ function run_prompt_stop { kill -s SIGKILL $(cat ./run_prompt_pid) rm ./run_prompt_pid } +function find_controller { + # Locate the Built-in Steam controller by USB Vendor id (28de) and USB Product id (1205) + # These ids are different from the steam controller wireless dongle and the wired controller + + # Fills variable steam_controller with directory of matching device + read -r -d '' steam_controller < <(find /sys/devices -path "*usb*" -type d -execdir sh -c 'grep --no-messages --silent "28de" "$0/idVendor" && grep --no-messages --silent "1205" "$0/idProduct"' '{}' \; -print0 2>/dev/null) + # Extract PCI bus id for the usb controller from the device path + steam_controller="${steam_controller%/*/*}" + steam_controller="${steam_controller##*/}" + echo "$steam_controller" >./controller_id +} + +function reset_controller { + xhci_driver_path="/sys/bus/pci/drivers/xhci_hcd" + # Using both unbind/bind seems to be more reliable than just bind + cat "./controller_id" >"$xhci_driver_path/unbind" + cat "./controller_id" >"$xhci_driver_path/bind" + rm ./controller_id +} \ No newline at end of file From 3397440eddb454821634cd18eb2af8a3343cf058 Mon Sep 17 00:00:00 2001 From: Joshwiker14 Date: Mon, 15 Jul 2024 00:04:33 -0600 Subject: [PATCH 2/3] Small bugfix --- deckpad.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deckpad.sh b/deckpad.sh index b7de3ea..a8e88eb 100755 --- a/deckpad.sh +++ b/deckpad.sh @@ -36,7 +36,12 @@ function run_as_root() { reenable_sleep stop_virtualhere reset_controller +<<<<<<< HEAD wait quit_prompt_pid +======= + wait $quit_prompt_pid + trap - EXIT +>>>>>>> 9d44ff1 (Small bugfix) } source ./functions.sh From 701ac9842acc7b1ef147a3d23afaab08d734c638 Mon Sep 17 00:00:00 2001 From: Joshwiker14 Date: Sat, 3 Aug 2024 16:06:10 -0600 Subject: [PATCH 3/3] fixup! Small bugfix --- deckpad.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/deckpad.sh b/deckpad.sh index a8e88eb..8fcbb9e 100755 --- a/deckpad.sh +++ b/deckpad.sh @@ -36,12 +36,7 @@ function run_as_root() { reenable_sleep stop_virtualhere reset_controller -<<<<<<< HEAD - wait quit_prompt_pid -======= wait $quit_prompt_pid - trap - EXIT ->>>>>>> 9d44ff1 (Small bugfix) } source ./functions.sh