steamcontroller: initial add-on

This commit is contained in:
Lukas Rusak 2016-11-18 00:03:22 -08:00
parent d8e056fbb1
commit dd885d0348
No known key found for this signature in database
GPG Key ID: 8C310C807E7393A3
9 changed files with 216 additions and 0 deletions

View File

@ -0,0 +1,2 @@
100
- Initial add-on

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -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 <http://www.gnu.org/licenses/>.
################################################################################
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 {} \;
}

View File

@ -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

View File

@ -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 \

View File

@ -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')

View File

@ -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()

View File

@ -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 <http://www.gnu.org/licenses/>.
################################################################################
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()

View File

@ -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