forked from melonDS-emu/melonDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenLayout.h
104 lines (89 loc) · 3.46 KB
/
ScreenLayout.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
Copyright 2016-2024 melonDS team
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#ifndef SCREENLAYOUT_H
#define SCREENLAYOUT_H
enum ScreenLayoutType
{
screenLayout_Natural, // top screen above bottom screen always
screenLayout_Vertical,
screenLayout_Horizontal,
screenLayout_Hybrid,
screenLayout_MAX,
};
enum ScreenRotation
{
screenRot_0Deg,
screenRot_90Deg,
screenRot_180Deg,
screenRot_270Deg,
screenRot_MAX,
};
enum ScreenSizing
{
screenSizing_Even, // both screens get same size
screenSizing_EmphTop, // make top screen as big as possible, fit bottom screen in remaining space
screenSizing_EmphBot,
screenSizing_Auto, // not applied in SetupScreenLayout
screenSizing_TopOnly,
screenSizing_BotOnly,
screenSizing_MAX,
};
const int kMaxScreenTransforms = 3;
class ScreenLayout
{
public:
ScreenLayout();
~ScreenLayout() {}
// setup the display layout based on the provided display size and parameters
// * screenWidth/screenHeight: size of the host display
// * screenLayout: how the DS screens are laid out
// * rotation: angle at which the DS screens are presented
// * sizing: how the display size is shared between the two screens
// * screenGap: size of the gap between the two screens in pixels
// * integerScale: force screens to be scaled up at integer scaling factors
// * screenSwap: whether to swap the position of both screens
// * topAspect/botAspect: ratio by which to scale the top and bottom screen respectively
void Setup(int screenWidth, int screenHeight,
ScreenLayoutType screenLayout,
ScreenRotation rotation,
ScreenSizing sizing,
int screenGap,
bool integerScale,
bool swapScreens,
float topAspect, float botAspect);
// get a 2x3 transform matrix for each screen and whether it's a top or bottom screen
// note: the transform assumes an origin point at the top left of the display,
// X going right and Y going down
// for each screen the source coordinates should be (0,0) and (256,192)
// 'out' should point to an array of 6*MaxScreenTransforms floats
// 'kind' should point to an array of MaxScreenTransforms ints
// (0 = indicates top screen, 1 = bottom screen)
// returns the amount of screens
int GetScreenTransforms(float* out, int* kind);
// de-transform the provided host display coordinates to get coordinates
// on the bottom screen
bool GetTouchCoords(int& x, int& y, bool clamp);
private:
float TopScreenMtx[6];
float BotScreenMtx[6];
float HybScreenMtx[6];
float TouchMtx[6];
float HybTouchMtx[6];
bool TopEnable;
bool BotEnable;
bool HybEnable;
int HybScreen;
int HybPrevTouchScreen; // 0:unknown, 1:buttom screen, 2:hybrid screen
};
#endif // SCREENLAYOUT_H