diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index 969786c072..853ac6b08a 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "Core/MIPS/MIPSDebugInterface.h" @@ -13,12 +12,10 @@ #include "Core/SaveState.h" #include "Core/System.h" #include "base/display.h" -#include "base/NKCodeFromQt.h" #include "GPU/GPUInterface.h" #include "UI/GamepadEmu.h" #include "QtHost.h" -#include "qtemugl.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -31,23 +28,18 @@ MainWindow::MainWindow(QWidget *parent) : displaylistWindow(0) { host = new QtHost(this); - emugl = new QtEmuGL(); + emugl = new MainUI(this); setCentralWidget(emugl); - emugl->init(&input_state); createMenus(); updateMenus(); - int zoom = g_Config.iInternalResolution; - if (zoom < 1) zoom = 1; - if (zoom > 4) zoom = 4; - SetZoom(zoom); + SetZoom(g_Config.iInternalResolution); SetGameTitle(fileToStart); - startTimer(16); - - QObject::connect(emugl, SIGNAL(doubleClick()), this, SLOT(fullscrAct()) ); + QObject::connect(emugl, SIGNAL(doubleClick()), this, SLOT(fullscrAct())); + QObject::connect(emugl, SIGNAL(newFrame()), this, SLOT(newFrame())); } void MainWindow::ShowMemory(u32 addr) @@ -62,10 +54,8 @@ inline float clamp1(float x) { return x; } -void MainWindow::timerEvent(QTimerEvent *) +void MainWindow::newFrame() { - emugl->updateGL(); - if (lastUIState != globalUIState) { lastUIState = globalUIState; if (lastUIState == UISTATE_INGAME && g_Config.bFullScreen && !QApplication::overrideCursor() && !g_Config.bShowTouchControls) @@ -119,21 +109,6 @@ void MainWindow::updateMenus() emit updateMenu(); } -void MainWindow::closeEvent(QCloseEvent *) -{ - exitAct(); -} - -void MainWindow::keyPressEvent(QKeyEvent *e) -{ - NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(e->key())->second, KEY_DOWN)); -} - -void MainWindow::keyReleaseEvent(QKeyEvent *e) -{ - NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(e->key())->second, KEY_UP)); -} - /* SLOTS */ void MainWindow::Boot() { @@ -377,17 +352,6 @@ void MainWindow::fullscrAct() showFullScreen(); - int width = (int) QApplication::desktop()->screenGeometry().width(); - int height = (int) QApplication::desktop()->screenGeometry().height(); - PSP_CoreParameter().pixelWidth = width; - PSP_CoreParameter().pixelHeight = height; - PSP_CoreParameter().outputWidth = width; - PSP_CoreParameter().outputHeight = height; - - pixel_xres = width; - pixel_yres = height; - dp_xres = pixel_xres; - dp_yres = pixel_yres; if (gpu) gpu->Resized(); InitPadLayout(); @@ -411,21 +375,13 @@ void MainWindow::aboutAct() void MainWindow::SetZoom(int zoom) { if (isFullScreen()) fullscrAct(); + if (zoom < 1) zoom = 1; + if (zoom > 4) zoom = 4; g_Config.iInternalResolution = zoom; - pixel_xres = 480 * zoom; - pixel_yres = 272 * zoom; - dp_xres = pixel_xres; - dp_yres = pixel_yres; - - emugl->setFixedSize(pixel_xres, pixel_yres); + emugl->setFixedSize(480 * zoom, 272 * zoom); setFixedSize(sizeHint()); - PSP_CoreParameter().pixelWidth = pixel_xres; - PSP_CoreParameter().pixelHeight = pixel_yres; - PSP_CoreParameter().outputWidth = pixel_xres; - PSP_CoreParameter().outputHeight = pixel_yres; - if (gpu) gpu->Resized(); } diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h index 7c105f8b76..3167f5a25a 100644 --- a/Qt/mainwindow.h +++ b/Qt/mainwindow.h @@ -9,11 +9,11 @@ #include "ConsoleListener.h" #include "Core/Core.h" #include "Core/Config.h" -#include "input/input_state.h" #include "debugger_disasm.h" #include "debugger_memory.h" #include "debugger_memorytex.h" #include "debugger_displaylist.h" +#include "base/QtMain.h" class QtEmuGL; class MenuAction; @@ -35,12 +35,10 @@ public: void ShowMemory(u32 addr); void updateMenus(); + void newFrame(); protected: - void closeEvent(QCloseEvent *); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); - void timerEvent(QTimerEvent *); + void closeEvent(QCloseEvent *) { exitAct(); } signals: void retranslate(); @@ -134,7 +132,7 @@ private: QTranslator translator; QString currentLanguage; - QtEmuGL *emugl; + MainUI *emugl; CoreState nextState; InputState input_state; GlobalUIState lastUIState; diff --git a/Qt/qkeyedit.cpp b/Qt/qkeyedit.cpp deleted file mode 100644 index b01f0863ef..0000000000 --- a/Qt/qkeyedit.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "qkeyedit.h" -#include -#include - -QKeyEdit::QKeyEdit(QWidget *parent) : - QLineEdit(parent) -{ -} - -bool QKeyEdit::event(QEvent *e) -{ - if(e->type() == QEvent::KeyPress) - { - QKeyEvent *ke = static_cast(e); - QKeySequence seq(ke->key()); - setText(seq.toString()); - return true; - } - - return QLineEdit::event(e); -} diff --git a/Qt/qkeyedit.h b/Qt/qkeyedit.h deleted file mode 100644 index 1beb9ac352..0000000000 --- a/Qt/qkeyedit.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QKEYEDIT_H -#define QKEYEDIT_H - -#include - -class QKeyEdit : public QLineEdit -{ - Q_OBJECT -public: - explicit QKeyEdit(QWidget *parent = 0); - -protected: - bool event(QEvent *e); -signals: - -public slots: - -}; - -#endif // QKEYEDIT_H diff --git a/Qt/qtemugl.cpp b/Qt/qtemugl.cpp deleted file mode 100644 index 90d3581624..0000000000 --- a/Qt/qtemugl.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "qtemugl.h" - -#include - -#include "base/display.h" -#include "base/timeutil.h" -#include "Core/Config.h" - -QtEmuGL::QtEmuGL(QWidget *parent) : - QGLWidget(parent) -{ -} - -void QtEmuGL::init(InputState *inputState) -{ - input_state = inputState; -} - -void QtEmuGL::initializeGL() -{ -#ifndef USING_GLES2 - glewInit(); -#endif - NativeInitGraphics(); -} -void QtEmuGL::paintGL() -{ - NativeUpdate(*input_state); - NativeRender(); - EndInputState(input_state); - time_update(); -} - -void QtEmuGL::mouseDoubleClickEvent(QMouseEvent *) -{ - if (!g_Config.bShowTouchControls || globalUIState != UISTATE_INGAME) - emit doubleClick(); -} - -void QtEmuGL::mousePressEvent(QMouseEvent *e) -{ - TouchInput input; - input_state->pointer_down[0] = true; - input_state->pointer_x[0] = e->x(); - input_state->pointer_y[0] = e->y(); - - input.x = e->x(); - input.y = e->y(); - input.flags = TOUCH_DOWN; - input.id = 0; - NativeTouch(input); -} - -void QtEmuGL::mouseReleaseEvent(QMouseEvent *e) -{ - TouchInput input; - input_state->pointer_down[0] = false; - - input.x = e->x(); - input.y = e->y(); - input.flags = TOUCH_UP; - input.id = 0; - NativeTouch(input); -} - -void QtEmuGL::mouseMoveEvent(QMouseEvent *e) -{ - TouchInput input; - input.x = e->x(); - input.y = e->y(); - input.flags = TOUCH_MOVE; - input.id = 0; - NativeTouch(input); -} - -void QtEmuGL::wheelEvent(QWheelEvent *e) -{ - KeyInput key; - key.deviceId = DEVICE_ID_MOUSE; - key.keyCode = e->delta()<0 ? NKCODE_EXT_MOUSEWHEEL_DOWN : NKCODE_EXT_MOUSEWHEEL_UP; - key.flags = KEY_DOWN; - NativeKey(key); -} diff --git a/Qt/qtemugl.h b/Qt/qtemugl.h deleted file mode 100644 index fede4a1459..0000000000 --- a/Qt/qtemugl.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef QTEMUGL_H -#define QTEMUGL_H - -#include "gfx_es2/glsl_program.h" -#include "input/input_state.h" -#include -#include "QtHost.h" - -class QtEmuGL : public QGLWidget -{ - Q_OBJECT -public: - explicit QtEmuGL(QWidget *parent = nullptr); - ~QtEmuGL() { - NativeShutdownGraphics(); - } - - void init(InputState* inputState); -signals: - void doubleClick(); -protected: - void initializeGL(); - void paintGL(); - void mouseDoubleClickEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void wheelEvent(QWheelEvent *e); - -private: - InputState *input_state; -}; - -#endif // QTEMUGL_H diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index ada5e9e4e9..288c68130e 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -486,7 +486,7 @@ void MainScreen::CreateViews() { logos->Add(new ImageView(I_LOGO, IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0)))); rightColumnItems->Add(logos); rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))))->SetSmall(true); -#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MEEGO_EDITION_HARMATTAN)) +#if defined(_WIN32) || defined(USING_QT_UI) rightColumnItems->Add(new Choice(m->T("Load","Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile); #endif rightColumnItems->Add(new Choice(m->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings); @@ -582,7 +582,7 @@ void MainScreen::update(InputState &input) { } UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { -#if defined(USING_QT_UI) && !defined(MEEGO_EDITION_HARMATTAN) +#if defined(USING_QT_UI) QString fileName = QFileDialog::getOpenFileName(NULL, "Load ROM", g_Config.currentDirectory.c_str(), "PSP ROMs (*.iso *.cso *.pbp *.elf)"); if (QFile::exists(fileName)) { QDir newPath; diff --git a/native b/native index 1d28b00536..17ddae23cc 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 1d28b00536a7366e00ce900547e01a9d4b2914ee +Subproject commit 17ddae23cceda928777cf253101dc78a6da502d4