Merge pull request #897 from vpeter4/touchscreen-addon

touchscreen: initial addon
This commit is contained in:
Christian Hewitt 2016-11-02 16:06:47 +04:00 committed by GitHub
commit f1a0c4161e
30 changed files with 6593 additions and 0 deletions

View File

@ -0,0 +1,61 @@
################################################################################
# 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="tslib"
PKG_VERSION="1.1"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="https://github.com/kergoth/tslib"
PKG_URL="https://github.com/kergoth/tslib/releases/download/1.1/$PKG_NAME-$PKG_VERSION.tar.xz"
PKG_DEPENDS_TARGET="toolchain evtest"
PKG_SECTION="service/system"
PKG_SHORTDESC="Touchscreen access library with ts_uinput_touch daemon."
PKG_LONGDESC="Touchscreen access library with ts_uinput_touch daemon."
PKG_AUTORECONF="no"
PKG_IS_ADDON="no"
TSLIB_MODULES_ENABLED="linear dejitter variance pthres ucb1x00 tatung input galax dmc touchkit st1232 waveshare"
TSLIB_MODULES_DISABLED="arctic2 corgi collie h3600 linear_h2200 mk712 cy8mrln_palmpre"
TSLIB_BUILD_STATIC="yes" # no .so files (easy to manage)
pre_configure_target() {
local OPTS_MODULES=""
if [ "$TSLIB_BUILD_STATIC" = "yes" ]; then
OPTS_MODULES="--enable-static --disable-shared"
for module in $TSLIB_MODULES_ENABLED; do
OPTS_MODULES="$OPTS_MODULES --enable-$module=static"
done
fi
for module in $TSLIB_MODULES_DISABLED; do
OPTS_MODULES="$OPTS_MODULES --disable-$module"
done
PKG_CONFIGURE_OPTS_TARGET="$OPTS_MODULES \
--sysconfdir=/storage/.kodi/userdata/addon_data/service.touchscreen"
}
post_makeinstall_target() {
rm -fr $INSTALL/etc
rm -fr $INSTALL/storage
debug_strip $INSTALL/usr/bin
}

View File

@ -0,0 +1,25 @@
From f60540a1e0c120dfb6a7452470b3e56bee91c7d7 Mon Sep 17 00:00:00 2001
From: Dirk Gerdes <dirk.gerdes@googlemail.com>
Date: Mon, 22 Dec 2014 11:07:13 +0100
Subject: [PATCH] Added support for additional model of eGalax Touchscreen
---
plugins/galax-raw.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/plugins/galax-raw.c b/plugins/galax-raw.c
index c8689e2..6cacc56 100644
--- a/plugins/galax-raw.c
+++ b/plugins/galax-raw.c
@@ -93,8 +93,9 @@ static int ts_galax_check_fd (struct tslib_galax *i)
if ((ioctl(ts->fd, EVIOCGID, &infos) < 0)) {
fprintf (stderr, "tslib: warning, can not read device identifier\n");
- } else if (infos.bustype != 3 || infos.vendor != 0x0EEF || infos.product != 0x0001) {
- fprintf (stderr, "tslib: this is not an eGalax touchscreen (3,0x0EEF,1,0x0112)\n"
+ } else if (infos.bustype != 3 || infos.vendor != 0x0EEF
+ || (infos.product != 0x0001 && infos.product != 0x7200 && infos.product != 0x7201 && infos.product != 0xC000)) {
+ fprintf (stderr, "tslib: this is not an eGalax touchscreen (3,0x0EEF,1/7200/7201/C000,0x0112)\n"
"Your device: bus=%d, vendor=0x%X, product=0x%X, version=0x%X\n",infos.bustype, infos.vendor, infos.product, infos.version);
return -1;
}

View File

@ -0,0 +1,17 @@
diff -aurN a/plugins/linear.c b/plugins/linear.c
--- a/plugins/linear.c 2013-08-08 02:23:04.000000000 +0200
+++ b/plugins/linear.c 2015-09-04 20:21:50.376205701 +0200
@@ -187,11 +187,11 @@
for (index = 0; index < 7; index++)
if (fscanf(pcal_fd, "%d", &lin->a[index]) != 1) break;
fscanf(pcal_fd, "%d %d", &lin->cal_res_x, &lin->cal_res_y);
-#ifdef DEBUG
+/*#ifdef DEBUG*/
printf("Linear calibration constants: ");
for(index=0;index<7;index++) printf("%d ",lin->a[index]);
printf("\n");
-#endif /*DEBUG*/
+/*#endif*/ /*DEBUG*/
fclose(pcal_fd);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="@PKG_ADDON_ID@"
name="@ADDON_NAME@"
version="@ADDON_VERSION@"
provider-name="@PROVIDER_NAME@">
<requires>
<import addon="os.libreelec.tv" version="@OS_VERSION@"/>
<import addon="xbmc.python" version="2.1.0"/>
@REQUIRES@
</requires>
<extension point="xbmc.service" library="service.py">
<provides></provides>
</extension>
<extension point="xbmc.python.pluginsource" library="calibrate.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary>@PKG_SHORTDESC@</summary>
<description>
@PKG_LONGDESC@
</description>
<disclaimer>
@PKG_DISCLAIMER@
</disclaimer>
<platform>all</platform>
<news>
@PKG_ADDON_NEWS@
</news>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.png</fanart>
@PKG_ADDON_SCREENSHOT@
</assets>
</extension>
</addon>

View File

@ -0,0 +1,2 @@
+100
- Initial release

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,57 @@
################################################################################
# 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="touchscreen"
PKG_VERSION="1.0"
PKG_REV="100"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE=""
PKG_URL=""
PKG_DEPENDS_TARGET="toolchain tslib evtest"
PKG_SECTION="service"
PKG_SHORTDESC="Touchscreen: support addon for Touchscreens"
PKG_LONGDESC="Touchscreen: addon creates new virtual input device and \
converts data from touchscreen to Kodi. Short tap sends button press event \
and long tap sends only xy coordinates. Also includes calibration program."
PKG_AUTORECONF="no"
PKG_IS_ADDON="yes"
PKG_ADDON_NAME="Touchscreen"
PKG_ADDON_TYPE="xbmc.service"
make_target() {
: # only pack everything
}
makeinstall_target() {
: # only pack everything
}
addon() {
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/bin
cp $PKG_DIR/addon.xml $ADDON_BUILD/$PKG_ADDON_ID
# set version (no need to edit xml file on version bump)
$SED -e "s|@ADDON_VERSION@|$ADDON_VERSION.$PKG_REV|g" \
-i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
cp $(get_build_dir tslib)/.install_pkg/usr/bin/* $ADDON_BUILD/$PKG_ADDON_ID/bin
cp $(get_build_dir evtest)/.$TARGET_NAME/evtest $ADDON_BUILD/$PKG_ADDON_ID/bin
}

View File

@ -0,0 +1,71 @@
#!/bin/sh
################################################################################
# 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/>.
################################################################################
. /etc/profile
oe_setup_addon service.touchscreen
if [ -d /usr/share/kodi/addons/service.touchscreen ]; then
# addon included in image
ADDON_DIR="/usr/share/kodi/addons/service.touchscreen"
fi
. $ADDON_DIR/bin/ts_env.sh
echo "touchscreen device: $TSLIB_TSDEVICE"
if [ "$1" = "service" ]; then
# recalibrate from service if required
SETTINGS_XML="$ADDON_HOME/settings.xml"
if [ -f "$SETTINGS_XML" ]; then
mkdir -p /var/config
cat "$SETTINGS_XML" | awk -F\" '{print $2"=\""$4"\""}' | sed '/^=/d' > /var/config/ts_calibration_addon.conf
. /var/config/ts_calibration_addon.conf
if [ "$TS_RECALIBRATE" = "true" ]; then
sed -i 's|id="TS_RECALIBRATE"[ ]*value="true"|id="TS_RECALIBRATE" value="false"|g' "$SETTINGS_XML"
touch $ADDON_HOME/recalibrate
fi
fi
if [ -f $ADDON_HOME/recalibrate ]; then
echo "recalibrating..."
rm -f $ADDON_HOME/recalibrate
ts_calibrate
fi
else
echo "Stopping Kodi and touchscreen daemon..."
systemctl stop kodi
systemctl stop ts_uinput_touch
while pidof kodi.bin &>/dev/null; do
sleep 0.5
done
killall ts_uinput_touch &>/dev/null
ts_calibrate
# restart both if argument was set
if [ "$1" = "run" ]; then
echo "Starting touchscreen daemon and Kodi..."
systemctl start ts_uinput_touch
systemctl start kodi
fi
fi

View File

@ -0,0 +1,99 @@
#!/bin/sh
################################################################################
# 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/>.
################################################################################
. /etc/profile
oe_setup_addon service.touchscreen
if [ -d /usr/share/kodi/addons/service.touchscreen ]; then
# addon included in image
ADDON_DIR=/usr/share/kodi/addons/service.touchscreen
fi
if [ ! -f $ADDON_HOME/ts.conf-generic ]; then
cp $ADDON_DIR/config/* $ADDON_HOME
fi
if [ -f $ADDON_HOME/ts_env.sh ]; then
# use user supplied script
if [ ! -x $ADDON_HOME/ts_env.sh ]; then
chmod +x $ADDON_HOME/ts_env.sh
fi
dos2unix $ADDON_HOME/ts_env.sh
dos2unix $ADDON_HOME/ts.conf
. $ADDON_HOME/ts_env.sh
else
# automatic start only on Udoo dual/quad for ldb screen
LDB=""
if grep -iq ":dev=ldb" /proc/cmdline; then
LDB="yes"
# maybe 7" LVDS display
modprobe st1232 >/dev/null 2>&1
fi
if [ -n "$LDB" ]; then
# find event# with command
# ls -l /dev/input/by-id
# or using evtest program
# st1232 module is always loaded so check for 3M first
TS_DEVICE_1="3M 3M USB Touchscreen - EX II"
TS_DEVICE_2="st1232-touchscreen"
TS_DEVICE_CONF_1="ts.conf-udoo_15_6"
TS_DEVICE_CONF_2="ts.conf-udoo_7"
TS_DEVICE_CONF_GENERIC="ts.conf-generic"
#TS_DEVICE="$TS_DEVICE_1" # use specified one, should exist ts.conf for it
TS_DEVICE="" # find one automatically
#echo "device: $TS_DEVICE"
TS_DEVICE_CONF=""
if [ -n "$TS_DEVICE" ]; then
TSLIB_TSDEVICE=$(echo 999 | evtest 2>&1 >/dev/null | awk -F':' -v TS_DEVICE="$TS_DEVICE" '$0 ~ TS_DEVICE {print $1}')
TS_DEVICE_CONF="$TS_DEVICE_CONF_GENERIC"
else
TSLIB_TSDEVICE=$(echo 999 | evtest 2>&1 >/dev/null | awk -F':' -v TS_DEVICE="$TS_DEVICE_1" '$0 ~ TS_DEVICE {print $1}')
if [ -n "$TSLIB_TSDEVICE" ]; then
TS_DEVICE_CONF="$TS_DEVICE_CONF_1"
rmmod st1232 >/dev/null 2>&1 # it's not
else
TSLIB_TSDEVICE=$(echo 999 | evtest 2>&1 >/dev/null | awk -F':' -v TS_DEVICE="$TS_DEVICE_2" '$0 ~ TS_DEVICE {print $1}')
if [ -n "$TSLIB_TSDEVICE" ]; then
TS_DEVICE_CONF="$TS_DEVICE_CONF_2"
fi
fi
fi
if [ ! -f $ADDON_HOME/ts.conf -a -n "$TS_DEVICE_CONF" ]; then
cp "$ADDON_HOME/$TS_DEVICE_CONF" $ADDON_HOME/ts.conf
fi
export TSLIB_TSDEVICE="$TSLIB_TSDEVICE"
export TSLIB_PLUGINDIR=$ADDON_DIR/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CALIBFILE=$ADDON_HOME/pointercal
export TSLIB_CONFFILE=$ADDON_HOME/ts.conf
#export TSLIB_RES_X=800
#export TSLIB_RES_Y=480
fi
fi

View File

@ -0,0 +1,55 @@
#!/bin/sh
################################################################################
# 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/>.
################################################################################
. /etc/profile
oe_setup_addon service.touchscreen
if [ -d /usr/share/kodi/addons/service.touchscreen ]; then
# addon included in image
ADDON_DIR="/usr/share/kodi/addons/service.touchscreen"
fi
. $ADDON_DIR/bin/ts_env.sh
params=$*
if [ "$1" = "service" ]; then
# skip service parameter and daemonize
params="-d"
else
# started from command line
systemctl stop ts_uinput_touch >/dev/null 2>&1
killall ts_uinput_touch >/dev/null 2>&1
fi
echo " touchscreen device: '$TSLIB_TSDEVICE'"
if [ -n "$TSLIB_RES_X" -a -n "$TSLIB_RES_Y" ]; then
echo "touchscreen resolution: '${TSLIB_RES_X}x${TSLIB_RES_Y}'"
params="-x $TSLIB_RES_X -y $TSLIB_RES_Y $params"
fi
echo "params: .$params."
if [ ! -x $ADDON_HOME/ts_uinput_touch ]; then
ts_uinput_touch $params
else
echo "Using $ADDON_HOME/ts_uinput_touch"
$ADDON_HOME/ts_uinput_touch $params
fi

View File

@ -0,0 +1,157 @@
################################################################################
# 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 os
import socket
import sys
from threading import Thread
import xbmc
import xbmcgui
import xbmcaddon
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_RIGHT = 1
TEXT_ALIGN_CENTER_X = 2
TEXT_ALIGN_CENTER_Y = 4
TEXT_ALIGN_RIGHT_CENTER_Y = 5
TEXT_ALIGN_LEFT_CENTER_X_CENTER_Y = 6
ACTION_PREVIOUS_MENU = 10
ACTION_BACKSPACE = 92
SOCK_PATH = "/tmp/ts_calibrate.socket"
TSLIB_EDGE_OFFEST = 50
CROSSHAIR_IMAGE_SIZE = 23
CROSSHAIR_IMAGE_OFFSET = 11
SKIN_WIDTH = 1280 # we are using 720p skin
SKIN_HEIGHT = 720
class coordinates:
var_x = 0
var_y = 0
def server_thread(conn, self):
while True:
data = conn.recv(128)
if not data:
break
self.currentTarget = self.currentTarget + 1
if self.currentTarget > 0:
self.removeControl(self.targetImage)
if self.currentTarget == 5:
xbmcgui.Dialog().ok("Calibration", "Calibration done.")
break
self.info.setLabel("Touch '" + data + "' crosshair")
self.targetImage = xbmcgui.ControlImage(
self.touch_points[self.currentTarget].var_x - CROSSHAIR_IMAGE_OFFSET,
self.touch_points[self.currentTarget].var_y - CROSSHAIR_IMAGE_OFFSET,
CROSSHAIR_IMAGE_SIZE, CROSSHAIR_IMAGE_SIZE,
self.crosshair_path, colorDiffuse='0x00000000')
self.addControl(self.targetImage)
# out of loop, close connection
conn.close()
os.remove(SOCK_PATH)
self.retval = 0
self.close()
class ts_calibrate(xbmcgui.WindowDialog):
def __init__(self):
self.retval = 0
self.media_path=os.path.join(addon.getAddonInfo('path'), 'resources','media') + '/'
self.crosshair_path = self.media_path + 'crosshair.png'
self.currentTarget = -1
self.edge_offset_x = TSLIB_EDGE_OFFEST * SKIN_WIDTH / self.getWidth()
self.edge_offset_y = TSLIB_EDGE_OFFEST * SKIN_HEIGHT / self.getHeight()
self.touch_points = [coordinates() for i in range(5)]
self.touch_points[0].var_x = self.edge_offset_x
self.touch_points[0].var_y = self.edge_offset_y
self.touch_points[1].var_x = SKIN_WIDTH - self.edge_offset_x
self.touch_points[1].var_y = self.edge_offset_y
self.touch_points[2].var_x = SKIN_WIDTH - self.edge_offset_x
self.touch_points[2].var_y = SKIN_HEIGHT - self.edge_offset_y
self.touch_points[3].var_x = self.edge_offset_x
self.touch_points[3].var_y = SKIN_HEIGHT - self.edge_offset_y
self.touch_points[4].var_x = SKIN_WIDTH / 2
self.touch_points[4].var_y = SKIN_HEIGHT / 2
self.background = xbmcgui.ControlImage(0, 0, SKIN_WIDTH, SKIN_HEIGHT,
self.media_path + 'background.jpg', colorDiffuse = '0xffffffff')
self.addControl(self.background)
tmp_str = "Tslib/Kodi calibration utility\n\nTouch crosshair to calibrate"
tmp_str += "\n\nresolution: " + str(self.getWidth()) + "x" + str(self.getHeight())
tmp_str += "\nskin: " + str(SKIN_WIDTH) + "x" + str(SKIN_HEIGHT)
self.about = xbmcgui.ControlLabel(
10, 80, SKIN_WIDTH, 400,
"", textColor = '0xffffffff', font = 'font25', alignment = TEXT_ALIGN_CENTER_X)
self.addControl(self.about)
self.about.setLabel(tmp_str)
self.info = xbmcgui.ControlLabel(
20, SKIN_HEIGHT/2 - 40,
1000, 400,
"", textColor = '0xffffffff', font = 'font30', alignment = TEXT_ALIGN_LEFT)
self.addControl(self.info)
self.info.setLabel("")
if os.path.exists(SOCK_PATH):
os.remove(SOCK_PATH)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(SOCK_PATH)
sock.listen(1)
# enter calibration mode
os.system("killall -SIGUSR1 ts_uinput_touch")
print 'Waiting for calibration connection'
conn, addr = sock.accept()
print 'Calibration connection accepted'
self.t = Thread(target=server_thread, args=(conn, self,))
self.t.start()
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU or action == ACTION_BACKSPACE:
self.retval = 0
self.close()
addon = xbmcaddon.Addon(id = 'service.touchscreen')
finished = False
while finished == False:
dialog = ts_calibrate()
dialog.doModal()
if dialog.retval == 0:
finished = True
del dialog
del addon
# exit calibration mode
os.system("killall -SIGUSR2 ts_uinput_touch")
if os.path.exists(SOCK_PATH):
os.remove(SOCK_PATH)

View File

@ -0,0 +1,8 @@
module_raw input grab_events=1
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
# or use swap_xy parameter to swap axes
#module linear swap_xy=1

View File

@ -0,0 +1,6 @@
# Udoo with 15.6" 1366x768 display with 3M USB Touchscreen - EX II
module_raw input grab_events=1
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

View File

@ -0,0 +1,3 @@
# Udoo with 7" 800x480 display with ST1232 touch controler
# only st1232 raw input module is used
module_raw st1232 grab_events=1 invert_y=480

View File

@ -0,0 +1,6 @@
# len is hidraw data size
module_raw waveshare len=22
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

View File

@ -0,0 +1,42 @@
#!/bin/sh
################################################################################
# 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/>.
################################################################################
# find touchscreen device by name (substring) using evtest program
# $ evtest
# No device specified, trying to scan all of /dev/input/event*
# Available devices:
# /dev/input/event0: Video Bus
# /dev/input/event1: Goodix Capacitive TouchScreen
# Select the device event number [0-1]:
TOUCHSCREEN_NAME="Goodix Capacitive TouchScreen"
TSLIB_TSDEVICE=$(echo 999 | evtest 2>&1 >/dev/null | awk -F':' -v TS_NAME="$TOUCHSCREEN_NAME" '$0 ~ TS_NAME {print $1; exit}')
export TSLIB_TSDEVICE
export TSLIB_PLUGINDIR=$ADDON_DIR/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CALIBFILE=/storage/.kodi/userdata/addon_data/service.touchscreen/pointercal
export TSLIB_CONFFILE=/storage/.kodi/userdata/addon_data/service.touchscreen/ts.conf
# sometimes needed
#export TSLIB_RES_X=800
#export TSLIB_RES_Y=480

View File

@ -0,0 +1,62 @@
#!/bin/sh
################################################################################
# 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/>.
################################################################################
# change vid/pid for waveshare touchscreen device
PRODUCT_VID=0EEF
PRODUCT_PID=0005
# device set directly or find automaticaly at the end of this script
export TSLIB_TSDEVICE=""
#export TSLIB_TSDEVICE="/dev/hidrawN"
export TSLIB_PLUGINDIR=$ADDON_DIR/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CALIBFILE=/storage/.kodi/userdata/addon_data/service.touchscreen/pointercal
export TSLIB_CONFFILE=/storage/.kodi/userdata/addon_data/service.touchscreen/ts.conf
export TSLIB_RES_X=800
export TSLIB_RES_Y=480
# find touchscreen device
if [ "$TSLIB_TSDEVICE" = "" ]; then
PRODUCT_VID_PID="0000${PRODUCT_VID}:0000${PRODUCT_PID}"
echo "PRODUCT_VID_PID: $PRODUCT_VID_PID"
hidrawN=""
for dev in /sys/class/hidraw/hidraw*/device/uevent; do
echo
echo "device: $dev"
HID_ID=$(cat $dev | grep HID_ID | grep "$PRODUCT_VID_PID")
if [ -n "$HID_ID" ]; then
hidrawN=$(echo $dev | awk -F "/" '{print $5}')
hidrawN="/dev/$hidrawN"
echo "OK HID_ID: $HID_ID"
echo "OK hidrawN: $hidrawN"
break
fi
done
if [ -n "$hidrawN" ]; then
echo "found hidrawN: $hidrawN"
export TSLIB_TSDEVICE=$hidrawN
fi
fi

View File

@ -0,0 +1,48 @@
################################################################################
# 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 xbmc
import xbmcgui
import xbmcaddon
__scriptid__ = 'service.touchscreen'
__addon__ = xbmcaddon.Addon(id=__scriptid__)
_ = __addon__.getLocalizedString
# http://forum.kodi.tv/showthread.php?tid=230766
def handle_wait(time_to_wait, title, text):
dialog = xbmcgui.DialogProgress()
ret = dialog.create(' ' + title)
secs = 0
percent = 0
increment = int(100 / time_to_wait)
while secs < time_to_wait:
secs += 1
percent = increment*secs
secs_left = time_to_wait - secs
remaining_display = (_(2030).encode('utf-8')) % secs_left
dialog.update(percent, text, "", remaining_display)
xbmc.sleep(1000)
dialog.close()
return False
# how long to lock the screen
lock_secs = 30
handle_wait(lock_secs, _(2010).encode('utf-8'), _(2020).encode('utf-8'))

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="1000">General</string>
<string id="1010">Recalibrate after reboot</string>
<string id="1020">Clean screen</string>
<string id="2010">Touchscreen</string>
<string id="2020">Now you can safely clean the screen.</string>
<string id="2030">Still %d seconds left.</string>
</strings>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="1000">Allgemein</string>
<string id="1010">Nach einem Neustart neu kalibrieren</string>
<string id="1020">Touchscreen reinigen</string>
<string id="2010">Touchscreen</string>
<string id="2020">Sie können jetzt den Touchscreen sicher reinigen.</string>
<string id="2030">Noch %d Sekunden übrig.</string>
</strings>

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="1000" >
<setting type="sep" />
<setting label="1010" id="TS_RECALIBRATE" type="bool" default="false" />
<setting label="1020" id="clean_screen" type="action" option="close" action="RunScript($CWD/lock-screen.py)" />
</category>
</settings>

View File

@ -0,0 +1,17 @@
################################################################################
# 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/>.
################################################################################

View File

@ -0,0 +1,14 @@
[Unit]
Description=Touchscreen support daemon
After=graphical.target
Before=kodi.target
[Service]
Type=oneshot
Environment=HOME=/storage
ExecStartPre=-/bin/sh -c "exec /bin/sh /storage/.kodi/addons/service.touchscreen/bin/ts_calibrate.sh service"
ExecStart=-/bin/sh -c "exec /bin/sh /storage/.kodi/addons/service.touchscreen/bin/ts_uinput_touch.sh service"
RemainAfterExit=yes
[Install]
WantedBy=kodi.target