Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor rotation not working - height of menu bar in KDE #3

Open
novo-redeunt opened this issue Nov 16, 2018 · 9 comments
Open

Cursor rotation not working - height of menu bar in KDE #3

novo-redeunt opened this issue Nov 16, 2018 · 9 comments

Comments

@novo-redeunt
Copy link

Hello,

first of all: Thank you very much for providing the script! I have a MS Surface Book 2 (13") with jakeday's kernel (https://github.com/jakeday/linux-surface). Everything works well but I did not dare to touch screen auto rotation since I once screwed things so up that I had to reinstall.

Auto rotation with your script works great after changing eDP-1 to eDP1. However, mouse cursor does not follow rotation. Can you give me any direction where to look to fix that? Also: Do you have an idea how to scale the menu bar (i. e. adjust height) in KDE? It gets very small when I flip the screen to upright postion.

Thanks in advance!

@novo-redeunt novo-redeunt changed the title Cursor rotation not working - scaling of menu bar Cursor rotation not working - heigt of menu bar in KDE Nov 16, 2018
@donbowman
Copy link
Owner

Can you post the output of: xinput list ?

For the mouse to not rotate it means the input rotation matrix doesn't find it.

as for the size, um, its big enough landscape but not portrait? Maybe look @ https://wiki.archlinux.org/index.php/HiDPI

@donbowman donbowman changed the title Cursor rotation not working - heigt of menu bar in KDE Cursor rotation not working - height of menu bar in KDE Nov 16, 2018
@novo-redeunt
Copy link
Author

Thank you for your quick reply! The output is as follows:

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ipts 045E:0021 UNKNOWN id=11 [slave pointer (2)]
⎜ ↳ ipts 045E:0021 Touchscreen id=13 [slave pointer (2)]
⎜ ↳ ipts 045E:0021 Mouse id=14 [slave pointer (2)]
⎜ ↳ Surface Arc Mouse Mouse id=19 [slave pointer (2)]
⎜ ↳ Surface Arc Mouse Consumer Control id=20 [slave pointer (2)]
⎜ ↳ Microsoft Surface Keyboard Mouse id=8 [slave pointer (2)]
⎜ ↳ Microsoft Surface Keyboard Consumer Control id=9 [slave pointer (2)]
⎜ ↳ Microsoft Surface Keyboard Touchpad id=17 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Video Bus id=6 [slave keyboard (3)]
↳ ipts 045E:0021 Pen id=12 [slave keyboard (3)]
↳ gpio-keys id=16 [slave keyboard (3)]
↳ gpio-keys id=15 [slave keyboard (3)]
↳ Surface Arc Mouse Keyboard id=18 [slave keyboard (3)]
↳ Surface Arc Mouse Consumer Control id=21 [slave keyboard (3)]
↳ Microsoft Surface Keyboard Keyboard id=7 [slave keyboard (3)]
↳ Microsoft Surface Keyboard Consumer Control id=10 [slave keyboard (3)]

Thank you again for your great work and your efforts!

@donbowman
Copy link
Owner

donbowman commented Nov 16, 2018

do you know which pointer you are using of that list that is not following the rotation?

you could try 'xev' to see i guess.

you could manually try setting the transformation matrix.

don't worry, nothing in this script persists, it won't cause trouble :)

It seems my script would be transforming:

2
4
11
13
14
19
20
8
9
17

pointer id from your list

@donbowman
Copy link
Owner

My guess is the 'arc mouse keyboard' is actually a pointer(?) or the 'ipts'.

↳ Video Bus id=6 [slave keyboard (3)]
↳ ipts 045E:0021 Pen id=12 [slave keyboard (3)]
↳ gpio-keys id=16 [slave keyboard (3)]
↳ gpio-keys id=15 [slave keyboard (3)]
↳ Surface Arc Mouse Keyboard id=18 [slave keyboard (3)]
↳ Surface Arc Mouse Consumer Control id=21 [slave keyboard (3)]
↳ Microsoft Surface Keyboard Keyboard id=7 [slave keyboard (3)]
↳ Microsoft Surface Keyboard Consumer Control id=10 [slave keyboard (3)]

@novo-redeunt
Copy link
Author

Got it. Surface Arc Mouse is working fine but not the pen (↳ ipts 045E:0021 Pen id=12 [slave keyboard (3)]). So after rotation the mouse pointer when moved by the Arc mouse is behaving as expected but not the touch screen input. I guess that it is only a minor change to the script?

@donbowman
Copy link
Owner

donbowman commented Nov 16, 2018

try this:

--- a/auto-rotate
+++ b/auto-rotate
@@ -5,7 +5,7 @@
 # copyright 2018 Don Bowman ([email protected])
 # Licensed under Apache License, Version 2.0
 
-pointers=$(xinput list | awk '/Virtual core pointer/ { printing=1 } /Virtual core keyboard/ { printing=0} { if (printing) { gsub(".*id=",""); print $1 } }')
+pointers=$(xinput list | awk '/ pointer|ipts / { gsub(".*id=",""); print $1 } {}')
 
 rotate_cursor() {
     for p in $pointers

@donbowman
Copy link
Owner

Looking @ jakeday/linux-surface#150 (comment)

it seems they do ipts/surface keyboard touchpad

@novo-redeunt
Copy link
Author

I changed the line as you suggested but it did not have an effect. I need to look deeper into my system to exclude that I made a stupid mistake on my side and will come back to you when I found something. All you wrote makes absolutely sense to me so I think I screwed up something else. Again: Thank you very much for your script and your fast reaction!

@novo-redeunt
Copy link
Author

novo-redeunt commented Dec 19, 2018

After some testing I ended up with following script working for me (SB2):

#!/bin/sh
#
# auto-rotate the screen and pointers
# copyright 2018 Don Bowman ([email protected])
# Licensed under Apache License, Version 2.0
#
monitor-sensor | awk '/Accelerometer orientation changed:/ { print $NF; fflush();}' | while read line
do
    # If we have external monitor connected, do not rotate
    nscreens=$(xrandr  | grep -c " connected")
    if [ $nscreens != 1 ]
    then
        line=normal
    fi

    # Set the actions to be taken for each possible orientation
    case "$line" in
        normal)
            xrandr --output eDP1 --rotate normal 
            xinput set-prop "ipts 045E:0021 Touchscreen" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            xinput set-prop "ipts 045E:0021 Mouse" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            xinput set-prop "ipts 045E:0021 UNKNOWN" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            xinput set-prop "ipts 045E:0021 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            xinput set-prop "ipts 045E:0021 Pen" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            xinput set-prop "Microsoft Surface Keyboard Touchpad" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
            qdbus org.kde.plasmashell /PlasmaShell evaluateScript "panels()[0].height = 62"            
            ;;
        bottom-up)
            xrandr --output eDP1 --rotate inverted
            xinput set-prop "ipts 045E:0021 Touchscreen" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
            xinput set-prop "ipts 045E:0021 Mouse" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
            xinput set-prop "ipts 045E:0021 UNKNOWN" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
            xinput set-prop "ipts 045E:0021 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
            xinput set-prop "ipts 045E:0021 Pen" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
            xinput set-prop "Microsoft Surface Keyboard Touchpad" --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1            
            qdbus org.kde.plasmashell /PlasmaShell evaluateScript "panels()[0].height = 62"
            ;;
        right-up)
            xrandr --output eDP1 --rotate right 
            xinput set-prop "ipts 045E:0021 Touchscreen" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
            xinput set-prop "ipts 045E:0021 Mouse" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
            xinput set-prop "ipts 045E:0021 UNKNOWN" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
            xinput set-prop "ipts 045E:0021 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
            xinput set-prop "ipts 045E:0021 Pen" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
            xinput set-prop "Microsoft Surface Keyboard Touchpad" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1            
            qdbus org.kde.plasmashell /PlasmaShell evaluateScript "panels()[0].height = 62"
            ;;
        left-up)
            xrandr --output eDP1 --rotate left
            xinput set-prop "ipts 045E:0021 Touchscreen" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
            xinput set-prop "ipts 045E:0021 Mouse" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
            xinput set-prop "ipts 045E:0021 UNKNOWN" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
            xinput set-prop "ipts 045E:0021 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
            xinput set-prop "ipts 045E:0021 Pen" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
            xinput set-prop "Microsoft Surface Keyboard Touchpad" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1            
            qdbus org.kde.plasmashell /PlasmaShell evaluateScript "panels()[0].height = 62"
            ;;
    esac
done
exit 0

Unfortunately I could not make use of your advanced scripting but maybe this is a good starting point to extend your script to cover my case. I have the impression that the --type=float option is an important piece of the puzzle.

The qdbus stuff solved my menu bar height problem. The height is being set to a certain value after each rotation. The height value used here is of course specific for me and maybe needs to be adjusted for other users.

I must mention here that pen input does not work if I rotate from normal to any other position (everything else works fine). If i turn from normal to bottom-up and back pen input works from this moment on in any position. This of course sounds like that some stupid error is hidden somewhere in my script but I was not able so far to figure out what I am doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants