Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.14k stars 10.5k forks source link

screen rotation #489

Open dude105tanki opened 5 years ago

dude105tanki commented 5 years ago

I have a bug on my LG device where the screen on my pc is rotated 90 degrees but still functions as if the touches were not. it is similar to this issue, https://github.com/Genymobile/scrcpy/issues/186

but the reference there doesn't help me. sdfgsdfgsdfg

how do i fix this bug and/or rotate the screen on my pc

rom1v commented 5 years ago

Also similar to https://github.com/Genymobile/scrcpy/issues/481.

dude105tanki commented 5 years ago

kinda more like this, I suck at explaining things anyways. https://youtu.be/kVBgShD9E_w

codeandcreate commented 5 years ago

This also happens to the planet computers gemini.

syockit commented 4 years ago

On Planet Computers Gemini PDA, when I modify the DisplayManager wrapper to use appWidth/Height instead of logicalWidth/Height, the correct orientation is displayed for some apps (including the home screen), but still fails for full screen application (games). The logical dimensions are 2160x1080, while the reported appWidth/Height are 2032x1080. The cropped 128 pixels correspond to the android buttons which appear to the right.

Playing around with contentRect width, I found that the correction orientation is displayed when width is ≤ 2038 pixels. There's probably something on the android side that rotates the display when requesting content above certain dimensions.

Currently, as a workaround for viewing full screen games, I hardcoded the rotation set by setDisplayProjection to 3 (taking hint from Ihttps://github.com/Genymobile/scrcpy/pull/1151).

rom1v commented 4 years ago

It seems scrcpy is incapible of rotating the screen properly when it detects a rotation with or without the keybind.

In fact, it does... when the device/ROM correctly notifies the rotation event:

https://github.com/Genymobile/scrcpy/blob/master/server/src/main/java/com/genymobile/scrcpy/Device.java#L30

rom1v commented 4 years ago

Clearly something wrong with the code if it can't switch between Portrait and Landscape modes interchangeably without stretching or squashing the screen proportions and render it correctly.

Of course something is wrong. To handle this properly, scrcpy restart the video encoding when the device notifies the rotation change (because the video dimension change).

It works pretty well. But some devices (apparently) do not call the onRotationChange callback, so in that case the video encoding is not restarted, and stretch the new screen surface to the old dimensions on the device side.

Because the device is correctly notifies for the rotation event.

Are you sure?

Could you add a log here:

https://github.com/Genymobile/scrcpy/blob/1a9429f3c73e319f108211a66ad57b8c2c9a60aa/server/src/main/java/com/genymobile/scrcpy/Device.java#L57-L64

and verify that it is printed when you rotate your device?