implement swapping the position of both screens

closes #855
This commit is contained in:
RSDuck 2021-01-17 22:16:32 +01:00
parent 1d6cc3c6ef
commit d529b650c0
6 changed files with 26 additions and 4 deletions

View File

@ -120,7 +120,8 @@ void EnableCheats(bool enable);
// 2 = emphasize bottom screen // 2 = emphasize bottom screen
// * screenGap: size of the gap between the two screens // * screenGap: size of the gap between the two screens
// * integerScale: force screens to be scaled up at integer scaling factors // * integerScale: force screens to be scaled up at integer scaling factors
void SetupScreenLayout(int screenWidth, int screenHeight, int screenLayout, int rotation, int sizing, int screenGap, bool integerScale); // * screenSwap: whether to swap the position of both screens
void SetupScreenLayout(int screenWidth, int screenHeight, int screenLayout, int rotation, int sizing, int screenGap, bool integerScale, int swapScreens);
// get a 2x3 transform matrix for each screen // get a 2x3 transform matrix for each screen
// note: the transform assumes an origin point at the top left of the display, // note: the transform assumes an origin point at the top left of the display,

View File

@ -109,7 +109,7 @@ void M23_Transform(float* m, float& x, float& y)
} }
void SetupScreenLayout(int screenWidth, int screenHeight, int screenLayout, int rotation, int sizing, int screenGap, bool integerScale) void SetupScreenLayout(int screenWidth, int screenHeight, int screenLayout, int rotation, int sizing, int screenGap, bool integerScale, int swapScreens)
{ {
float refpoints[4][2] = float refpoints[4][2] =
{ {
@ -152,7 +152,7 @@ void SetupScreenLayout(int screenWidth, int screenHeight, int screenLayout, int
(((layout == 0 && (rotation % 2 == 0)) || (layout == 1 && (rotation % 2 == 1)) (((layout == 0 && (rotation % 2 == 0)) || (layout == 1 && (rotation % 2 == 1))
? 192.f : 256.f) ? 192.f : 256.f)
+ screenGap) / 2.f; + screenGap) / 2.f;
if (rotation == 1 || rotation == 2) if ((rotation == 1 || rotation == 2) ^ swapScreens)
offset *= -1.f; offset *= -1.f;
M23_Translate(TopScreenMtx, (idx==0)?-offset:0, (idx==1)?-offset:0); M23_Translate(TopScreenMtx, (idx==0)?-offset:0, (idx==1)?-offset:0);

View File

@ -39,6 +39,7 @@ int WindowMaximized;
int ScreenRotation; int ScreenRotation;
int ScreenGap; int ScreenGap;
int ScreenLayout; int ScreenLayout;
int ScreenSwap;
int ScreenSizing; int ScreenSizing;
int IntegerScaling; int IntegerScaling;
int ScreenFilter; int ScreenFilter;
@ -135,6 +136,7 @@ ConfigEntry PlatformConfigFile[] =
{"ScreenRotation", 0, &ScreenRotation, 0, NULL, 0}, {"ScreenRotation", 0, &ScreenRotation, 0, NULL, 0},
{"ScreenGap", 0, &ScreenGap, 0, NULL, 0}, {"ScreenGap", 0, &ScreenGap, 0, NULL, 0},
{"ScreenLayout", 0, &ScreenLayout, 0, NULL, 0}, {"ScreenLayout", 0, &ScreenLayout, 0, NULL, 0},
{"ScreenSwap", 0, &ScreenSwap, 0, NULL, 0},
{"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0},
{"IntegerScaling", 0, &IntegerScaling, 0, NULL, 0}, {"IntegerScaling", 0, &IntegerScaling, 0, NULL, 0},
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},

View File

@ -53,6 +53,7 @@ extern int WindowMaximized;
extern int ScreenRotation; extern int ScreenRotation;
extern int ScreenGap; extern int ScreenGap;
extern int ScreenLayout; extern int ScreenLayout;
extern int ScreenSwap;
extern int ScreenSizing; extern int ScreenSizing;
extern int IntegerScaling; extern int IntegerScaling;
extern int ScreenFilter; extern int ScreenFilter;

View File

@ -647,7 +647,8 @@ void ScreenHandler::screenSetupLayout(int w, int h)
Config::ScreenRotation, Config::ScreenRotation,
sizing, sizing,
Config::ScreenGap, Config::ScreenGap,
Config::IntegerScaling != 0); Config::IntegerScaling != 0,
Config::ScreenSwap != 0);
Frontend::GetScreenTransforms(screenMatrix[0], screenMatrix[1]); Frontend::GetScreenTransforms(screenMatrix[0], screenMatrix[1]);
} }
@ -1232,6 +1233,12 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
} }
connect(grpScreenLayout, &QActionGroup::triggered, this, &MainWindow::onChangeScreenLayout); connect(grpScreenLayout, &QActionGroup::triggered, this, &MainWindow::onChangeScreenLayout);
submenu->addSeparator();
actScreenSwap = submenu->addAction("Swap screens");
actScreenSwap->setCheckable(true);
connect(actScreenSwap, &QAction::triggered, this, &MainWindow::onChangeScreenSwap);
} }
{ {
QMenu* submenu = menu->addMenu("Screen sizing"); QMenu* submenu = menu->addMenu("Screen sizing");
@ -1315,6 +1322,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actScreenSizing[Config::ScreenSizing]->setChecked(true); actScreenSizing[Config::ScreenSizing]->setChecked(true);
actIntegerScaling->setChecked(Config::IntegerScaling != 0); actIntegerScaling->setChecked(Config::IntegerScaling != 0);
actScreenSwap->setChecked(Config::ScreenSwap != 0);
actScreenFiltering->setChecked(Config::ScreenFilter != 0); actScreenFiltering->setChecked(Config::ScreenFilter != 0);
actShowOSD->setChecked(Config::ShowOSD != 0); actShowOSD->setChecked(Config::ShowOSD != 0);
@ -2049,6 +2058,13 @@ void MainWindow::onChangeScreenLayout(QAction* act)
emit screenLayoutChange(); emit screenLayoutChange();
} }
void MainWindow::onChangeScreenSwap(bool checked)
{
Config::ScreenSwap = checked?1:0;
emit screenLayoutChange();
}
void MainWindow::onChangeScreenSizing(QAction* act) void MainWindow::onChangeScreenSizing(QAction* act)
{ {
int sizing = act->data().toInt(); int sizing = act->data().toInt();

View File

@ -222,6 +222,7 @@ private slots:
void onChangeScreenRotation(QAction* act); void onChangeScreenRotation(QAction* act);
void onChangeScreenGap(QAction* act); void onChangeScreenGap(QAction* act);
void onChangeScreenLayout(QAction* act); void onChangeScreenLayout(QAction* act);
void onChangeScreenSwap(bool checked);
void onChangeScreenSizing(QAction* act); void onChangeScreenSizing(QAction* act);
void onChangeIntegerScaling(bool checked); void onChangeIntegerScaling(bool checked);
void onChangeScreenFiltering(bool checked); void onChangeScreenFiltering(bool checked);
@ -279,6 +280,7 @@ public:
QAction* actScreenGap[6]; QAction* actScreenGap[6];
QActionGroup* grpScreenLayout; QActionGroup* grpScreenLayout;
QAction* actScreenLayout[3]; QAction* actScreenLayout[3];
QAction* actScreenSwap;
QActionGroup* grpScreenSizing; QActionGroup* grpScreenSizing;
QAction* actScreenSizing[4]; QAction* actScreenSizing[4];
QAction* actIntegerScaling; QAction* actIntegerScaling;