Skip to content

Commit

Permalink
Rework sixad file; Finish manual
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Jun 30, 2011
1 parent 7aae2b9 commit f8985ab
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 159 deletions.
Binary file modified manual.odt
Binary file not shown.
5 changes: 2 additions & 3 deletions sixad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ install:
install -d $(DESTDIR)/etc/logrotate.d/
install -d $(DESTDIR)/usr/bin/
install -d $(DESTDIR)/usr/sbin/
install -d $(DESTDIR)/lib/udev/rules.d/
install -d $(DESTDIR)/var/lib/sixad/
install -d $(DESTDIR)/var/lib/sixad/profiles/
install -m 644 sixad.default $(DESTDIR)/etc/default/sixad
install -m 755 sixad.init $(DESTDIR)/etc/init.d/sixad
install -m 644 sixad.log $(DESTDIR)/etc/logrotate.d/sixad
Expand All @@ -32,7 +32,6 @@ install:
install -m 755 bins/sixad-sixaxis $(DESTDIR)/usr/sbin/
install -m 755 bins/sixad-remote $(DESTDIR)/usr/sbin/
install -m 755 bins/sixad-raw $(DESTDIR)/usr/sbin/
install -m 644 98-sixad.rules $(DESTDIR)/lib/udev/rules.d/
@echo "Please run '[sudo] make install-system' now if you're installing from source"

install-system:
Expand All @@ -52,5 +51,5 @@ uninstall:
rm -f $(DESTDIR)/usr/sbin/sixad-sixaxis
rm -f $(DESTDIR)/usr/sbin/sixad-remote
rm -f $(DESTDIR)/usr/sbin/sixad-raw
rm -f $(DESTDIR)/lib/udev/rules.d/98-sixad.rules
rm -rf $(DESTDIR)/var/lib/sixad/
@if [ -f /usr/sbin/bluetoothd.bak ]; then mv /usr/sbin/bluetoothd.bak /usr/sbin/bluetoothd; fi
249 changes: 96 additions & 153 deletions sixad/sixad
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,32 @@ REMOTE=0
. /etc/default/sixad


start_by_udev_q () {
ADDR=`hcitool con | head -n 2 | tail -n 1 | awk '{printf$3}'`
hcitool name $ADDR | grep -e 'PLAYSTATION(R)3 Controller' -e 'Wireless Keypad'
}

using_old_bt_ver () {
VER=`hciconfig default version | grep "HCI Ver" | awk '{print$3}'`
if [ "$VER" == "1.1" ]; then
echo "***** NOTICE *****
You're using a very old bluetooth dongle,
the Sixaxis will not work properly!
"
fi
if [ "$VER" == "1.0" ]; then
echo "***** WARNING *****
You're using a _really_ old bluetooth dongle,
the Sixaxis will just not work!
"
fi
}

bt_device_check () {
if (which hciconfig > /dev/null); then
{ #1
if (hciconfig dev > /dev/null); then true; else
echo "No bluetooth adapters found on the system!
sixad will now quit"
exit
fi
} #2
else
# no hciconfig means no bluez installed, hurray!
false
if (hciconfig dev > /dev/null); then
VER=`hciconfig default version | grep "HCI Ver" | awk '{print$3}'`
if [ "$VER" == "1.1" ]; then
echo "***** NOTICE *****"
echo "You're using a very old bluetooth dongle,"
echo "the Sixaxis will not work properly!"
elif [ "$VER" == "1.0" ]; then
echo "***** WARNING *****"
echo "You're using a _really_ old bluetooth dongle,"
echo "the Sixaxis will just not work!"
fi
else
echo "No bluetooth adapters found on the system!"
echo "sixad will now quit"
exit
fi
fi
}

boot_yes_check () {
if [ -f /etc/arch-release ]; then
cat /etc/rc.conf | grep sixad > /dev/null
elif [ -f /etc/gentoo-release ]; then
rc-status | grep started | grep -q sixad > /dev/null
else
ls /etc/rc2.d/S90sixad > /dev/null
fi
}

sixad_already_running_check () {
sixad_running_check () {
ps -e | grep sixad-bin > /dev/null
}

bluetoothd_check () {
bluetoothd_running_check () {
ps -e | grep bluetoothd > /dev/null
}

Expand All @@ -69,158 +44,126 @@ sudo /sbin/modprobe uinput
}

bt_start () {
# sudo pkill -KILL hcid
if [ -f /usr/sbin/bluetoothd.bak ]; then sudo mv /usr/sbin/bluetoothd.bak /usr/sbin/bluetoothd; fi
if [ -f /lib/udev/rules.d/97-bluetooth.rules ]; then sudo /usr/sbin/bluetoothd --udev; else sudo /etc/init.d/bluetooth start; fi
}

case $1 in
bt_stop() {
if (bluetoothd_running_check); then sudo pkill -KILL bluetoothd; fi
if [ -f /usr/sbin/bluetoothd ]; then sudo mv /usr/sbin/bluetoothd /usr/sbin/bluetoothd.bak; fi
# sudo /usr/sbin/hcid
}

--boot-no)
boot_yes_check () {
if [ -f /etc/arch-release ]; then
{ #1 - ArchLinux Fix
sudo sed "s/ sixad//" -i /etc/rc.conf
} #1
cat /etc/rc.conf | grep sixad > /dev/null
elif [ -f /etc/gentoo-release ]; then
{ #2 - Gentoo fix
sudo rc-update delete sixad
} #2
rc-status | grep started | grep -q sixad > /dev/null
else
{ #3
if [ -f /etc/rc2.d/S90sixad ]; then sudo rm /etc/rc2.d/S90sixad; fi
if [ -f /etc/rc3.d/S90sixad ]; then sudo rm /etc/rc3.d/S90sixad; fi
if [ -f /etc/rc4.d/S90sixad ]; then sudo rm /etc/rc4.d/S90sixad; fi
if [ -f /etc/rc5.d/S90sixad ]; then sudo rm /etc/rc5.d/S90sixad; fi
} #3
ls /etc/rc2.d/S90sixad > /dev/null
fi
;;
}

--boot-yes)
if [ -f /etc/arch-release ]; then
{ #1 - ArchLinux Fix
sudo sed '/DAEMONS=/ s/)/ sixad)/g' -i /etc/rc.conf
} #1
elif [ -f /etc/gentoo-release ]; then
{ #2 - Gentoo fix
sudo rc-update add sixad
} #2
else
{ #3
if [ -f /etc/rc2.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc2.d/S90sixad; fi
if [ -f /etc/rc3.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc3.d/S90sixad; fi
if [ -f /etc/rc4.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc4.d/S90sixad; fi
if [ -f /etc/rc5.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc5.d/S90sixad; fi
} #3
fi
;;

--force|-force|force|-f) #Used for QtSixA GUI
bt_device_check && using_old_bt_ver
echo "sixad has been forced to start.
bluetooth will not be operational in this mode"
if (bluetoothd_check "$1"); then sudo pkill -KILL bluetoothd; fi
sudo /usr/sbin/hcid
if (sixad_already_running_check "$1"); then true
case $1 in

--start|-start|start|-s)
REMOTE=0
bt_device_check
if (sixad_running_check); then
echo "sixad is already running."
echo "run '$0 --stop' to stop it"
else
/sbin/modprobe uinput
/usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE
if (modprobe_check); then #Check for root access before running, If NO access, quit
bt_stop
sudo /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE
else
echo "You need admin/root access to run this application"
fi
fi
;;

--stop|-stop|stop)
sudo pkill -KILL sixad-sixaxis
sudo pkill -KILL sixad-remote
sudo pkill -TERM sixad-bin
sudo pkill -KILL hcid
if (bluetoothd_check "$1"); then true; else bt_start; fi
bt_start
;;

--udev) #Used for udev
# Only start udev action if a Sixaxis or Keypad is detected
if (start_by_udev_q "$1"); then

{ #Full _start
if (bluetoothd_check "$1"); then pkill -KILL bluetoothd; fi
/usr/sbin/hcid
if (sixad_already_running_check "$1"); then true
--remote|-remote|remote)
REMOTE=1
bt_device_check
if (modprobe_check); then #Check for root access before running, If NO access, quit
bt_stop
sudo /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE
else
DEBUG=1
/sbin/modprobe uinput
date >> /var/log/sixad.log
/usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE &>> /var/log/sixad.log &
fi
if (boot_yes_check "$1"); then true; else
sleep 10 # wait for device to connect
pkill -KILL hcid
echo "You need admin/root access to run this application"
fi
;;

--restore|-restore|restore|-r)
bt_start
} #Full _end
;;

--boot-yes)
# ArchLinux
if [ -f /etc/arch-release ]; then
sudo sed '/DAEMONS=/ s/)/ sixad)/g' -i /etc/rc.conf
# Gentoo
elif [ -f /etc/gentoo-release ]; then
sudo rc-update add sixad
# Debian (default)
else
if [ -f /etc/rc2.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc2.d/S90sixad; fi
if [ -f /etc/rc3.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc3.d/S90sixad; fi
if [ -f /etc/rc4.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc4.d/S90sixad; fi
if [ -f /etc/rc5.d/S90sixad ]; then true; else sudo ln -s /etc/init.d/sixad /etc/rc5.d/S90sixad; fi
fi
;;

--start|-start|start|-s)
bt_device_check && using_old_bt_ver
if (sixad_already_running_check "$1"); then
echo "sixad is already running.
run 'sixad --stop' to stop it"
--boot-no)
# ArchLinux
if [ -f /etc/arch-release ]; then
sudo sed "s/ sixad//" -i /etc/rc.conf
# Gentoo
elif [ -f /etc/gentoo-release ]; then
sudo rc-update delete sixad
# Debian (default)
else
{ #2
if (modprobe_check "$1"); then #Check for root access before running, If NO access, quit
{ #3
if (bluetoothd_check "$1"); then sudo pkill -KILL bluetoothd; fi
sudo /usr/sbin/hcid
sudo /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE
} #3
else
echo "You need admin/root access to run this application"
fi
} #2
if [ -f /etc/rc2.d/S90sixad ]; then sudo rm /etc/rc2.d/S90sixad; fi
if [ -f /etc/rc3.d/S90sixad ]; then sudo rm /etc/rc3.d/S90sixad; fi
if [ -f /etc/rc4.d/S90sixad ]; then sudo rm /etc/rc4.d/S90sixad; fi
if [ -f /etc/rc5.d/S90sixad ]; then sudo rm /etc/rc5.d/S90sixad; fi
fi
;;

--remote)
REMOTE=1
bt_device_check && using_old_bt_ver
{ #2
if (modprobe_check "$1"); then #Check for root access before running, If NO access, quit
{ #3
if (bluetoothd_check "$1"); then sudo pkill -KILL bluetoothd; fi
sudo /usr/sbin/hcid
sudo /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTE
} #3
else
echo "You need admin/root access to run this application"
fi
} #2
--help|-help|help|-h)
echo "[Qt]SixA Daemon"
$0
;;

--version|-version|version|-v)
--version|-version|version|-v)
echo "[Qt]SixA Daemon - version 1.5.0"
;;

--help|-help|help|-h)
echo "[Qt]SixA Daemon
"
$0
;;

*)
echo "usage: sixad <command>
*)
echo "usage: $0 <command>
command can be:
-h, --help Show help (this message)
-v, --version Show sixad version
-h, --help Show help (this message)
-v, --version Show sixad version
-s, --start Start sixad
-f, --force Force connection (and starts sixad if not running)
--stop Stop sixad
-s, --start Start sixad
--stop Stop sixad
--remote BD Remote mode
--remote BD Remote mode
--boot-yes Auto-starts sixad at boot time
--boot-no Does not auto-start sixad at boot time
-r, --restore Restore regular bluetooth
--boot-yes Auto-starts sixad at boot time
--boot-no Does not auto-start sixad at boot time
You can also check: sixad-raw, sixad-notify"
;;


esac
6 changes: 3 additions & 3 deletions utils/sixad-jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ int main(int argc, char **argv)
}

black_keys = 0;
if (argc == 3)
if (argv[1][0] == '-')
if (argv[1][1] == 'b') {
if (argc == 3) {
if (argv[1][0] == '-' && argv[1][1] == 'b') {
black_keys = 1;
if (debug) printf("Using black keys\n");
}
}

if (black_keys)
fd = open(argv[2], O_RDONLY);
Expand Down

0 comments on commit f8985ab

Please sign in to comment.