Skip to content

Commit

Permalink
Merge pull request #139 from beaumanvienna/beta
Browse files Browse the repository at this point in the history
PS3 controller reworked
  • Loading branch information
mdeguzis committed Nov 1, 2014
2 parents d806d4d + 66d20c9 commit 99d0c05
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 1,579 deletions.
158 changes: 150 additions & 8 deletions XBMC-cfgs/extra/gp_autodetect_xbmc.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,162 @@
#!/bin/bash

# Project RetroRig: https://github.com/ProfessorKaos64/RetroRig
# This script detects a change on available PS controller. If detected, it notifies XBMC.
# Author: Jens-Christiansen, aka beaumanvienna/JC
# Revision: 2014/06/21, initial version
#
# This script detects a change of the amount of available PS3 controller.
# If such a change was detected, it notifies XBMC.
#
# If enabled, it will start RetroRig automatically
# for the first game controller being switched on.
#
# Author: Jens-Christian, aka beaumanvienna/JC
#
# Revision: 2014/10/30, support for PS3 / USB and auto start XBMC function

autostartXBMC_PS3_USB=enabled
autostartXBMC_PS3_BT=enabled

controllerAvailable=`cat /proc/bus/input/devices | grep PLAYSTATION`
echo $controllerAvailable
PS3_BT_controllerAvailable=`cat /proc/bus/input/devices | grep "PLAYSTATION(R)3 Controller ("`
PS3_USB_controllerAvailable=`lsusb | grep "PlayStation 3 Controller"`

while [ 0 ]
do
oldControllerAvailable=$controllerAvailable
controllerAvailable=`cat /proc/bus/input/devices | grep PLAYSTATION`
if [ "$controllerAvailable" != "$oldControllerAvailable" ]; then
oldPS3_BT_controllerAvailable=$PS3_BT_controllerAvailable
oldPS3_USB_controllerAvailable=$PS3_USB_controllerAvailable

#check for PS3 / USB controller

PS3_USB_controllerAvailable=`lsusb | grep "PlayStation 3 Controller"`
if [ "$PS3_USB_controllerAvailable" != "$oldPS3_USB_controllerAvailable" ]; then
echo "[begin:] PS3 / USB controller changed"

#first attempt
service xboxdrv restart
echo "sending gamepad reconfiguration request"
killall xbmc.bin -SIGUSR1

#second attempt
service xboxdrv restart
echo "sending gamepad reconfiguration request"
killall xbmc.bin -SIGUSR1

#auto start xbmc for first controller being switched on
if [ "$autostartXBMC_PS3_USB" == "enabled" ]; then
echo "auto start function"
autostarted=false
setup_running=`ps ax|grep retrorig-setup| grep -v grep`

if [ -z "$setup_running" ]; then
#retrorig-setup is not running
echo "retrorig-setup is not running"

if [ -z "$oldPS3_USB_controllerAvailable" ]; then
#first controller was switched on
echo "first controller was switched on"

xbmc_running=`ps ax|grep xbmc.bin|grep -v grep`
if [ -z "$xbmc_running" ]; then
# xbmc not running yet
echo "xbmc not running yet"

# get user name
user=`ps aux |grep "/bin/dbus-daemon --config-file"|grep -v grep|cut -f 1 -d " "`

export export DISPLAY=:0.0
echo "auto starting RetroRig for user $user"
sudo -u $user -g $user -s /usr/share/applications/startXBMC.sh &
autostarted=true

else
echo "RetroRig *not* started automatically: XBMC already running, xbmc_running="$xbmc_running
fi
else
echo "RetroRig *not* started automatically: first controller not switched on, oldPS3_USB_controllerAvailable="$oldPS3_USB_controllerAvailable
fi
else
echo "RetroRig *not* started automatically: setup_running="$setup_running
fi

#diagnostic message
sleep 2
if [ "$autostarted" == "true" ]; then
if [ -n "$(ps ax|grep xbmc.bin|grep -v grep)" ]; then
echo "RetroRig sucessfully started"
else
echo "attempt to start RetroRig failed"
fi
fi

else
echo "auto start function disabled"
fi

#Avoid starting XBMC after USB is unplugged.
#For some reasons the game controller connects via
#BT after being unplugged from USB
autostartXBMC_PS3_BT=enabled
echo "[end:] PS3 / USB controller changed"
fi

#check for PS3 / Bluetooth controller

PS3_BT_controllerAvailable=`cat /proc/bus/input/devices | grep "PLAYSTATION(R)3 Controller ("`
if [ "$PS3_BT_controllerAvailable" != "$oldPS3_BT_controllerAvailable" ]; then
echo "[begin:] PS3 / Bluetooth controller changed"

echo "sending gamepad reconfiguration request"
killall xbmc.bin -SIGUSR1

#auto start xbmc for first controller being switched on
if [ "$autostartXBMC_PS3_BT" == "enabled" ]; then
echo "auto start function"
autostarted=false
setup_running=`ps ax|grep retrorig-setup| grep -v grep`

if [ -z "$setup_running" ]; then
#retrorig-setup is not running
echo "retrorig-setup is not running"

if [ -z "$oldPS3_BT_controllerAvailable" ]; then
#first controller was switched on
echo "first controller was switched on"

xbmc_running=`ps ax|grep xbmc.bin|grep -v grep`
if [ -z "$xbmc_running" ]; then
# xbmc not running yet
echo "xbmc not running yet"

# get user name
user=`ps aux |grep "/bin/dbus-daemon --config-file"|grep -v grep|cut -f 1 -d " "`

export export DISPLAY=:0.0
echo "auto starting RetroRig for user $user"
sudo -u $user -g $user -s /usr/share/applications/startXBMC.sh &
autostarted=true
else
echo "RetroRig *not* started automatically: XBMC already running, xbmc_running="$xbmc_running
fi
else
echo "RetroRig *not* started automatically: first controller not switched on, oldPS3_BT_controllerAvailable="$oldPS3_BT_controllerAvailable
fi
else
echo "RetroRig *not* started automatically: setup_running="$setup_running
fi

#diagnostic message
sleep 2
if [ "$autostarted" == "true" ]; then
if [ -n "$(ps ax|grep xbmc.bin|grep -v grep)" ]; then
echo "RetroRig sucessfully started"
else
echo "attempt to start RetroRig failed"
fi
fi

else
echo "auto start function disabled"
fi

echo "[end:] PS3 / Bluetooth controller changed"
fi
sleep 1
done
Expand Down
6 changes: 5 additions & 1 deletion scriptmodules/emulators.shinc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function em_install_yabause()

function em_install_pcsx2()
{

#prerequisites
$cmd_install_pkg libportaudio2:i386 libjack-jackd2-0:i386

echo "Installing Playstation 2 emulator PCSX2"
$cmd_install_pkg pcsx2
# Unstable version still needs testing:
Expand Down Expand Up @@ -177,7 +181,7 @@ function em_install_gens()
$cmd_remove_pkg gens

echo "Installing Gens Sega CD/32X emulator"
$cmd_pkg_install install gens
$cmd_install_pkg gens

# deprecated: installation from libregeek.org:
#wget --tries=50 -P /tmp "http://www.libregeek.org/RetroRig/Ubuntu-Trusty/emulators/gens//Gens_2.16.7_i386.deb"
Expand Down
197 changes: 0 additions & 197 deletions scriptmodules/emulators.shinc.orig

This file was deleted.

Loading

0 comments on commit 99d0c05

Please sign in to comment.