Skip to content

Commit 9915f1d

Browse files
committed
steamcontroller: switch to a different upstream source
Changed to use the driver from https://github.com/Ryochan7/sc-controller since it offers a Python3 compatible version. Module has been updatd updated/reworked: - the driver repo is no longer cloned to $md_inst, so 'noinstclean' flag is not necessary - installation is still done `virtualenv`, in Bookworm and later this becomes mandatory Note: the `--no-site-packages` was removed in the `virtualenv` call since it's ignored in v15 (version from Buster) and was removed in v20 - the `install` function is a mix of build/install, but since `install` cleans up $md_inst, it's necessary to have them there. - added an update hook that removes the old driver start-up sequence in `/etc/rc.local` - some minor re-wording of the text shown in the dialogs Untested with a real controller, unfortunately, since I don't have one.
1 parent 4c63277 commit 9915f1d

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

scriptmodules/supplementary/steamcontroller.sh

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,52 @@
1010
#
1111

1212
rp_module_id="steamcontroller"
13-
rp_module_desc="Standalone Steam Controller Driver"
14-
rp_module_help="Steam Controller Driver from https://github.com/ynsta/steamcontroller"
15-
rp_module_licence="MIT https://raw.githubusercontent.com/ynsta/steamcontroller/master/LICENSE"
16-
rp_module_repo="git https://github.com/ynsta/steamcontroller.git master"
13+
rp_module_desc="User-mode driver for Steam Controller"
14+
rp_module_help="Steam Controller Driver from https://github.com/Ryochan7/sc-controller"
15+
rp_module_licence="GPL2 https://raw.githubusercontent.com/Ryochan7/sc-controller/python3/LICENSE"
16+
rp_module_repo="git https://github.com/Ryochan7/sc-controller python3"
1717
rp_module_section="driver"
18-
rp_module_flags="noinstclean"
1918

19+
function _update_hook_steamcontroller() {
20+
# remove the start command from the previous scriptmodule version
21+
if rp_isInstalled "$md_id"; then
22+
sed -i "/bin\/sc-.*.py/d" /etc/rc.local
23+
fi
24+
}
2025
function depends_steamcontroller() {
21-
getDepends virtualenv python3-dev
26+
getDepends python3-virtualenv python3-dev python3-setuptools
2227
}
2328

2429
function sources_steamcontroller() {
25-
gitPullOrClone "$md_inst"
30+
gitPullOrClone
2631
}
2732

2833
function install_steamcontroller() {
29-
cd "$md_inst"
30-
chown -R "$user:$user" "$md_inst"
31-
sudo -u $user bash -c "\
32-
virtualenv -p python3 --no-site-packages \"$md_inst\"; \
33-
source bin/activate; \
34-
pip3 install libusb1; \
35-
python3 setup.py install; \
36-
"
34+
# build the driver in a virtualenv created in $md_inst
35+
virtualenv -p python3 "$md_inst"
36+
source "$md_inst/bin/activate"
37+
pip3 install libusb1 evdev
38+
pip3 install "sccontroller @ file://$md_build"
39+
deactivate
40+
41+
# copy the default controller profiles
42+
md_ret_files=("default_profiles")
3743
}
3844

3945
function enable_steamcontroller() {
40-
local mode="$1"
41-
[[ -z "$mode" ]] && mode="xbox"
46+
local profile="$1"
47+
[[ -z "$profile" ]] && profile="XBox Controller"
4248

43-
local config="\"$md_inst/bin/sc-$mode.py\" start"
49+
local config="\"$md_inst/bin/scc-daemon\" \"$md_inst/default_profiles/$profile.sccprofile\" start"
4450

4551
disable_steamcontroller
4652
sed -i "s|^exit 0$|${config}\\nexit 0|" /etc/rc.local
47-
printMsgs "dialog" "$md_id enabled in /etc/rc.local with the following config\n\n$config\n\nIt will be started on next boot."
53+
printMsgs "dialog" "Steamcontroller enabled in /etc/rc.local with the following profile:\n\n$profile\n\nIt will be started on next boot."
4854
}
4955

5056
function disable_steamcontroller() {
51-
sed -i "/bin\/sc-.*.py/d" /etc/rc.local
57+
sed -i "/bin\/sc-.*.py/d" /etc/rc.local # previous version
58+
sed -i "/bin\/scc-daemon.*start/d" /etc/rc.local # current version
5259
}
5360

5461
function remove_steamcontroller() {
@@ -61,6 +68,9 @@ function configure_steamcontroller() {
6168
# Steam controller keyboard/mouse mode
6269
SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", GROUP="input", MODE="0660"
6370
71+
# Valve HID devices over bluetooth hidraw
72+
KERNEL=="hidraw*", KERNELS=="*28de:*", MODE="0660", GROUP="input", TAG+="uaccess"
73+
6474
# Steam controller gamepad mode
6575
KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
6676
_EOF_
@@ -69,19 +79,19 @@ _EOF_
6979
function gui_steamcontroller() {
7080
local cmd=(dialog --backtitle "$__backtitle" --menu "Choose an option." 22 86 16)
7181
local options=(
72-
1 "Enable steamcontroller (xbox 360 mode)"
73-
2 "Enable steamcontroller (desktop mouse/keyboard mode)"
74-
3 "Disable steamcontroller"
82+
1 "Enable Steamcontroller (Xbox controller mode)"
83+
2 "Enable Steamcontroller (Desktop mouse/keyboard mode)"
84+
3 "Disable Steamcontroller"
7585
)
7686
while true; do
7787
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
7888
if [[ -n "$choice" ]]; then
7989
case "$choice" in
8090
1)
81-
enable_steamcontroller xbox
91+
enable_steamcontroller "XBox Controller"
8292
;;
8393
2)
84-
enable_steamcontroller desktop
94+
enable_steamcontroller "Desktop"
8595
;;
8696
3)
8797
disable_steamcontroller

0 commit comments

Comments
 (0)