
Come da titolo vedremo oggi come configurare il controller PS3 anche compatibile comprato dai cinesi su linux. Preciso che è stato testato su Sabayon/Gentoo ma dovrebbe funzionare anche per le altre distro.
Per prima cosa apriamo il terminale e da utente root aggiungiamo il server layman “nirvana”
layman -a nirvana
Adesso scarichiamo il repository nirvana
layman -s nirvana
Fatto questo, adesso, scarichiamo il file QtSixA-1.5.1 da qui
Ora ci serve spostare il file scaricato chiamato QtSixA-1.5.1-src.tar.gz in /usr/portage/distfiles
Per prima cosa ora ci serve scaricare la patch per i controller conpatibili, ecco la patch:
From 71500fc4535846bc4294541d675ae2d0877c1e6d Mon Sep 17 00:00:00 2001From: falkTXDate: Mon, 24 Oct 2011 21:11:17 +0100Subject: [PATCH] More gasia gamepad hacks, now working—sixad/Makefile | 13 +++++++++++++sixad/bluetooth.cpp | 2 +-sixad/shared.cpp | 20 +++++++++++++++++++-sixad/sixad-sixaxis.cpp | 4 ++–sixad/sixaxis.cpp | 35 +++++++++++++++++++++++++++——–5 files changed, 62 insertions(+), 12 deletions(-)diff –git a/sixad/Makefile b/sixad/Makefileindex 0386a18..466d36e 100644— a/sixad/Makefile+++ b/sixad/Makefile@@ -4,6 +4,12 @@ CXX ?= g++CXXFLAGS ?= -O2 -WallLDFLAGS += -Wl,-Bsymbolic-functions+GASIA_GAMEPAD_HACKS = true++ifeq ($(GASIA_GAMEPAD_HACKS),true)+CXXFLAGS += -DGASIA_GAMEPAD_HACKS+endif+all: sixad_binssixad_bins:@@ -35,6 +41,13 @@ install:install -m 755 bins/sixad-3in1 $(DESTDIR)/usr/sbin/install -m 755 bins/sixad-raw $(DESTDIR)/usr/sbin/install -m 755 sixad-dbus-blocker $(DESTDIR)/usr/sbin/++ifeq “$(wildcard /usr/bin/python2 )” “”+else+ # Python2 force+ sed -i “s/env python/env python2/” $(DESTDIR)/usr/sbin/sixad-dbus-blocker+endif+@chmod 777 -R $(DESTDIR)/var/lib/sixad/@echo “Installation is Complete!”diff –git a/sixad/bluetooth.cpp b/sixad/bluetooth.cppindex 3ad6bdb..19d2077 100644— a/sixad/bluetooth.cpp+++ b/sixad/bluetooth.cpp@@ -57,7 +57,7 @@ void do_search(int ctl, bdaddr_t *bdaddr, int debug)for (i = 0; i < num_rsp; i++) {memcpy(_class, (info+i)->dev_class, 3);–+if (debug) syslog(LOG_INFO, “Got device %02X | %02X | %02X”, _class[0], _class[1], _class[2]);if (_class[1] == 0x25 && (_class[2] == 0x00 || _class[2] == 0x01)) {diff –git a/sixad/shared.cpp b/sixad/shared.cppindex d5239bf..34c8da5 100644— a/sixad/shared.cpp+++ b/sixad/shared.cpp@@ -268,14 +268,32 @@ int get_joystick_number()void enable_sixaxis(int csk){+#ifdef GASIA_GAMEPAD_HACKS+ unsigned char enable[] = {+ 0xA2,+ 0x01,+ 0x00, 0x00, 0x00, 0x00, 0x00, // rumble values [0x00, right-timeout, right-force, left-timeout, left-force]+ 0x00, 0x00, 0x00, 0x00, 0x02, // 0x02=LED1 .. 0x10=LED4+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 4+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 3+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 2+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 1+ 0x00, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00+ };+#elsechar buf[128];–unsigned char enable[] = {0x53, /* HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE */0xf4, 0x42, 0x03, 0x00, 0x00};+#endif/* enable reporting */send(csk, enable, sizeof(enable), 0);+#ifndef GASIA_GAMEPAD_HACKSrecv(csk, buf, sizeof(buf), 0);+#endif}diff –git a/sixad/sixad-sixaxis.cpp b/sixad/sixad-sixaxis.cppindex 23ee9f6..7aa0f7c 100644— a/sixad/sixad-sixaxis.cpp+++ b/sixad/sixad-sixaxis.cpp@@ -293,7 +293,7 @@ int main(int argc, char *argv[])p[1].events = POLLIN | POLLERR | POLLHUP;p[2].events = POLLIN | POLLERR | POLLHUP;p[3].events = POLLIN | POLLERR | POLLHUP;–+p[0].fd = 0;p[1].fd = 1;p[2].fd = ufd->js;@@ -353,7 +353,7 @@ int main(int argc, char *argv[])}delete ufd;–+do_rumble(csk, 10, 0xff, 0xff, 0x01);shutdown(isk, SHUT_RDWR);diff –git a/sixad/sixaxis.cpp b/sixad/sixaxis.cppindex fbe5d10..dee5fa4 100644— a/sixad/sixaxis.cpp+++ b/sixad/sixaxis.cpp@@ -380,9 +380,12 @@ void do_input(int fd, unsigned char* buf, struct dev_input input)void do_rumble(int csk, int led_n, int weak, int strong, int timeout){– unsigned char buf[128];unsigned char setrumble[] = {+#ifdef GASIA_GAMEPAD_HACKS+ 0x92,+#else0x52, /* HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT */+#endif0x01,0x00, 0x00, 0x00, 0x00, 0x00, // rumble values [0x00, right-timeout, right-force, left-timeout, left-force]0x00, 0x00, 0x00, 0x00, 0x1E, // 0x02=LED1 .. 0x10=LED4@@ -419,22 +422,34 @@ void do_rumble(int csk, int led_n, int weak, int strong, int timeout)setrumble[11] = ledpattern[led_n]; //keep old ledsend(csk, setrumble, sizeof(setrumble), 0);+#ifndef GASIA_GAMEPAD_HACKS+ unsigned char buf[128];recv(csk, buf, sizeof(buf), 0); //MSG_DONTWAIT?+#endif}int set_sixaxis_led(int csk, struct dev_led led, int rumble){– int i, led_n, led_number;+ int led_n, led_number;++#ifndef GASIA_GAMEPAD_HACKS+ int i;unsigned char buf[128];+#endif+unsigned char setleds[] = {+#ifdef GASIA_GAMEPAD_HACKS+ 0x92,+#else0x52, /* HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT */+#endif0x01,– 0x00, 0x00, 0x00, 0x00, 0x00, // rumble values [0x00, right-timeout, right-force, left-timeout, left-force]– 0x00, 0x00, 0x00, 0x00, 0x1E, // 0x02=LED1 .. 0x10=LED4– 0xff, 0x27, 0x10, 0x00, 0x32, // LED 4– 0xff, 0x27, 0x10, 0x00, 0x32, // LED 3– 0xff, 0x27, 0x10, 0x00, 0x32, // LED 2– 0xff, 0x27, 0x10, 0x00, 0x32, // LED 1+ 0x00, 0x00, 0x00, 0x00, 0x00, // rumble values [0x00, right-timeout, right-force, left-timeout, left-force]+ 0x00, 0x00, 0x00, 0x00, 0x1E, // 0x02=LED1 .. 0x10=LED4+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 4+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 3+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 2+ 0xff, 0x27, 0x10, 0x00, 0x32, // LED 10x00, 0x00, 0x00, 0x00, 0x00};const unsigned char ledpattern[11] = {@@ -460,6 +475,7 @@ int set_sixaxis_led(int csk, struct dev_led led, int rumble)} elseled_n = 0;+#ifndef GASIA_GAMEPAD_HACKSif (led.enabled && led.anim){/* Sixaxis LED animation – Way Cool!! */@@ -523,12 +539,15 @@ int set_sixaxis_led(int csk, struct dev_led led, int rumble)recv(csk, buf, sizeof(buf), 0);}}+#endif/* set LEDs (final) */setleds[11] = ledpattern[led_n];if (rumble) setleds[3] = setleds[4] = setleds[5] = setleds[6] = 0x00;send(csk, setleds, sizeof(setleds), 0);+#ifndef GASIA_GAMEPAD_HACKSrecv(csk, buf, sizeof(buf), 0);+#endifreturn led_n;}—1.7.4.1
gasia.patch
Ora copiate la patch in:
/var/lib/layman/nirvana/games-util/qtsixa/files/
Ora spostiamo nella cartella
/var/lib/layman/nirvana/games-util/qtsixa/
ed editiamo il file ebuild qtsixa-1.5.1.ebuild in questo modo, da notare, la riga di colore rosso è quella da aggiungere:
# Copyright 1999-2013 Gentoo Foundation# Distributed under the terms of the GNU General Public License v2# $Header: $EAPI=5PYTHON_COMPAT=( python2_7 )inherit eutils linux-info python-single-r1 systemd udevMY_P=”QtSixA-${PV}”DESCRIPTION=”Sixaxis Joystick Manager”HOMEPAGE=”http://qtsixa.sourceforge.net/”SRC_URI=”mirror://sourceforge/${PN}/${MY_P/-/%20}/${MY_P}-src.tar.gz”LICENSE=”GPL-2″SLOT=”0″KEYWORDS=”~amd64 ~x86″IUSE=”jack qt4″DEPEND=”net-wireless/bluezvirtual/libusb:1jack? ( media-sound/jack-audio-connection-kit )qt4? ( dev-python/PyQt4[${PYTHON_USEDEP}] )”RDEPEND=”${DEPEND}dev-python/dbus-python[${PYTHON_USEDEP}]qt4? (net-wireless/bluez-hcidumpx11-libs/libnotifyx11-misc/xdg-utils)”S=”${WORKDIR}/${MY_P}”CONFIG_CHECK=”~BT_HIDP ~INPUT_UINPUT”pkg_setup() {python-single-r1_pkg_setuplinux-info_pkg_setup}src_prepare() {epatch “${FILESDIR}”/qtsixa-1.5.1-fix-missing-includes.patchepatch “${FILESDIR}”/gasia.patchsed -i -e s/exec\ python/exec\ “${EPYTHON}”/g qtsixa/qtsixa ||die “Replace hardcoded python executable fails.”}src_compile() {use qt4 && emake -C qtsixaemake -C utils WANT_JACK=$(use jack && echo true)emake -C sixad}src_install() {use qt4 && emake -C qtsixa install DESTDIR=”${D}”emake -C utils install DESTDIR=”${D}” WANT_JACK=$(use jack && echo true)emake -C sixad install DESTDIR=”${D}”dodoc INSTALL manual.pdf README TODOif use qt4; thenpython_fix_shebang “${D}”/usr/bin/sixad-lqpython_fix_shebang “${D}”/usr/bin/sixad-notifypython_fix_shebang “${D}”/usr/share/qtsixa/guipython_optimize “${D}”/usr/share/qtsixa/guifi# Remove unused configuration file.# Since we are using hand-written startup files.# We could coexist with the bluetooth daemon if input plugin is disabled.rm -r “${D}etc/default” || die “Remove not needed configuration file fails.”# Remove unused logrotate configuration file.rm -r “${D}etc/logrotate.d” ||die “Remove not needed log configuration fails.”# Do not install upstream start script.# It does not work nicely.# We added custom startup scripts for OpenRC and systemd.rm “${D}usr/bin/sixad” || die “Could not remove upstream start script.”# Use our own init script compatible with OpenRC.newinitd “${FILESDIR}”/sixad.initd sixad# Install systemd unit file.systemd_dounit “${FILESDIR}”/sixad.service# Add an udev rule for automatically pairing.udev_dorules “${FILESDIR}”/97-sixpair.rules}pkg_postinst() {udev_reloadeinfo “Requirements:”einfo “Ensure that the uinput module is loaded.”einfo “”einfo “Solve conflicts:”einfo “Do not forget to disable the input plugin of your bluetooth daemon.”einfo “You could disable the plugin by adding the following line to the”einfo “configuration file of the bluetooth daemon (/etc/bluetooth/main.conf):”einfo “DisablePlugins = input”einfo “”einfo “Pairing:”einfo “There is an udev rule installed, that will pair PS3 remote”einfo “controllers if they are plugged in on USB.”}
ebuild qtsixa-1.5.1.ebuild digest
emerge qtsixa
#!/bin/bash# sixad-bin wrapper# written by falkTXDEBUG=0LEGACY=0. /etc/default/sixadif [ -f /usr/bin/sudo ]; thenSUDO=”/usr/bin/sudo”elseSUDO=””fibt_device_check () {if (which hciconfig > /dev/null); thenif (hciconfig dev > /dev/null); thenVER=`hciconfig default version | grep “HCI Ver” | awk ‘{print$3}’`if [ “$VER” == “1.1” ]; thenecho “***** NOTICE *****”echo “You’re using a very old bluetooth dongle,”echo “the Sixaxis will not work properly!”elif [ “$VER” == “1.0” ]; thenecho “***** WARNING *****”echo “You’re using a _really_ old bluetooth dongle,”echo “the Sixaxis will just not work!”fielseecho “No bluetooth adapters found on the system!”echo “sixad will now quit”exitfifi}sixad_running_check () {ps -e | grep sixad-bin > /dev/null}bluetoothd_running_check () {ps -e | grep bluetoothd > /dev/null}modprobe_check () {$SUDO /sbin/modprobe uinput}bt_start () {$SUDO rm -f /tmp/.sixad-dbus-blocker.pidenv sleep 1if [ -f /lib/udev/rules.d/97-bluetooth.rules ]; then$SUDO /usr/sbin/bluetoothd –udevelif [ -f /etc/rc.d/bluetooth ]; then$SUDO /etc/rc.d/bluetooth startelse$SUDO /etc/init.d/bluetooth startfi}bt_stop() {if (bluetoothd_running_check); then$SUDO restart bluetoothdfi$SUDO /usr/sbin/sixad-dbus-blocker &}case $1 in–start|-start|start|-s)REMOTE=0bt_device_checkif (sixad_running_check); thenecho “sixad is already running.”echo “run ‘$0 –stop’ to stop it”elseif (modprobe_check); then #Check for root access before running, If NO access, quitbt_stop$SUDO /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTEelseecho “You need admin/root access to run this application”fifi;;–stop|-stop|stop)$SUDO pkill -KILL sixad-sixaxis$SUDO pkill -KILL sixad-remote$SUDO pkill -TERM sixad-binbt_start;;–remote|-remote|remote)REMOTE=1bt_device_checkif (modprobe_check); then #Check for root access before running, If NO access, quitbt_stop$SUDO /usr/sbin/sixad-bin $DEBUG $LEGACY $REMOTEelseecho “You need admin/root access to run this application”fi;;–restore|-restore|restore|-r)bt_start;;–boot-yes)# ArchLinuxif [ -f /etc/arch-release ]; then$SUDO sed ‘/DAEMONS=/ s/)/ sixad)/g’ -i /etc/rc.conf# Gentooelif [ -f /etc/gentoo-release ]; then$SUDO rc-update add sixad# Debian (default)elseif [ -f /etc/rc2.d/S90sixad ]; then true; else $SUDO ln -s /etc/init.d/sixad /etc/rc2.d/S90sixad; fiif [ -f /etc/rc3.d/S90sixad ]; then true; else $SUDO ln -s /etc/init.d/sixad /etc/rc3.d/S90sixad; fiif [ -f /etc/rc4.d/S90sixad ]; then true; else $SUDO ln -s /etc/init.d/sixad /etc/rc4.d/S90sixad; fiif [ -f /etc/rc5.d/S90sixad ]; then true; else $SUDO ln -s /etc/init.d/sixad /etc/rc5.d/S90sixad; fifi;;–boot-no)# ArchLinuxif [ -f /etc/arch-release ]; then$SUDO sed “s/ sixad//” -i /etc/rc.conf# Gentooelif [ -f /etc/gentoo-release ]; then$SUDO rc-update delete sixad# Debian (default)elseif [ -f /etc/rc2.d/S90sixad ]; then $SUDO rm /etc/rc2.d/S90sixad; fiif [ -f /etc/rc3.d/S90sixad ]; then $SUDO rm /etc/rc3.d/S90sixad; fiif [ -f /etc/rc4.d/S90sixad ]; then $SUDO rm /etc/rc4.d/S90sixad; fiif [ -f /etc/rc5.d/S90sixad ]; then $SUDO rm /etc/rc5.d/S90sixad; fifi;;–help|-help|help|-h)echo “[Qt]SixA Daemon”$0;;–version|-version|version|-v)echo “[Qt]SixA Daemon – version 1.5.1”;;*)echo “usage: $0command can be:-h, –help Show help (this message)-v, –version Show sixad version-s, –start Start sixad–stop Stop sixad–remote BD Remote mode-r, –restore Restore regular bluetooth–boot-yes Auto-starts sixad at boot time–boot-no Does not auto-start sixad at boot timeYou can also check: sixad-raw, sixad-notify”;;esac
chmod a+x sixad
[Unit]Description=sixad – Sixaxis Daemon# It does not conflict, if the input plugin is disabled.#Conflicts=bluetooth.serviceAfter=bluetooth.serviceRequires=bluetooth.service[Service]ExecStart=/usr/sbin/sixad-bin 0 0 0Restart=on-failure[Install]WantedBy=bluetooth.target#WantedBy=multi-user.target
systemctl enable sixad.servicesystemctl start sixad.service