Files
ppsspp/Common/System/Display.h
Henrik RydgårdandClaude Opus 5.5 5fbd134a7d Android: Show the game on a second display, with the controls on the phone
A presentation display (HDMI or USB-C video out, some wireless displays,
or the simulated ones in Developer options) gets a Presentation with a
SurfaceView, whose surface becomes a Game output, when the backend is
Vulkan. Otherwise Android keeps mirroring.

The surface mustn't be touched after surfaceDestroyed returns, so the
output is removed with the new Native_RemoveOutputAndWait(), which
returns once the render thread has let go of it (or right away if the
graphics are down). The UI drawn on an output now leaves out the main
swapchain's pre-rotation, as the game already did.

"In menus on %1" gets the device name from Settings.Global.DEVICE_NAME.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 22:31:07 +02:00

69 lines
2.1 KiB
C++

#pragma once
#include <string_view>
#include "Common/Math/lin/matrix4x4.h"
#include "Common/GPU/MiscTypes.h"
#include "Common/Math/geom2d.h"
// This is meant to be a framework for handling DPI scaling etc.
// For now, it just consists of these ugly globals.
// On some platforms (currently only Windows UWP) we need to manually rotate
// our rendered output to match the display. Use these to do so.
enum class DisplayRotation {
ROTATE_0 = 0,
ROTATE_90,
ROTATE_180,
ROTATE_270,
};
struct DisplayProperties {
// Display resolution in true pixels.
int pixel_xres;
int pixel_yres;
// Display resolution in virtual ("display") pixels
int dp_xres;
int dp_yres;
float dpi_scale_x = 1.0f;
float dpi_scale_y = 1.0f;
// Size of a physical pixel in dps
float pixel_in_dps_x = 1.0f;
float pixel_in_dps_y = 1.0f;
// If DPI is overridden (like in small window mode), this is still the original DPI scale factor.
float dpi_scale_real_x = 1.0f;
float dpi_scale_real_y = 1.0f;
float display_hz = 60.0f;
DisplayRotation rotation;
Lin::Matrix4x4 rot_matrix;
DisplayProperties();
void Print();
DeviceOrientation GetDeviceOrientation() const;
// Returns true if the dimensions changed.
// The first three parameters can take -1 to signify "unchanged".
bool Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale_x, float new_scale_y, float customScale);
};
extern DisplayProperties g_display;
template<class T>
struct DisplayRect {
T x, y, w, h;
};
void RotateRectToDisplay(DisplayRect<float> &rect, float rtWidth, float rtHeight);
void RotateRectToDisplay(DisplayRect<int> &rect, int rtWidth, int rtHeight);
// rotateToDisplay applies the primary display's rotation (Android's Vulkan pre-rotation). Not for other outputs.
Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention, bool rotateToDisplay = true);
// Take this and run through translation. Returns "Portrait", "Landscape" or later "Square" (the latter being the square shape you get when you open a foldable phone).
std::string_view DeviceOrientationToString(DeviceOrientation orientation);