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
4 changes: 3 additions & 1 deletion deckpad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +35,8 @@ function run_as_root() {
restore_brightness
reenable_sleep
stop_virtualhere
wait quit_prompt_pid
reset_controller
wait $quit_prompt_pid
}

source ./functions.sh
Expand Down
19 changes: 19 additions & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}