diff options
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r-- | src/frontend/qt_sdl/PlatformConfig.cpp | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/PlatformConfig.h | 2 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 110 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.h | 15 |
4 files changed, 103 insertions, 28 deletions
diff --git a/src/frontend/qt_sdl/PlatformConfig.cpp b/src/frontend/qt_sdl/PlatformConfig.cpp index 0f67b9a..ffab9fb 100644 --- a/src/frontend/qt_sdl/PlatformConfig.cpp +++ b/src/frontend/qt_sdl/PlatformConfig.cpp @@ -42,6 +42,8 @@ int ScreenLayout; int ScreenSwap; int ScreenSizing; int IntegerScaling; +int ScreenAspectTop; +int ScreenAspectBot; int ScreenFilter; int ScreenUseGL; @@ -146,6 +148,8 @@ ConfigEntry PlatformConfigFile[] = {"ScreenSwap", 0, &ScreenSwap, 0, NULL, 0}, {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, {"IntegerScaling", 0, &IntegerScaling, 0, NULL, 0}, + {"ScreenAspectTop",0, &ScreenAspectTop,0, NULL, 0}, + {"ScreenAspectBot",0, &ScreenAspectBot,0, NULL, 0}, {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, {"ScreenUseGL", 0, &ScreenUseGL, 0, NULL, 0}, diff --git a/src/frontend/qt_sdl/PlatformConfig.h b/src/frontend/qt_sdl/PlatformConfig.h index bf5fc60..02230ab 100644 --- a/src/frontend/qt_sdl/PlatformConfig.h +++ b/src/frontend/qt_sdl/PlatformConfig.h @@ -56,6 +56,8 @@ extern int ScreenGap; extern int ScreenLayout; extern int ScreenSwap; extern int ScreenSizing; +extern int ScreenAspectTop; +extern int ScreenAspectBot; extern int IntegerScaling; extern int ScreenFilter; diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index baa4716..cc5ef6e 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -646,15 +646,25 @@ void ScreenHandler::screenSetupLayout(int w, int h) int sizing = Config::ScreenSizing; if (sizing == 3) sizing = autoScreenSizing; + float aspectRatios[] = + { + 1.f, + (16.f/9)/(4.f/3), + (21.f/9)/(4.f/3), + ((float)w/h)/(4.f/3) + }; + Frontend::SetupScreenLayout(w, h, Config::ScreenLayout, Config::ScreenRotation, sizing, Config::ScreenGap, Config::IntegerScaling != 0, - Config::ScreenSwap != 0); + Config::ScreenSwap != 0, + aspectRatios[Config::ScreenAspectTop], + aspectRatios[Config::ScreenAspectBot]); - Frontend::GetScreenTransforms(screenMatrix[0], screenMatrix[1]); + numScreens = Frontend::GetScreenTransforms(screenMatrix[0], screenKind); } QSize ScreenHandler::screenGetMinSize() @@ -779,19 +789,16 @@ void ScreenPanelNative::setupScreenLayout() { int w = width(); int h = height(); - float* mtx; screenSetupLayout(w, h); - mtx = screenMatrix[0]; - screenTrans[0].setMatrix(mtx[0], mtx[1], 0.f, - mtx[2], mtx[3], 0.f, - mtx[4], mtx[5], 1.f); - - mtx = screenMatrix[1]; - screenTrans[1].setMatrix(mtx[0], mtx[1], 0.f, - mtx[2], mtx[3], 0.f, - mtx[4], mtx[5], 1.f); + for (int i = 0; i < numScreens; i++) + { + float* mtx = screenMatrix[i]; + screenTrans[i].setMatrix(mtx[0], mtx[1], 0.f, + mtx[2], mtx[3], 0.f, + mtx[4], mtx[5], 1.f); + } } void ScreenPanelNative::paintEvent(QPaintEvent* event) @@ -811,11 +818,11 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event) QRect screenrc(0, 0, 256, 192); - painter.setTransform(screenTrans[0]); - painter.drawImage(screenrc, screen[0]); - - painter.setTransform(screenTrans[1]); - painter.drawImage(screenrc, screen[1]); + for (int i = 0; i < numScreens; i++) + { + painter.setTransform(screenTrans[i]); + painter.drawImage(screenrc, screen[screenKind[i]]); + } OSD::Update(nullptr); OSD::DrawNative(painter); @@ -1002,11 +1009,11 @@ void ScreenPanelGL::paintGL() GLint transloc = screenShader->uniformLocation("uTransform"); - glUniformMatrix2x3fv(transloc, 1, GL_TRUE, screenMatrix[0]); - glDrawArrays(GL_TRIANGLES, 0, 2*3); - - glUniformMatrix2x3fv(transloc, 1, GL_TRUE, screenMatrix[1]); - glDrawArrays(GL_TRIANGLES, 2*3, 2*3); + for (int i = 0; i < numScreens; i++) + { + glUniformMatrix2x3fv(transloc, 1, GL_TRUE, screenMatrix[i]); + glDrawArrays(GL_TRIANGLES, screenKind[i] == 0 ? 0 : 2*3, 2*3); + } screenShader->release(); @@ -1272,9 +1279,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) QMenu* submenu = menu->addMenu("Screen sizing"); grpScreenSizing = new QActionGroup(submenu); - const char* screensizing[] = {"Even", "Emphasize top", "Emphasize bottom", "Auto"}; + const char* screensizing[] = {"Even", "Emphasize top", "Emphasize bottom", "Auto", "Top only", "Bottom only"}; - for (int i = 0; i < 4; i++) + for (int i = 0; i < 6; i++) { actScreenSizing[i] = submenu->addAction(QString(screensizing[i])); actScreenSizing[i]->setActionGroup(grpScreenSizing); @@ -1290,6 +1297,38 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) actIntegerScaling->setCheckable(true); connect(actIntegerScaling, &QAction::triggered, this, &MainWindow::onChangeIntegerScaling); } + { + QMenu* submenu = menu->addMenu("Aspect ratio"); + grpScreenAspectTop = new QActionGroup(submenu); + + const char* aspectRatiosTop[] = {"Top 4:3 (native)", "Top 16:9", "Top 21:9", "Top window"}; + + for (int i = 0; i < 4; i++) + { + actScreenAspectTop[i] = submenu->addAction(QString(aspectRatiosTop[i])); + actScreenAspectTop[i]->setActionGroup(grpScreenAspectTop); + actScreenAspectTop[i]->setData(QVariant(i)); + actScreenAspectTop[i]->setCheckable(true); + } + + connect(grpScreenAspectTop, &QActionGroup::triggered, this, &MainWindow::onChangeScreenAspectTop); + + submenu->addSeparator(); + + grpScreenAspectBot = new QActionGroup(submenu); + + const char* aspectRatiosBot[] = {"Bottom 4:3 (native)", "Bottom 16:9", "Bottom 21:9", "Bottom window"}; + + for (int i = 0; i < 4; i++) + { + actScreenAspectBot[i] = submenu->addAction(QString(aspectRatiosBot[i])); + actScreenAspectBot[i]->setActionGroup(grpScreenAspectBot); + actScreenAspectBot[i]->setData(QVariant(i)); + actScreenAspectBot[i]->setCheckable(true); + } + + connect(grpScreenAspectBot, &QActionGroup::triggered, this, &MainWindow::onChangeScreenAspectBot); + } actScreenFiltering = menu->addAction("Screen filtering"); actScreenFiltering->setCheckable(true); @@ -1352,6 +1391,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) actScreenSwap->setChecked(Config::ScreenSwap != 0); + actScreenAspectTop[Config::ScreenAspectTop]->setChecked(true); + actScreenAspectBot[Config::ScreenAspectBot]->setChecked(true); + actScreenFiltering->setChecked(Config::ScreenFilter != 0); actShowOSD->setChecked(Config::ShowOSD != 0); @@ -2264,6 +2306,22 @@ void MainWindow::onChangeScreenSizing(QAction* act) emit screenLayoutChange(); } +void MainWindow::onChangeScreenAspectTop(QAction* act) +{ + int aspect = act->data().toInt(); + Config::ScreenAspectTop = aspect; + + emit screenLayoutChange(); +} + +void MainWindow::onChangeScreenAspectBot(QAction* act) +{ + int aspect = act->data().toInt(); + Config::ScreenAspectBot = aspect; + + emit screenLayoutChange(); +} + void MainWindow::onChangeIntegerScaling(bool checked) { Config::IntegerScaling = checked?1:0; @@ -2444,7 +2502,9 @@ int main(int argc, char** argv) SANITIZE(Config::ScreenRotation, 0, 3); SANITIZE(Config::ScreenGap, 0, 500); SANITIZE(Config::ScreenLayout, 0, 2); - SANITIZE(Config::ScreenSizing, 0, 3); + SANITIZE(Config::ScreenSizing, 0, 5); + SANITIZE(Config::ScreenAspectTop, 0, 4); + SANITIZE(Config::ScreenAspectBot, 0, 4); #undef SANITIZE QSurfaceFormat format; diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index ec7bd74..a79c245 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -34,6 +34,7 @@ #include <QOpenGLFunctions_3_2_Core> #include <QOpenGLShaderProgram> +#include "FrontendUtil.h" class EmuThread : public QThread { @@ -105,7 +106,9 @@ protected: void screenOnMouseRelease(QMouseEvent* event); void screenOnMouseMove(QMouseEvent* event); - float screenMatrix[2][6]; + float screenMatrix[Frontend::MaxScreenTransforms][6]; + int screenKind[Frontend::MaxScreenTransforms]; + int numScreens; bool touching; @@ -137,7 +140,7 @@ private: void setupScreenLayout(); QImage screen[2]; - QTransform screenTrans[2]; + QTransform screenTrans[Frontend::MaxScreenTransforms]; }; @@ -237,6 +240,8 @@ private slots: void onChangeScreenLayout(QAction* act); void onChangeScreenSwap(bool checked); void onChangeScreenSizing(QAction* act); + void onChangeScreenAspectTop(QAction* act); + void onChangeScreenAspectBot(QAction* act); void onChangeIntegerScaling(bool checked); void onChangeScreenFiltering(bool checked); void onChangeShowOSD(bool checked); @@ -303,8 +308,12 @@ public: QAction* actScreenLayout[3]; QAction* actScreenSwap; QActionGroup* grpScreenSizing; - QAction* actScreenSizing[4]; + QAction* actScreenSizing[6]; QAction* actIntegerScaling; + QActionGroup* grpScreenAspectTop; + QAction* actScreenAspectTop[4]; + QActionGroup* grpScreenAspectBot; + QAction* actScreenAspectBot[4]; QAction* actScreenFiltering; QAction* actShowOSD; QAction* actLimitFramerate; |