hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.43k stars 2.19k forks source link

PPSSPPSDL: No way to rotate UI #16630

Open zack-huangzihan opened 1 year ago

zack-huangzihan commented 1 year ago

Game or games this happens in

games

What area of the game / PPSSPP

I use the source code to compile "ppssppsdl"

cmake -DUSE_SYSTEM_FFMPEG=OFF -DUSING_FBDEV=ON -DUSING_EGL=OFF -DUSING_GLES2=ON -DUSING_X11_VULKAN=OFF -DUSE_DISCORD=OFF -DARM64=ON -DMOBILE_DEVICE=ON ..

And then execute it

First of all, my screen is vertical, I need to rotate the ui, but I can't find some configuration items, how can I change it so that I can rotate the ui by 90 degrees? It rotates while running the game using the "&g_Config.iScreenRotation" , Using the rotation in the Settings screen, I can only rotate the game screen, not the ui screen.

What should happen

I want the ui to rotate 90 degrees: image

Logs

VulkanMayBeAvailable: Device allowed ('SDL:Linux') VulkanMayBeAvailable: Library loaded ('libvulkan.so') VulkanMayBeAvailable: Enumerating instance extensions VulkanMayBeAvailable: Instance extension count: 2 VulkanMaybeAvailable: Instance extension found: VK_EXT_debug_report (00000009) VulkanMaybeAvailable: Instance extension found: VK_EXT_debug_utils (00000002) Surface extension not found DEBUG: Vulkan is not available, not using Vulkan. xcb_connection_has_error() returned true Info: We compiled against SDL version 2.24.2 and we are linking against SDL version 2.24.2. :) ThreadManager::Init(compute threads: 8, all: 16) Pixels: 1080 x 1920 Virtual pixels: 1080 x 1920 arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'. xcb_connection_has_error() returned true loading control pad mappings from gamecontrollerdb.txt: SUCCESS!

Platform

Linux / BSD

Mobile phone model or graphics card

mali

PPSSPP version affected

latest

Last working version

No response

Graphics backend (3D API)

OpenGL / GLES

Checklist

hrydgard commented 1 year ago

Hm, does SDL have a way to query the desired rotation? It's true that we don't even try to set rotation with SDL right now, as I have no device where this is required.

Absolutely something we should support though.

zack-huangzihan commented 1 year ago

Hm, does SDL have a way to query the desired rotation? It's true that we don't even try to set rotation with SDL right now, as I have no device where this is required.

Absolutely something we should support though.

thank, But the ui of ppsspp seems to be written by sdl2, so none of you have tried rotating the ui?

hrydgard commented 1 year ago

No, the only devices I have that rotate are iOS and Android and we don't use SDL on any of those.

anr2me commented 1 year ago

This might help (SDL2 with screen rotation with PPSSPP as example) https://forum.odroid.com/viewtopic.php?t=38045 (seems to use modified SDL2 https://github.com/AreaScout/SDL/ )

zack-huangzihan commented 1 year ago

This might help (SDL2 with screen rotation with PPSSPP as example) https://forum.odroid.com/viewtopic.php?t=38045 (seems to use modified SDL2)

thanks

dhwz commented 1 year ago

@zack-huangzihan The above mentioned patches are outdated. But from your picture I see this is a rockchip device? So our patches should be the right ones for your device too. Just remember librga is required.

You might want to use our patches, these apply to the latest SDL2 version 2.26.1 https://github.com/AmberELEC/AmberELEC/tree/dev/packages/games/tools/SDL2/patches/rotation

zack-huangzihan commented 1 year ago

@zack-huangzihan The above mentioned patches are outdated. But from your picture I see this is a rockchip device? So our patches should be the right ones for your device too. Just remember librga is required.

You might want to use our patches, these apply to the latest SDL2 version 2.26.1 https://github.com/AmberELEC/AmberELEC/tree/dev/packages/games/tools/SDL2/patches/rotation

thanks, But there's one thing I don't understand:

My screen resolution is 720*1280,so, width is 720,high is 1280, But in this patch: rga_set_rect(&src_info.rect, 0, 0, frameHeight, frameWidth, l_frameHeight, frameWidth, RK_FORMAT_BGRA_8888);

"src_info" I understand the src buf, src buf width should be 720, high should be 1280, Why should the length and width be switched?

What's more, after I applied the patch you recommended above, the wrong image appeared on my screen, which seemed to be caused by the wrong setting of length and width.

I printed in my code "frameHeight" and "frameWidth" , the frameWidth=1080 frameHeight=1920 ,It's very strange...

zack-huangzihan commented 1 year ago

@zack-huangzihan The above mentioned patches are outdated. But from your picture I see this is a rockchip device? So our patches should be the right ones for your device too. Just remember librga is required.

You might want to use our patches, these apply to the latest SDL2 version 2.26.1 https://github.com/AmberELEC/AmberELEC/tree/dev/packages/games/tools/SDL2/patches/rotation

After my testing, I found that this patch only works in resolutions below 720*1280? Why is that??

dhwz commented 1 year ago

@zack-huangzihan that's odd because I'm using it on a device with 1920x1152 (1152x1920)

zack-huangzihan commented 1 year ago

@zack-huangzihan that's odd because I'm using it on a device with 1920x1152 (1152x1920)

And I didn't find any place to set the resolution on top of the software. 2ee783e6f3783821dac997e0269f095

zack-huangzihan commented 1 year ago

ok, Problem solved, both length and width should be aligned 32 bits

unknownbrackets commented 1 year ago

SDL patches aside, in theory would would just need a setting somewhere in options to rotate the UI on SDL devices, I suppose.

Could also be useful on desktops for people with monitors that can rotate (I know a number of people who use ultrawides rotated to portrait, but usually as a secondary screen.)

-[Unknown]

zack-huangzihan commented 1 year ago

SDL patches aside, in theory would would just need a setting somewhere in options to rotate the UI on SDL devices, I suppose.

Could also be useful on desktops for people with monitors that can rotate (I know a number of people who use ultrawides rotated to portrait, but usually as a secondary screen.)

-[Unknown]

so, Is there a plan to realize this problem at present?

hrydgard commented 1 year ago

Does SDL itself have any plans or existing API to query for the current rotation? We can add rotation compensation without too much trouble but gotta have a way to know what rotation is actually the correct one (I mean, I guess a command line parameter could work, but it's hardly ideal)

Or maybe that Display extension you added support for does? If so it would not be too hard to hook it up.

zack-huangzihan commented 1 year ago

In my understanding, the best way to rotate is to use sdl interface to do rotation, but unfortunately, As far as I know, sdl doesn't seem to provide such interface at present, of course, I can do rotation through the vulkan layer function, but this is not very standard,Previously I used a hardware on soc called "rga" to implant the sdl for rotation, but I don't think this is the best solution