devicepkg-dev: Generate calibration matrix for libinput (#1205)
* Automatically generate a calibration matrix for libinput This takes the calibration matrix for wayland and divides the pixel offsets by the device width/height. * Bump pkgrels of devices using devicepkg-dev This causes new packages to be generated, using the new devicepkg-dev version.
This commit is contained in:
parent
f870333b99
commit
99b398a7e5
16 changed files with 65 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-asus-tf101"
|
pkgname="device-asus-tf101"
|
||||||
pkgdesc="Asus Eee Pad Transformer"
|
pkgdesc="Asus Eee Pad Transformer"
|
||||||
pkgver=0.2
|
pkgver=0.2
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-leeco-s2"
|
pkgname="device-leeco-s2"
|
||||||
pkgdesc="LeEco Le 2"
|
pkgdesc="LeEco Le 2"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-lg-h815"
|
pkgname="device-lg-h815"
|
||||||
pkgdesc="LG G4 (h815)"
|
pkgdesc="LG G4 (h815)"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-motorola-potter"
|
pkgname="device-motorola-potter"
|
||||||
pkgdesc="Motorola Moto G5 Plus"
|
pkgdesc="Motorola Moto G5 Plus"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-motorola-shamu"
|
pkgname="device-motorola-shamu"
|
||||||
pkgdesc="Motorola Google Nexus 6"
|
pkgdesc="Motorola Google Nexus 6"
|
||||||
pkgver=0.3
|
pkgver=0.3
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-samsung-espresso10"
|
pkgname="device-samsung-espresso10"
|
||||||
pkgdesc="Samsung Galaxy Tab 2 (10.1 inch)"
|
pkgdesc="Samsung Galaxy Tab 2 (10.1 inch)"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=2
|
pkgrel=3
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Reference: <https://postmarketos.org/devicepkg>
|
# Reference: <https://postmarketos.org/devicepkg>
|
||||||
pkgname=device-samsung-i9070
|
pkgname=device-samsung-i9070
|
||||||
pkgver=1
|
pkgver=1
|
||||||
pkgrel=19
|
pkgrel=20
|
||||||
pkgdesc="Samsung Galaxy S Advance"
|
pkgdesc="Samsung Galaxy S Advance"
|
||||||
url="https://github.com/postmarketOS"
|
url="https://github.com/postmarketOS"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-samsung-i9195"
|
pkgname="device-samsung-i9195"
|
||||||
pkgdesc="Samsung Galaxy S4 Mini"
|
pkgdesc="Samsung Galaxy S4 Mini"
|
||||||
pkgver=0.2
|
pkgver=0.2
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Reference: <https://postmarketos.org/devicepkg>
|
# Reference: <https://postmarketos.org/devicepkg>
|
||||||
pkgname=device-samsung-maguro
|
pkgname=device-samsung-maguro
|
||||||
pkgver=2
|
pkgver=2
|
||||||
pkgrel=16
|
pkgrel=17
|
||||||
pkgdesc="Google Galaxy Nexus (GSM)"
|
pkgdesc="Google Galaxy Nexus (GSM)"
|
||||||
url="https://github.com/postmarketOS"
|
url="https://github.com/postmarketOS"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-samsung-manta"
|
pkgname="device-samsung-manta"
|
||||||
pkgdesc="Google Nexus 10"
|
pkgdesc="Google Nexus 10"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-samsung-s6500d"
|
pkgname="device-samsung-s6500d"
|
||||||
pkgdesc="Samsung Galaxy Mini 2"
|
pkgdesc="Samsung Galaxy Mini 2"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname=device-semc-anzu
|
pkgname=device-semc-anzu
|
||||||
pkgdesc="Xperia Arc"
|
pkgdesc="Xperia Arc"
|
||||||
pkgver=1
|
pkgver=1
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
pkgname="device-teclast-x80pro"
|
pkgname="device-teclast-x80pro"
|
||||||
pkgdesc="Teclast X80Pro"
|
pkgdesc="Teclast X80Pro"
|
||||||
pkgver=1.0
|
pkgver=1.0
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pkgname="device-xiaomi-ido"
|
pkgname="device-xiaomi-ido"
|
||||||
pkgdesc="Xiaomi Xiaomi RedMi 3"
|
pkgdesc="Xiaomi Xiaomi RedMi 3"
|
||||||
pkgver=0.1
|
pkgver=0.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
pkgname="devicepkg-dev"
|
pkgname="devicepkg-dev"
|
||||||
pkgver=0.1
|
pkgver=0.2
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc="Provides default device package functions"
|
pkgdesc="Provides default device package functions"
|
||||||
url="https://github.com/postmarketOS"
|
url="https://github.com/postmarketOS"
|
||||||
|
@ -16,5 +16,5 @@ package() {
|
||||||
install -Dm755 "$srcdir/devicepkg_package.sh" \
|
install -Dm755 "$srcdir/devicepkg_package.sh" \
|
||||||
"$pkgdir/usr/bin/devicepkg_package"
|
"$pkgdir/usr/bin/devicepkg_package"
|
||||||
}
|
}
|
||||||
sha512sums="e6f96f8942fa8124ca7461bcf9c78879e08ef00da4a728735046503cae86548505594e078eb14056af74616b17332474f1473f72127299773e075bfd970af13b devicepkg_build.sh
|
sha512sums="638d50e6388eabf0da6bf0cff2fe9719ad8a808946f0077228db57fa13a26d9eeb39c1f2689c9a6f93ff9b3bcfdcfb7c358b180bba90e5bba8b9a9e78d25ed18 devicepkg_build.sh
|
||||||
c732792596f56860f6ab9ddd53b9a7a80224400dd20097b20cebe17a6e7330e9178783f09db16132a28a555f83e29ef3643bfe069638b62998912a9a7ffefdc0 devicepkg_package.sh"
|
c732792596f56860f6ab9ddd53b9a7a80224400dd20097b20cebe17a6e7330e9178783f09db16132a28a555f83e29ef3643bfe069638b62998912a9a7ffefdc0 devicepkg_package.sh"
|
||||||
|
|
|
@ -20,6 +20,50 @@ fi
|
||||||
# shellcheck disable=SC1090,SC1091
|
# shellcheck disable=SC1090,SC1091
|
||||||
. "$srcdir/deviceinfo"
|
. "$srcdir/deviceinfo"
|
||||||
|
|
||||||
|
# Convert an input calibration matrix from pixel coordinates to 0-1 coordinates
|
||||||
|
# and echo it for libinput.
|
||||||
|
# Parameters:
|
||||||
|
# $1: x multiplier for x coordinate
|
||||||
|
# $2: y multiplier for x coordinate
|
||||||
|
# $3: pixel offset for x coordinate
|
||||||
|
# $4: x multiplier for y coordinate
|
||||||
|
# $5: y multiplier for y coordinate
|
||||||
|
# $6: pixel offset for y coordinate
|
||||||
|
echo_libinput_calibration()
|
||||||
|
{
|
||||||
|
# Check if we have got the required number of parameters.
|
||||||
|
if [ $# -ne 6 ]; then
|
||||||
|
echo "WARNING: There must be exactly 6 (or 0) values for the touchscreen calibration." >&2
|
||||||
|
echo "WARNING: No calibration matrix for x11/libinput will be generated." >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if we have got a screen width and screen height.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
if [ -z "$deviceinfo_screen_width" ] || [ -z "$deviceinfo_screen_height" ]; then
|
||||||
|
echo "WARNING: Screen width and height are required to generate a calibration matrix for x11/libinput." >&2
|
||||||
|
echo "WARNING: No calibration matrix for x11/libinput will be generated." >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Perform the actual conversion: divide both offsets by width/height.
|
||||||
|
# As the "dc" command from "bc" is incompatible to the one provided by busybox,
|
||||||
|
# this calls busybox explicitly.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
x_offset=$(busybox dc "$3" "$deviceinfo_screen_width" / p)
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
y_offset=$(busybox dc "$6" "$deviceinfo_screen_height" / p)
|
||||||
|
# Check if we have got results from dc. If there was an error, dc should have
|
||||||
|
# printed an error message that hopefully gives the user a hint why it failed.
|
||||||
|
if [ -z "$x_offset" ] || [ -z "$y_offset" ]; then
|
||||||
|
echo "WARNING: Calculating the offsets for the calibration matrix for x11/libinput failed." >&2
|
||||||
|
echo "No calibration matrix for x11/libinput will be generated." >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ENV{LIBINPUT_CALIBRATION_MATRIX}=\"$1 $2 $x_offset $4 $5 $y_offset\", \\"
|
||||||
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [ ! -z "$deviceinfo_dev_touchscreen" ]; then
|
if [ ! -z "$deviceinfo_dev_touchscreen" ]; then
|
||||||
# Create touchscreen udev rule
|
# Create touchscreen udev rule
|
||||||
|
@ -28,6 +72,11 @@ if [ ! -z "$deviceinfo_dev_touchscreen" ]; then
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [ ! -z "$deviceinfo_dev_touchscreen_calibration" ]; then
|
if [ ! -z "$deviceinfo_dev_touchscreen_calibration" ]; then
|
||||||
echo "ENV{WL_CALIBRATION}=\"$deviceinfo_dev_touchscreen_calibration\", \\"
|
echo "ENV{WL_CALIBRATION}=\"$deviceinfo_dev_touchscreen_calibration\", \\"
|
||||||
|
|
||||||
|
# The following intentionally expands the touchscreen calibration into the
|
||||||
|
# 6 values that should be there.
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
echo_libinput_calibration $deviceinfo_dev_touchscreen_calibration
|
||||||
fi
|
fi
|
||||||
echo "ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TOUCHSCREEN}=\"1\""
|
echo "ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TOUCHSCREEN}=\"1\""
|
||||||
} > "$srcdir/90-$pkgname.rules"
|
} > "$srcdir/90-$pkgname.rules"
|
||||||
|
|
Loading…
Reference in a new issue