diff --git a/packages/addons/addon-depends/enum34/package.mk b/packages/addons/addon-depends/enum34/package.mk new file mode 100644 index 0000000000..7337a61e6d --- /dev/null +++ b/packages/addons/addon-depends/enum34/package.mk @@ -0,0 +1,42 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +PKG_NAME="enum34" +PKG_VERSION="1.1.6" +PKG_REV="1" +PKG_ARCH="any" +PKG_LICENSE="BSD" +PKG_SITE="https://bitbucket.org/stoneleaf/enum34" +PKG_URL="https://bitbucket.org/stoneleaf/$PKG_NAME/get/$PKG_VERSION.tar.bz2" +PKG_SOURCE_DIR="stoneleaf-enum34-*" +PKG_DEPENDS_TARGET="toolchain Python distutilscross:host" +PKG_PRIORITY="optional" +PKG_SECTION="python" +PKG_SHORTDESC="Python 3.4 Enum backported to 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4" +PKG_LONGDESC="Python 3.4 Enum backported to 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4" + +PKG_IS_ADDON="no" +PKG_AUTORECONF="no" + +make_target() { + python setup.py build +} + +makeinstall_target() { + : +} diff --git a/packages/addons/addon-depends/python-libusb1/package.mk b/packages/addons/addon-depends/python-libusb1/package.mk new file mode 100644 index 0000000000..7538c898c0 --- /dev/null +++ b/packages/addons/addon-depends/python-libusb1/package.mk @@ -0,0 +1,41 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +PKG_NAME="python-libusb1" +PKG_VERSION="1.5.3" +PKG_REV="1" +PKG_ARCH="any" +PKG_LICENSE="LGPL" +PKG_SITE="https://github.com/vpelletier/python-libusb1" +PKG_URL="https://github.com/vpelletier/$PKG_NAME/archive/$PKG_VERSION.tar.gz" +PKG_DEPENDS_TARGET="toolchain Python distutilscross:host" +PKG_PRIORITY="optional" +PKG_SECTION="python" +PKG_SHORTDESC="Pure-python wrapper for libusb-1.0" +PKG_LONGDESC="Pure-python wrapper for libusb-1.0" + +PKG_IS_ADDON="no" +PKG_AUTORECONF="no" + +make_target() { + python setup.py build +} + +makeinstall_target() { + : +} diff --git a/packages/addons/driver/steamcontroller/changelog.txt b/packages/addons/driver/steamcontroller/changelog.txt new file mode 100644 index 0000000000..32d81ca428 --- /dev/null +++ b/packages/addons/driver/steamcontroller/changelog.txt @@ -0,0 +1,2 @@ +100 +- Initial add-on diff --git a/packages/addons/driver/steamcontroller/icon/icon.png b/packages/addons/driver/steamcontroller/icon/icon.png new file mode 100644 index 0000000000..e75bb57a61 Binary files /dev/null and b/packages/addons/driver/steamcontroller/icon/icon.png differ diff --git a/packages/addons/driver/steamcontroller/package.mk b/packages/addons/driver/steamcontroller/package.mk new file mode 100644 index 0000000000..7bf8e99300 --- /dev/null +++ b/packages/addons/driver/steamcontroller/package.mk @@ -0,0 +1,66 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +PKG_NAME="steamcontroller" +PKG_VERSION="02f27c4" +PKG_REV="100" +PKG_ARCH="any" +PKG_LICENSE="MIT" +PKG_SITE="https://github.com/ynsta/steamcontroller" +PKG_URL="https://github.com/ynsta/steamcontroller/archive/$PKG_VERSION.tar.gz" +PKG_DEPENDS_TARGET="toolchain Python distutilscross:host python-libusb1 enum34 linux" +PKG_SECTION="driver" +PKG_SHORTDESC="A standalone userland driver for the steam controller to be used where steam client can't be installed." +PKG_LONGDESC="A standalone userland driver for the steam controller to be used where steam client can't be installed." +PKG_AUTORECONF="no" + +PKG_IS_ADDON="yes" +PKG_ADDON_NAME="Steam Controller Driver" +PKG_ADDON_TYPE="xbmc.service" + +pre_make_target() { + export PYTHONXCPREFIX="$SYSROOT_PREFIX/usr" + export LDSHARED="$CC -shared" +} + +make_target() { + python setup.py build +} + +makeinstall_target() { + : +} + +addon() { + mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/bin + cp -a $PKG_BUILD/build/scripts-2.7/* $ADDON_BUILD/$PKG_ADDON_ID/bin/ + + mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/lib + cp -a $PKG_BUILD/build/lib.linux-*-2.7/* $ADDON_BUILD/$PKG_ADDON_ID/lib/ + cp -a $(get_build_dir python-libusb1)/build/lib/* $ADDON_BUILD/$PKG_ADDON_ID/lib/ + cp -a $(get_build_dir enum34)/build/lib/* $ADDON_BUILD/$PKG_ADDON_ID/lib/ + + mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/include/linux + if [ -f "$(get_build_dir linux)/usr/include/linux/input-event-codes.h" ]; then + cp $(get_build_dir linux)/usr/include/linux/input-event-codes.h $ADDON_BUILD/$PKG_ADDON_ID/include/linux/ + fi + cp $(get_build_dir linux)/usr/include/linux/input.h $ADDON_BUILD/$PKG_ADDON_ID/include/linux/ + + python -Wi -t -B $ROOT/$TOOLCHAIN/lib/python2.7/compileall.py $ADDON_BUILD/$PKG_ADDON_ID/lib/ -f + find $ADDON_BUILD/$PKG_ADDON_ID/lib/ -name '*.py' -exec rm {} \; +} diff --git a/packages/addons/driver/steamcontroller/patches/steamcontroller-0001-fix-include-dir.patch b/packages/addons/driver/steamcontroller/patches/steamcontroller-0001-fix-include-dir.patch new file mode 100644 index 0000000000..66579e1ffb --- /dev/null +++ b/packages/addons/driver/steamcontroller/patches/steamcontroller-0001-fix-include-dir.patch @@ -0,0 +1,17 @@ +diff -Naur a/src/uinput.py b/src/uinput.py +--- a/src/uinput.py 2016-01-02 23:13:18.000000000 +0100 ++++ b/src/uinput.py 2016-01-03 08:44:34.003676619 +0100 +@@ -34,10 +34,10 @@ + from collections import deque + + # Get All defines from linux headers +-if os.path.exists('/usr/include/linux/input-event-codes.h'): +- CHEAD = defines('/usr/include', 'linux/input-event-codes.h') ++if os.path.exists('/storage/.kodi/addons/driver.steamcontroller/include/linux/input-event-codes.h'): ++ CHEAD = defines('/storage/.kodi/addons/driver.steamcontroller/include', 'linux/input-event-codes.h') + else: +- CHEAD = defines('/usr/include', 'linux/input.h') ++ CHEAD = defines('/storage/.kodi/addons/driver.steamcontroller/include', 'linux/input.h') + + # Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*) + Keys = IntEnum('Keys', {i: CHEAD[i] for i in CHEAD.keys() if (i.startswith('KEY_') or diff --git a/packages/addons/driver/steamcontroller/patches/steamcontroller-0002-append-python-path.patch b/packages/addons/driver/steamcontroller/patches/steamcontroller-0002-append-python-path.patch new file mode 100644 index 0000000000..1a6790e4d2 --- /dev/null +++ b/packages/addons/driver/steamcontroller/patches/steamcontroller-0002-append-python-path.patch @@ -0,0 +1,28 @@ +diff -Naur a/scripts/sc-desktop.py b/scripts/sc-desktop.py +--- a/scripts/sc-desktop.py 2016-01-02 23:13:18.000000000 +0100 ++++ b/scripts/sc-desktop.py 2016-01-04 22:00:18.536497613 +0100 +@@ -22,6 +22,10 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + # THE SOFTWARE. + ++import sys ++ ++sys.path.append('/storage/.kodi/addons/driver.steamcontroller/lib') ++ + """Steam Controller Mouse, Keyboard mode""" + + from steamcontroller import SteamController, SCButtons +diff -Naur a/scripts/sc-xbox.py b/scripts/sc-xbox.py +--- a/scripts/sc-xbox.py 2016-01-02 23:13:18.000000000 +0100 ++++ b/scripts/sc-xbox.py 2016-01-04 22:00:30.751519105 +0100 +@@ -22,6 +22,10 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + # THE SOFTWARE. + ++import sys ++ ++sys.path.append('/storage/.kodi/addons/driver.steamcontroller/lib') ++ + """Steam Controller XBOX360 Gamepad Emulator""" + + from steamcontroller import \ diff --git a/packages/addons/driver/steamcontroller/patches/steamcontroller-0003-wait-for-controller-connection.patch b/packages/addons/driver/steamcontroller/patches/steamcontroller-0003-wait-for-controller-connection.patch new file mode 100644 index 0000000000..b0f3bf01ad --- /dev/null +++ b/packages/addons/driver/steamcontroller/patches/steamcontroller-0003-wait-for-controller-connection.patch @@ -0,0 +1,31 @@ +diff -Naur a/src/__init__.py b/src/__init__.py +--- a/src/__init__.py 2016-09-14 13:00:35.000000000 -0700 ++++ b/src/__init__.py 2016-11-17 23:40:57.137095353 -0800 +@@ -116,18 +116,16 @@ + self._cmsg = [] + self._ctx = usb1.USBContext() + ++ while self._handle is None: ++ for i in range(len(PRODUCT_ID)): ++ pid = PRODUCT_ID[i] ++ endpoint = ENDPOINT[i] ++ ccidx = CONTROLIDX[i] + +- for i in range(len(PRODUCT_ID)): +- pid = PRODUCT_ID[i] +- endpoint = ENDPOINT[i] +- ccidx = CONTROLIDX[i] +- +- self._handle = self._ctx.openByVendorIDAndProductID( +- VENDOR_ID, pid, +- skip_on_error=True, +- ) +- if self._handle is not None: +- break ++ self._handle = self._ctx.openByVendorIDAndProductID( ++ VENDOR_ID, pid, ++ skip_on_error=True, ++ ) + + if self._handle is None: + raise ValueError('SteamControler Device not found') diff --git a/packages/addons/driver/steamcontroller/patches/steamcontroller-0004-use-run-for-pid-directory.patch b/packages/addons/driver/steamcontroller/patches/steamcontroller-0004-use-run-for-pid-directory.patch new file mode 100644 index 0000000000..ca60886135 --- /dev/null +++ b/packages/addons/driver/steamcontroller/patches/steamcontroller-0004-use-run-for-pid-directory.patch @@ -0,0 +1,24 @@ +diff -Naur a/scripts/sc-desktop.py b/scripts/sc-desktop.py +--- a/scripts/sc-desktop.py 2016-11-18 13:31:29.522462062 -0800 ++++ b/scripts/sc-desktop.py 2016-11-18 13:33:09.268432661 -0800 +@@ -80,7 +80,7 @@ + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug']) + args = parser.parse_args() +- daemon = SCDaemon('/tmp/steamcontroller.pid') ++ daemon = SCDaemon('/run/steamcontroller.pid') + + if 'start' == args.command: + daemon.start() +diff -Naur a/scripts/sc-xbox.py b/scripts/sc-xbox.py +--- a/scripts/sc-xbox.py 2016-11-18 13:31:29.522462062 -0800 ++++ b/scripts/sc-xbox.py 2016-11-18 13:33:09.266432642 -0800 +@@ -79,7 +79,7 @@ + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug']) + args = parser.parse_args() +- daemon = SCDaemon('/tmp/steamcontroller.pid') ++ daemon = SCDaemon('/run/steamcontroller.pid') + + if 'start' == args.command: + daemon.start() diff --git a/packages/addons/driver/steamcontroller/source/default.py b/packages/addons/driver/steamcontroller/source/default.py new file mode 100644 index 0000000000..6c6b84a8a5 --- /dev/null +++ b/packages/addons/driver/steamcontroller/source/default.py @@ -0,0 +1,35 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +import subprocess +import xbmc +import xbmcaddon + + +class Monitor(xbmc.Monitor): + + def __init__(self, *args, **kwargs): + xbmc.Monitor.__init__(self) + self.id = xbmcaddon.Addon().getAddonInfo('id') + + def onSettingsChanged(self): + subprocess.call(['systemctl', 'restart', self.id]) + + +if __name__ == '__main__': + Monitor().waitForAbort() diff --git a/packages/addons/driver/steamcontroller/source/system.d/driver.steamcontroller.service b/packages/addons/driver/steamcontroller/source/system.d/driver.steamcontroller.service new file mode 100644 index 0000000000..4a5be360ae --- /dev/null +++ b/packages/addons/driver/steamcontroller/source/system.d/driver.steamcontroller.service @@ -0,0 +1,13 @@ +[Unit] +Description=a standalone userland driver for the steam controller + +[Service] +Type=forking +ExecStart=/usr/bin/python /storage/.kodi/addons/driver.steamcontroller/bin/sc-xbox.py start +ExecStop=/usr/bin/python /storage/.kodi/addons/driver.steamcontroller/bin/sc-xbox.py stop +PIDFile=/run/steamcontroller.pid +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target