Power & Source of Big Ideas

Landscape display with Android 8

Moderators: chensy, FATechsupport

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.
It's really weird that it's not automatic.
Have you tried a re-initialization?

______________________________________________
Appvalley TutuApp Tweakbox
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.
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.
Where did you find inputreader.cpp?

Thank you!
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.
Yeah it took a while, but I did find it after remembering that feature.

Which line did you edit to hardcode landscape?
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;
@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!
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.
Thanks for the fast reply!
Will find it ...
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?

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 2865 on Sun Nov 10, 2019 5:27 am

Users browsing this forum: No registered users and 2 guests