Skip to content
Snippets Groups Projects
Commit aee9a3e4 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

+ LED & eggnog → config file

parent 908ef4a0
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#configure working directories
export workingDirectory="/where/gamepad-switcher/is"
export killProcessesScript="a/shell/file/that/will/be/created/and/erased/in/working/directory"
\ No newline at end of file
...@@ -3,6 +3,21 @@ ...@@ -3,6 +3,21 @@
# 2 parameters can be used : 1 → x for xbox controller, p for ps3 # 2 parameters can be used : 1 → x for xbox controller, p for ps3
# 2 → name of the game as suggested in menu # 2 → name of the game as suggested in menu
#configuration
. ./config.sh
cd $workingDirectory
if [ -e "$killProcessesScript" ]
then
echo "There seems to be (a) running instance(s) of the game controller, do you want to brutally kill the processes? (Y/n)\nI'm not sure what it does if you don't…"
read userinput
if [ "$userinput" = "Y" ]
then
sh $killProcessesScript
rm $killProcessesScript
sleep 1
fi
fi
if [ $# = 0 ] if [ $# = 0 ]
then then
echo "(X)box or (P)S3 ?" echo "(X)box or (P)S3 ?"
...@@ -33,11 +48,12 @@ else ...@@ -33,11 +48,12 @@ else
echo What game would you like to play? echo What game would you like to play?
echo 1\) vvvvvv echo 1\) vvvvvv
echo 2\) Braid echo 2\) Braid
echo 3\) Limbo echo 3\) Eggnogg
echo 4\) Lone Survivor echo 93\) Limbo
echo 5\) Minecraft echo 94\) Lone Survivor
echo 6\) Psychonauts echo 95\) Minecraft
echo 7\) Amnesia echo 96\) Psychonauts
echo 97\) Amnesia
echo "99) None, give me my gamepad mode back." echo "99) None, give me my gamepad mode back."
read userinput read userinput
fi fi
...@@ -55,31 +71,38 @@ then ...@@ -55,31 +71,38 @@ then
echo echo
cd modules cd modules
./braid.sh ./braid.sh
elif [ "$userinput" = 3 -o "$userinput" = "Limbo" -o "$userinput" = "limbo" ] elif [ "$userinput" = 3 -o "$userinput" = "Eggnogg" -o "$userinput" = "eggnogg" -o "$userinput" = "egg" -o "$userinput" = "E" -o "$userinput" = "e" ]
then
echo "Your controllerS will now be configured for eggnogg."
#Different types of controllers could be configured, but it's not my case so I won't do it ;)
echo
cd modules
./eggnogg.sh
elif [ "$userinput" = 93 -o "$userinput" = "Limbo" -o "$userinput" = "limbo" ]
then then
echo "Your controller will now be configured for Limbo." echo "Your controller will now be configured for Limbo."
echo echo
cd modules cd modules
./limbo.sh ./limbo.sh
elif [ "$userinput" = 4 -o "$userinput" = "Lone Survivor" -o "$userinput" = "lone survivor" ] elif [ "$userinput" = 94 -o "$userinput" = "Lone Survivor" -o "$userinput" = "lone survivor" ]
then then
echo "Your controller will now be configured for Lone Survivor" echo "Your controller will now be configured for Lone Survivor"
echo echo
cd modules cd modules
./lonesurvivor.sh ./lonesurvivor.sh
elif [ "$userinput" = 5 -o "$userinput" = "Minecraft" -o "$userinput" = "minecraft" ] elif [ "$userinput" = 95 -o "$userinput" = "Minecraft" -o "$userinput" = "minecraft" ]
then then
echo "Your controller will now be configured for Minecraft." echo "Your controller will now be configured for Minecraft."
echo echo
cd modules cd modules
./minecraft.sh ./minecraft.sh
elif [ "$userinput" = 6 -o "$userinput" = "Psychonauts" -o "$userinput" = "psychonauts" ] elif [ "$userinput" = 96 -o "$userinput" = "Psychonauts" -o "$userinput" = "psychonauts" ]
then then
echo "Your controller will now be configured for Psychonauts." echo "Your controller will now be configured for Psychonauts."
echo echo
cd modules cd modules
./psychonauts.sh ./psychonauts.sh
elif [ "$userinput" = 7 -o "$userinput" = "Amnesia" -o "$userinput" = "amnesia" ] elif [ "$userinput" = 97 -o "$userinput" = "Amnesia" -o "$userinput" = "amnesia" ]
then then
echo "Your controller will now be configured for Amnesia." echo "Your controller will now be configured for Amnesia."
echo echo
......
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c amnesia.xboxdrv -s sudo xboxdrv$pad -c amnesia.xboxdrv -s --led 2
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c braid.xboxdrv -s sudo xboxdrv$pad -c braid.xboxdrv -s --led 2
#!/bin/bash
# Define the default gamepad module name
module=xpad
# Check if the module is already loaded, if so, remove it and run the xboxdrv module
if lsmod | grep -q "^$module "
then sudo rmmod xpad
fi
if [ ! -e "$workingDirectory$killProcessesScript" ]
then
touch "$workingDirectory$killProcessesScript"
fi
sudo xboxdrv$pad -s -i 0 --led 2 &
echo "controller1 is being handled by process number $!"
if [ -f "$workingDirectory$killProcessesScript" ]
then
echo "sudo kill $!" > "$workingDirectory$killProcessesScript"
fi
sudo xboxdrv$pad -s -i 1 --led 3 &
echo "controller2 is being handled by process number $!"
if [ -f "$workingDirectory$killProcessesScript" ]
then
echo "sudo kill $!" >> "$workingDirectory$killProcessesScript"
fi
\ No newline at end of file
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c limbo.xboxdrv -s sudo xboxdrv$pad -c limbo.xboxdrv -s --led 2
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c lonesurvivor.xboxdrv -s sudo xboxdrv$pad -c lonesurvivor.xboxdrv -s --led 2
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c minecraft.xboxdrv -s sudo xboxdrv$pad -c minecraft.xboxdrv -s --led 2
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c psychonauts.xboxdrv -s sudo xboxdrv$pad -c psychonauts.xboxdrv -s --led 2
...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module " ...@@ -8,4 +8,4 @@ if lsmod | grep -q "^$module "
then sudo rmmod xpad then sudo rmmod xpad
fi fi
sudo xboxdrv$pad -c vvvvvv.xboxdrv -s sudo xboxdrv$pad --led 2 -c vvvvvv.xboxdrv -s
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module=xpad module=xpad
if lsmod | grep -q "^$module " if lsmod | grep -q "^$module "
then echo "Xpad already loaded." then echo "Xpad already loaded."
else echo "Controller has been returned to normal function." else sudo modprobe xpad
sudo modprobe xpad echo "Controller has been returned to normal function."
echo echo
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment