Compare commits
3 Commits
20180914gi
...
main
Author | SHA1 | Date | |
---|---|---|---|
bffbb611fb | |||
1fff217ccd | |||
cbfaa5d956 |
@ -0,0 +1,135 @@
|
||||
diff -Nru surface-tools-20180914git.orig/autorotate/autorotate surface-tools-20180914git/autorotate/autorotate
|
||||
--- surface-tools-20180914git.orig/autorotate/autorotate 2019-08-03 21:13:46.720000000 +0200
|
||||
+++ surface-tools-20180914git/autorotate/autorotate 2019-08-03 21:14:01.072000000 +0200
|
||||
@@ -3,12 +3,14 @@
|
||||
#####CONFIGURATION#####
|
||||
#sensorname="accel_3d"
|
||||
|
||||
-#screenname="eDP1"
|
||||
+screenname = None
|
||||
+touchname = None
|
||||
|
||||
#####PROGRAM CODE#####
|
||||
#Do not change unless you know what you are doing!
|
||||
|
||||
xrandr="/usr/bin/xrandr"
|
||||
+xinput="/usr/bin/xinput"
|
||||
|
||||
resourcepaths=[
|
||||
"./",
|
||||
@@ -36,6 +38,7 @@
|
||||
|
||||
hasAppIndicator = True
|
||||
try:
|
||||
+ gi.require_version('AppIndicator', '0.1')
|
||||
from gi.repository import AppIndicator3 as AppIndicator
|
||||
except:
|
||||
hasAppIndicator = False
|
||||
@@ -46,9 +49,15 @@
|
||||
out = p.stdout.read().strip()
|
||||
return out #This is the stdout from the shell command
|
||||
|
||||
-def twos_comp(val):
|
||||
- if val & (1 << (16-1)) != 0:
|
||||
- val = val - (1 << 16)
|
||||
+def twos_comp(val, scale):
|
||||
+ if scale:
|
||||
+ # Chuwi
|
||||
+ val = val * scale / 9.8
|
||||
+ else:
|
||||
+ # Microsoft Surface (unsupported)
|
||||
+ print 1 << 16
|
||||
+ if val & (1 << (16-1)) != 0:
|
||||
+ val = val - (1 << 16)
|
||||
return val
|
||||
|
||||
def getOrientation(accelX, accelY, accelZ):
|
||||
@@ -56,18 +65,32 @@
|
||||
absAccelY = abs(accelY)
|
||||
absAccelZ = abs(accelZ)
|
||||
|
||||
- if absAccelZ > 4 * absAccelX and absAccelZ > 4 * absAccelY:
|
||||
- orientation = "flat"
|
||||
- elif 3 * absAccelY > 2 * absAccelX:
|
||||
- orientation = "inverted" if accelY > 0 else "normal"
|
||||
- else:
|
||||
- orientation = "left" if accelX > 0 else "right"
|
||||
+ orientation = "nochange"
|
||||
+ if absAccelZ > 0.5:
|
||||
+ orientation = "nochange"
|
||||
+ elif absAccelX > 3 * absAccelY:
|
||||
+ orientation = "normal" if accelX > 0 else "inverted"
|
||||
+ elif absAccelY > 3 * absAccelX:
|
||||
+ orientation = "right" if accelY > 0 else "left"
|
||||
|
||||
return orientation
|
||||
|
||||
def rotate(orientation):
|
||||
- if orientation in orientations:
|
||||
+ if orientation in orientations and screenname is not None:
|
||||
subprocess.call([xrandr, "--output", screenname, "--rotate", orientation])
|
||||
+ if touchname is not None:
|
||||
+ if orientation == "normal":
|
||||
+ subprocess.call([xinput, "set-prop", "pointer:" + touchname, "Coordinate Transformation Matrix",
|
||||
+ "0", "0", "0", "0", "0", "0", "0", "0", "0"])
|
||||
+ elif orientation == "inverted":
|
||||
+ subprocess.call([xinput, "set-prop", "pointer:" + touchname, "Coordinate Transformation Matrix",
|
||||
+ "-1", "0", "1", "0", "-1", "1", "0", "0", "1"])
|
||||
+ elif orientation == "right":
|
||||
+ subprocess.call([xinput, "set-prop", "pointer:" + touchname, "Coordinate Transformation Matrix",
|
||||
+ "0", "1", "0", "-1", "0", "1", "0", "0", "1"])
|
||||
+ elif orientation == "left":
|
||||
+ subprocess.call([xinput, "set-prop", "pointer:" + touchname, "Coordinate Transformation Matrix",
|
||||
+ "0", "-1", "1", "1", "0", "0", "0", "0", "1"])
|
||||
|
||||
def toggleRotLock(event):
|
||||
global rotlock
|
||||
@@ -84,14 +107,14 @@
|
||||
icon.set_from_pixbuf(lockrot if rotlock else unlockrot)
|
||||
|
||||
def checkRotation():
|
||||
- if not rotlock:
|
||||
- device = pyudev.Device.from_path(context, path)
|
||||
- accelX = twos_comp(device.attributes.asint("in_accel_x_raw"))
|
||||
- accelY = twos_comp(device.attributes.asint("in_accel_y_raw"))
|
||||
- accelZ = twos_comp(device.attributes.asint("in_accel_z_raw"))
|
||||
-
|
||||
- orientation = getOrientation(accelX, accelY, accelZ)
|
||||
+ device = pyudev.Device.from_path(context, path)
|
||||
+ scale = float(device.attributes.__getitem__("in_accel_scale"))
|
||||
+ accelX = twos_comp(device.attributes.asint("in_accel_x_raw"), scale)
|
||||
+ accelY = twos_comp(device.attributes.asint("in_accel_y_raw"), scale)
|
||||
+ accelZ = twos_comp(device.attributes.asint("in_accel_z_raw"), scale)
|
||||
+ orientation = getOrientation(accelX, accelY, accelZ)
|
||||
|
||||
+ if not rotlock and orientation != "nochange":
|
||||
global prevorientation
|
||||
if orientation != prevorientation:
|
||||
prevorientation = orientation
|
||||
@@ -121,6 +144,20 @@
|
||||
screenname = out
|
||||
break
|
||||
|
||||
+# Cache the xinput info
|
||||
+XINPUT_INFO = run_shell_cmd('xinput --list --name-only')
|
||||
+
|
||||
+# Find the display we are interested to move (= the laptop panel)
|
||||
+POSSIBLE_OUTPUT = [ "CHPN0001:00" ]
|
||||
+for out in POSSIBLE_OUTPUT:
|
||||
+ match = re.search("^" + out + "$",
|
||||
+ XINPUT_INFO,
|
||||
+ re.MULTILINE
|
||||
+ )
|
||||
+ if match:
|
||||
+ touchname = out
|
||||
+ break
|
||||
+
|
||||
path = device.device_path
|
||||
|
||||
prevorientation = ""
|
||||
@@ -169,5 +206,3 @@
|
||||
Gtk.main()
|
||||
else:
|
||||
checkRotation()
|
||||
-
|
||||
-
|
44
surface-tools-20180914git-autorotate-python3.patch
Normal file
44
surface-tools-20180914git-autorotate-python3.patch
Normal file
@ -0,0 +1,44 @@
|
||||
diff -Nru surface-tools-20180914git/autorotate/autorotate surface-tools-20180914git.patched/autorotate/autorotate
|
||||
--- surface-tools-20180914git/autorotate/autorotate 2021-07-24 19:55:05.572617055 +0200
|
||||
+++ surface-tools-20180914git.patched/autorotate/autorotate 2021-07-24 19:52:10.136395281 +0200
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/python
|
||||
+#!/usr/bin/python3
|
||||
|
||||
#####CONFIGURATION#####
|
||||
#sensorname="accel_3d"
|
||||
@@ -55,7 +55,6 @@
|
||||
val = val * scale / 9.8
|
||||
else:
|
||||
# Microsoft Surface (unsupported)
|
||||
- print 1 << 16
|
||||
if val & (1 << (16-1)) != 0:
|
||||
val = val - (1 << 16)
|
||||
return val
|
||||
@@ -108,7 +107,7 @@
|
||||
|
||||
def checkRotation():
|
||||
device = pyudev.Device.from_path(context, path)
|
||||
- scale = float(device.attributes.__getitem__("in_accel_scale"))
|
||||
+ scale = float(device.attributes.get("in_accel_scale"))
|
||||
accelX = twos_comp(device.attributes.asint("in_accel_x_raw"), scale)
|
||||
accelY = twos_comp(device.attributes.asint("in_accel_y_raw"), scale)
|
||||
accelZ = twos_comp(device.attributes.asint("in_accel_z_raw"), scale)
|
||||
@@ -131,7 +130,7 @@
|
||||
|
||||
"""Find which output to rotate, and get its current rotation"""
|
||||
# Cache the xrandr info as we'll use it several times
|
||||
-XRANDR_INFO = run_shell_cmd('xrandr --verbose')
|
||||
+XRANDR_INFO = run_shell_cmd('xrandr --verbose').decode('utf-8')
|
||||
|
||||
# Find the display we are interested to move (= the laptop panel)
|
||||
POSSIBLE_OUTPUT = [ "DSI1", "DSI-1", "eDP1", "LVDS", "LVDS1" ]
|
||||
@@ -145,7 +144,7 @@
|
||||
break
|
||||
|
||||
# Cache the xinput info
|
||||
-XINPUT_INFO = run_shell_cmd('xinput --list --name-only')
|
||||
+XINPUT_INFO = run_shell_cmd('xinput --list --name-only').decode('utf-8')
|
||||
|
||||
# Find the display we are interested to move (= the laptop panel)
|
||||
POSSIBLE_OUTPUT = [ "CHPN0001:00" ]
|
@ -1,37 +1,38 @@
|
||||
Name: surface-tools
|
||||
Version: 20180914git
|
||||
Release: 3mamba
|
||||
Release: 6mamba
|
||||
Summary: Tools for using the Microsoft Surface with Linux
|
||||
Group: System/Kernel and Hardware
|
||||
Vendor: openmamba
|
||||
Distribution: openmamba
|
||||
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
URL: https://github.com/Surface-Pro-3/surface-tools
|
||||
## GITSOURCE https://github.com/Surface-Pro-3/surface-tools.git master
|
||||
URL: https://github.com/freundTech/surface-tools
|
||||
Source: https://github.com/Surface-Pro-3/surface-tools.git/master/surface-tools-%{version}.tar.bz2
|
||||
Source1: autorotate.desktop
|
||||
Patch0: surface-tools-20180914git-autorotate-autodetect.patch
|
||||
Patch1: surface-tools-20180914git-check-and-fork.patch
|
||||
Patch2: surface-tools-20180914git-penmon-autodetect.patch
|
||||
Patch3: surface-tools-20180914git-autorotate-chuwi-fix-and-touchscreen.patch
|
||||
Patch4: surface-tools-20180914git-autorotate-python3.patch
|
||||
License: GPL
|
||||
## AUTOBUILDREQ-BEGIN
|
||||
## AUTOBUILDREQ-END
|
||||
Requires: pyudev
|
||||
Requires: pygobject
|
||||
Requires: pyudev-py3
|
||||
Requires: python3
|
||||
Requires: pygobject-py3
|
||||
Requires: xrandr
|
||||
Requires: xinput
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
|
||||
%description
|
||||
Tools for using the Microsoft Surface with Linux.
|
||||
|
||||
%debug_package
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
|
||||
%build
|
||||
|
||||
@ -59,6 +60,15 @@ install -D -m0755 penmon/penmon %{buildroot}%{_datadir}/penmon/penmon
|
||||
%doc LICENSE
|
||||
|
||||
%changelog
|
||||
* Sat Jul 24 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 20180914git-6mamba
|
||||
- update autorotate patch for python3 pyudev 0.22
|
||||
|
||||
* Mon Dec 21 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 20180914git-5mamba
|
||||
- rebuilt with python3
|
||||
|
||||
* Sat Aug 03 2019 Silvan Calarco <silvan.calarco@mambasoft.it> 20180914git-4mamba
|
||||
- autorotate: fixes and touchscreen rotation support for chuwi
|
||||
|
||||
* Tue Mar 05 2019 Silvan Calarco <silvan.calarco@mambasoft.it> 20180914git-3mamba
|
||||
- patch #0 updated to detect DSI-1 displays
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user