shyzus / gnome-shell-extension-screen-autorotate

Enable screen rotation regardless of touch mode
GNU General Public License v3.0
33 stars 10 forks source link

Stylus digitizer input does not rotate #7

Closed Clewsy closed 1 year ago

Clewsy commented 1 year ago

Hello friend, I love your work.

I'm using your extension on a GPD-Pocket3 with Wayland (issue below is the same for Ubuntu and Pop_OS)..

I have implemented the following transformation matrix: ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 1, 0, 0

Screen rotation and touch input work great, however the stylus digitizer input does not rotate. In the default landscape orientation, the stylus input remains offset by 90 degrees. It remains in this orientation despite physical screen orientation - i.e. digitizer input works only if the screen is rotated right.

Is stylus digitizer input rotation something that your extension could also rotate?

shyzus commented 1 year ago

Hi @Clewsy, it sounds fairly interesting. I also use a stylus/pen however not on the GPD-Pocket3 just on a 2-in-1 laptop that has pen support. Could you perhaps elaborate or better yet show with a screen shot what kind of problem you are experiencing. Is it that the cursor icon the stylus has doesn't rotate with the screen or that when attempting to use the stylus it starts drawing on the wrong location or not at all?

Clewsy commented 1 year ago

Hi @shyzus thanks for the response!

I'm not sure that a screenshot would be useful as you would be unable to see my stylus, but I will try to better explain what I'm experiencing.

Right now I'm working in laptop mode so the screen is in the standard landscape position. Touching with my fingers works fine.

However if I hover the stylus so that I can see the cursor, it appears in the wrong location. For example, if I hover at the bottom left corner, the cursor appears in the top left. Hover at the top left and the cursor appears at the top right. Always 90 degrees out from actual pen location.

Moving the pen has the same 90 degree offset effect. Moving the pen upwards causes the cursor to move right. Moving the pen right causes the cursor to move down.

If I rotate the screen to the right, the display orients correctly and the stylus works as expected. However if I rotate left, the offset is 180 degrees instead of 90.

The pen works, just in the wrong location!

I found an ask ubuntu query from a couple of years ago describing the same problem.

I'm happy to provide any additional info that might help you or point me in the right direction.

shyzus commented 1 year ago

Ahhh I understand the problem. I have seen this before on other devices as well. This unfortunately is not something I could resolve trough this extension. However libinput should be able to help you at the very least troubleshoot it as this is the equivalent of xinput but for Wayland.

Please see this page for reporting bugs.

This extension doesn't directly modify the cursor or any of the input devices that are connected. It only interacts with the orientation of the display based on the info from the built-in accelerometer.

I hope this will help you with your stylus issues.

Clewsy commented 1 year ago

Hello again @shyzus, thanks so much for your guidance.

Turns out I found a fix thanks to a reddit post. In case anyone has a similar issue, I'll leave some instructions below. The key part of the fix is to set a kernel parameter to correct the default screen orientation at boot (this also fixed the decryption login orientation which was at 90 degrees before logging in). The kernel parameter did require that I change the tranformation matrix in etc/udev/hwdb.b/61-sensor-local.hwdb (differs to what I listed above).

Get screen rotation working (including touch and stylus inputs).

  1. Implement kernel parameter (video=DSI-1:panel_orientation=right_side_up) to correct default orientation at boot. Note, pop_os uses kernelstub for implementing kernel parameter changes. The following may not work for other distros (e.g. Ubuntu uses grub) but the parameter itself should be the same.
    $ sudo kernelstub -a video=DSI-1:panel_orientation=right_side_up

    Note: verify the presence of the kernel parameter under options.

    $ cat /boot/efi/loader/entries/Pop_OS-current.conf
  2. Configure a translation matrix to correct orientation based on accellerometer sensor. Create this file /etc/udev/hwdb.b/61-sensor-local.hwdb with the following:
    sensor:modalias:*
    ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1

    Enable the above with the following command:

    $ sudo systemd-hwdb update && \
    sudo udevadm trigger -v -p DEVNAME=/dev/iio:device0  && \
    sudo systemctl restart iio-sensor-proxy.service
  3. Install the Screen Rotate gnome-shell extension:
    $ git clone https://github.com/shyzus/gnome-shell-extension-screen-autorotate.git
    $ cd gnome-shell-extension-screen-autorotate
    $ cp -r screen-rotate@shyzus.github.io ~/.local/share/gnome-shell/extensions

    Enable the extension (need to log out then back in again to load new extension).

    $ gnome-extensions enable screen-rotate@shyzus.github.io
Clewsy commented 1 year ago

I will close the issue now since it was not related to your great extension. Thanks!

shyzus commented 1 year ago

@Clewsy thank you for your response and detailed steps on reaching a resolution for the issue you encountered. I have pinned this issue to make it easier for others with a similar issue to find this in the future.

shyzus commented 1 year ago

@Clewsy Sorry to bother you but I would like to confirm whether the third step of your solution uses the correct extension. At the moment it is the kosmospredanie repo. Not this current repo. I would like to confirm whether this is the correct extension repo that worked for you or not in the interest to avoid confusion for future readers.

Clewsy commented 1 year ago

Whoops! I copied an old version of my notes. Fixed now, thanks @shyzus.

Also fixed a mistake with the kernel parameter.