Skip to content

Commit 1a182cf

Browse files
author
Richard Siomporas
committed
Shuffled and moved, testing one last thing
1 parent 557dcbf commit 1a182cf

File tree

9 files changed

+52
-34
lines changed

9 files changed

+52
-34
lines changed

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -
1818
tzdata \
1919
usbutils \
2020
nano \
21+
python-usb \
2122
software-properties-common
2223

2324
RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata
@@ -42,13 +43,14 @@ RUN cd RetroPie-Setup \
4243
&& sudo ./retropie_packages.sh setup basic_install
4344

4445

45-
# Install USB resetting utility
46-
COPY reset_controller.py /usr/bin/reset_controller.py
47-
RUN chmod +x /usr/bin/reset_controller.py
46+
# Install USB controller resetting utility
47+
COPY utilities/reset_controller.py /opt/retropie/configs/all/reset_controller.py
48+
RUN chmod +x /opt/retropie/configs/all/reset_controller.py
49+
COPY utilities/reset_controller.py /opt/retropie/configs/all/reset_controller.sh
50+
RUN chmod +x /opt/retropie/configs/all/reset_controller.sh
4851

4952
# And install script hooks
50-
51-
COPY runcommand-onstart.sh /opt/retropie/configs/all/runcommand-onstart.sh
53+
COPY utilities/runcommand-onstart.sh /opt/retropie/configs/all/runcommand-onstart.sh
5254
RUN chmod +x /opt/retropie/configs/all/runcommand-onstart.sh
5355

5456
# Edit this file in your persistent storage to use all or part of the name provided from "lsusb" to reset the controller on each start

copy_scripts.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

reset_controller.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

retropie.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

runcommand-onstart.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

utilities/copy_scripts.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
cp ~/Projects/retropie-container/runcommand-onstart.sh ~/.config/retropie-container/configs/all/runcommand-onstart.sh && chmod +x ~/.config/retropie-container/configs/all/runcommand-onstart.sh
3+
cp ~/Projects/retropie-container/reset_controller.py ~/.config/retropie-container/configs/all/reset_controller.py && chmod +x ~/.config/retropie-container/configs/all/reset_controller.py
4+
cp ~/Projects/retropie-container/reset_controller.sh ~/.config/retropie-container/configs/all/reset_controller.sh && chmod +x ~/.config/retropie-container/configs/all/reset_controller.sh

utilities/reset_controller.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
from usb.core import find as finddev
5+
id = ""
6+
vendor = ""
7+
try:
8+
if len(sys.argv) == 3:
9+
vendor = sys.argv[1]
10+
id = sys.argv[2]
11+
12+
elif len(sys.argv) == 2:
13+
args = sys.argv[1]
14+
args.replace(":", " ")
15+
vendor = args.split()[0]
16+
id = args.split()[1]
17+
18+
dev = finddev(idVendor=int("0x"+ vendor, 16), idProduct=int("0x" + id, 16))
19+
dev.reset()
20+
print("Should have reset " + vendor+ ":" + id)
21+
22+
except Exception, msg:
23+
print "failed to reset device:", msg3
24+
25+
26+
27+
28+

reset_controller.sh renamed to utilities/reset_controller.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
#!/bin/bash
2-
sleep 10 # change this as necessary to ensure enough time is available for the emulator to start
2+
until pids=$(pidof retroarch)
3+
do
4+
sleep 1
5+
done
6+
7+
sleep 3
8+
39
declare -a controller_names
410
readarray controller_names < /opt/retropie/configs/all/controller_names
511

612
let i=0
713
while (( ${#controller_names[@]} > i )); do
814
controller="${controller_names[i++]}"
9-
sudo reset_controller.py "$controller"
15+
sudo /opt/retropie/configs/all/reset_controller.py "$controller"
1016
sleep 1
11-
sudo reset_controller.py "$controller"
17+
sudo /opt/retropie/configs/all/reset_controller.py "$controller"
18+
1219
printf "Attempt to reset $controller\n"
1320
done
1421

utilities/runcommand-onstart.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
/opt/retropie/configs/all/reset_controller.sh&
3+

0 commit comments

Comments
 (0)