Page 1 of 1

Landscape display with Android 8

Posted: Tue Jan 22, 2019 5:05 am
by v8dave
I've managed to rotate the display so that Android comes up in Landscape but the touch does not rotate. Touching the right centre of the display appears at the bottom centre.

I set the following property in /device/rockchip/rk3399/device.mk

ro.sf.hwrotation=90

It was 0 for portrait mode.

Anyone know how to get the touch to also rotate? It should have been automatic and taken care of by the OS but doesn't seem to be. On the Nano PC T3 Plus that I also use, this works fine.

Re: Landscape display with Android 8

Posted: Mon Jan 28, 2019 12:38 am
by shivaa
It's really weird that it's not automatic.
Have you tried a re-initialization?

________________________________________________________________________________________________
Pirate Bay YIFY RARBG

Re: Landscape display with Android 8

Posted: Mon Jan 28, 2019 1:50 am
by v8dave
It's a brand new installation using the SD card after I write this to the eMMC memory so it should work straight off.

I did find some info about an issue with this on older Android versions but you'd think that 8.1 would have the patch to fix this. Looking at the drivers, there is code to rotate the touch so not sure why it is not working here.

Re: Landscape display with Android 8

Posted: Thu Jan 31, 2019 7:53 am
by v8dave
I managed to fix this temporarily until I can work out how to do this without hard coding it.

I edited InputReader.cpp to hard code the display to landscape. I have no need for portrait at all.

I also managed to enable screen/sleep off without resorting to putting the device into debug mode but enabling the debugging.

Re: Landscape display with Android 8

Posted: Wed May 08, 2019 7:03 am
by Daitaro
Where did you find inputreader.cpp?

Thank you!

Re: Landscape display with Android 8

Posted: Wed May 08, 2019 7:08 am
by v8dave
Daitaro wrote:
Where did you find inputreader.cpp?


In the Android kernel source for the RK3399.

Do a search for it from the root of the source tree.

Re: Landscape display with Android 8

Posted: Wed May 08, 2019 9:00 am
by Daitaro
Yeah it took a while, but I did find it after remembering that feature.

Which line did you edit to hardcode landscape?

Re: Landscape display with Android 8

Posted: Wed May 08, 2019 9:26 am
by v8dave
Daitaro wrote:
Yeah it took a while, but I did find it after remembering that feature.

Which line did you edit to hardcode landscape?


It's in the actual Android framework but you already found it.

I added the following line of code after the comment TEST in 2 places.

Code starts at line 190

Code: Select all

static void rotateDelta(int32_t orientation, float* deltaX, float* deltaY) {
    float temp;
//
// TEST
//
    orientation = DISPLAY_ORIENTATION_90;

    switch (orientation) {
    case DISPLAY_ORIENTATION_90:
        temp = *deltaX;
        *deltaX = *deltaY;
        *deltaY = -temp;
        break;

    case DISPLAY_ORIENTATION_180:
        *deltaX = -*deltaX;
        *deltaY = -*deltaY;
        break;

    case DISPLAY_ORIENTATION_270:
        temp = *deltaX;
        *deltaX = -*deltaY;
        *deltaY = temp;
        break;
    }
}


Code starts at line 3754

Code: Select all

        if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
            // Convert rotated viewport to natural surface coordinates.
            int32_t naturalLogicalWidth, naturalLogicalHeight;
            int32_t naturalPhysicalWidth, naturalPhysicalHeight;
            int32_t naturalPhysicalLeft, naturalPhysicalTop;
            int32_t naturalDeviceWidth, naturalDeviceHeight;
//
// TEST
//
       mViewport.orientation = DISPLAY_ORIENTATION_90;

            switch (mViewport.orientation) {
            case DISPLAY_ORIENTATION_90:
                naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;

Re: Landscape display with Android 8

Posted: Thu May 09, 2019 8:46 am
by Tiemichael
@v8dave: Thank you for sharing!
I just modified my InputReader.cpp according to the previous post, and I see the screen as expected in Landscape mode, but the touchscreen being in Portrait mode.
In post #1 you mentioned the same issue, how did you resolve this?

Surprisingly without the changes in InputReader.cpp both Screen and Touscreen are 'aligned', but some applications seem to demand Portait-mode which does not fit to my screen.

Same like you, I only need Landscape mode.

Thanks!

Re: Landscape display with Android 8

Posted: Thu May 09, 2019 9:16 am
by v8dave
The changes to InputReader.cpp will fix the touch screen for Landscape more. It's not the ideal way but seems to be the only way I could get it to work in Landscape mode.

There is also a setting somewhere in the XML files that tell the system it should only offer Landscape mode only. Can't recall exactly where though.

Re: Landscape display with Android 8

Posted: Thu May 09, 2019 9:21 am
by Tiemichael
Thanks for the fast reply!
Will find it ...

Re: Landscape display with Android 8

Posted: Sun May 12, 2019 1:51 pm
by Tiemichael
I understand that changes in InputReader.cpp only influence the touch-screen.

The screen rotation can be disabled in 'frameworks/base/core/res/res/values/config.xml' by "<bool name="config_forceDefaultOrientation">true</bool>" **) and "<bool name="config_supportAutoRotation">false</bool>" .
**) : Flag indicating that this device does not rotate and will always remain in its default orientation. Activities that desire to run in a non-compatible orientation will be run from an emulated display within the physical display.

My device can also tell apps that it only supports landscape mode by deleting 'frameworks/native/data/etc/android.hardware.screen.portrait.xml'.

Now all my screens are in landscape mode, with the touchscreen aligned but for some apps and views of the contents is cut off:
(https://imgur.com/rOgFqBE)
The Notification bar seems to have the right width, app 2/3 of the screen are cut off, there is also no touch recorded at this 'black' area.

Any idea how to fix this?