mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Qt Desktop: Use the existing mobile GL widget instead of duplicating the work.
This commit is contained in:
parent
be9c4b14c4
commit
f1d234e2a7
@ -5,7 +5,6 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1,21 +0,0 @@
|
||||
#include "qkeyedit.h"
|
||||
#include <QKeySequence>
|
||||
#include <QKeyEvent>
|
||||
|
||||
QKeyEdit::QKeyEdit(QWidget *parent) :
|
||||
QLineEdit(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool QKeyEdit::event(QEvent *e)
|
||||
{
|
||||
if(e->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
|
||||
QKeySequence seq(ke->key());
|
||||
setText(seq.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
return QLineEdit::event(e);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#ifndef QKEYEDIT_H
|
||||
#define QKEYEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QKeyEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QKeyEdit(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // QKEYEDIT_H
|
@ -1,83 +0,0 @@
|
||||
#include "qtemugl.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#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);
|
||||
}
|
34
Qt/qtemugl.h
34
Qt/qtemugl.h
@ -1,34 +0,0 @@
|
||||
#ifndef QTEMUGL_H
|
||||
#define QTEMUGL_H
|
||||
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include "input/input_state.h"
|
||||
#include <QGLWidget>
|
||||
#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
|
@ -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;
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 1d28b00536a7366e00ce900547e01a9d4b2914ee
|
||||
Subproject commit 17ddae23cceda928777cf253101dc78a6da502d4
|
Loading…
Reference in New Issue
Block a user