Screen rotation, 2-in-1-Laptop, how to calibrate pen & touch?

Hi all there :slight_smile:

I am using a Lenovo IdeaPad Flex 5, a 2-in-1 laptop with a touchsreen and active pen support (Kernel 5.11.1, KDE Plasma 5.21).

I am able to rotate the screen via command line or settings. The iio-sensor is newly active in kernel 5.11.1 :slight_smile: , but does not report changes in rotation :frowning:, but this is OT here.

Now I am wondering, how to synchronize the pen- as well as the touch-input when rotating the screen: If I change the screen rotation via the monitor settings-menu, I have to rotate the pen input via “input devices → graphic tablet → rotate 90° clockwise”. But then, the screen-touch input is still not calibrated and moves the pointer laterally, when I move with the finger up- or downwards.

I found some scripts, addressing the screen rotation and mouse-calibration on the net.

But nothing addresses all at once: screen rotation, pen-/tablet-input, touch-input and maybe also the touch pad input.

Does anyone have a source of information, how to combine the rotation of screen and input devices at once?

Thanks :slight_smile:
Peer

1 Like

+1 for this topic

I would also like to be able to use the kded-rotation-git package in Manjaro to be able to auto-rotate the screen . Any chance of that ?

I’m very new to Manjaro and loving it at the moment. Thank you all very much

Same here!

hy
since i had a working solution i might share it with you :slight_smile:

For this you need iio-sensor-proxy and x but then you are good to go.
The list of devices may need to be changed by you. There are also scripts that support any device but these seem to have some bugs most times (atleas for me).

#!/bin/sh

DISPLAY=:0
export DISPLAY

devices=("Wacom HID 5201 Pen stylus" "Wacom HID 5201 Pen eraser" "Wacom HID 5201 Finger touch")

rotate_cursor() {
    for p in "${devices[@]}";
    do
        xinput set-prop "$p" "Coordinate Transformation Matrix" "$@"
        #echo '''"xinput set-prop '"$p"' "Coordinate Transformation Matrix" "$@""'''
    done
    sleep 1s
    for p in "${devices[@]}";
    do
        xinput --map-to-output "$p" "$MAIN_SCREEN"
        #echo '''xinput --map-to-output '"$p"' '"$MAIN_SCREEN"' '''
    done
}

MAIN_SCREEN=eDP-1
echo "$MAIN_SCREEN"
monitor-sensor | while read -r line
do
    line="${line##*: }"
    echo "$line"
    sleep 1s
    # Set the actions to be taken for each possible orientation
    case "$line" in
        normal)
            xrandr --output "$MAIN_SCREEN" --rotate normal
            rotate_cursor 1 0 0 0 1 0 0 0 1
            ;;
        bottom-up)
            xrandr --output "$MAIN_SCREEN" --rotate inverted
            rotate_cursor -1 0 1 0 -1 1 0 0 1
            ;; 
        right-up)
            xrandr --output "$MAIN_SCREEN" --rotate right
            rotate_cursor 0 1 0 -1 0 1 0 0 1
            ;;
        left-up)
            xrandr --output "$MAIN_SCREEN" --rotate left
            rotate_cursor 0 -1 1 1 0 0 0 0 1
            ;;
    esac
done
exit 0

Another thing you may want to consider when working on a 2in1 is to use a display keyboard like “onboard” this can be started when you turn the display 180deg. For this you can use the keyboard shortkut which disables the mouse pad since its executed when you turn the display.
For that i use this script…
but keep in mind the keypress may differ for your maschine

#!/bin/sh

line2=""
line3=""

xinput test-xi2 --root 3 | while read -r line
do  
    if [[ $line == *"detail: 201" ]]; then
        if [[ $line3 == *"RawKeyPress"* ]]; then
            onboard &
            #echo "start onboard"
        fi
        
    fi
    if [[ $line == *"detail: 200" ]]; then
        if [[ $line3 == *"RawKeyPress"* ]]; then
            killall onboard
            #echo "start onboard"
        fi
        
    fi    
    line3=$line2
    line2=$line
    
done
exit 0

also when working with the active pen 2 (which has a button at the top) the top button is normaly not supported. Therefor the following script allows to use the top button to start applications or whatever you like…

#!/bin/sh

DISPLAY=:0
export DISPLAY

SERVICE="xournalpp"


udevadm monitor | while read -r line
do
    if [[ $line == "KERNEL"*"add"*"hci0:3585"*"bluetooth"* ]]; then
        if pgrep -x "$SERVICE" >/dev/null
        then
            #xournal  is running wannt to open the sidebar
            xte "key F12"
            
        else
            #xournal not running open it now
            sudo -u felix_j xournalpp &>/dev/null &
        fi
        sudo -u felix_j xinput --map-to-output 11 eDP-1
        sudo -u felix_j xinput --map-to-output 12 eDP-1
        sudo -u felix_j xinput --map-to-output 15 eDP-1
    fi
done 
exit 0

the sudo statements at the bottom map my inputs(touch and pen) to the laptop display such that when i have multiple displays attached i can simply press the active pen button and all inputs (from touch and pen) are correctly on the laptop display.

Right now i have some problems with the iio-sensor-proxy which i cant resolve but since these scripts worked before i would guess they still do if the iio-sensor has proper output !

Edit: with the newest verison of iio-proxy it works so use these as u please :slight_smile:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.