mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 17:49:29 +01:00
Symbian support.
Add new Qt frontend. Can be used by any platform. Currently used by Symbian.
This commit is contained in:
1 parent
965c93411f
commit
aa8a1c7de0
2 files changed
+145
No files matched your search
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Sacha Refshauge
|
||||
*
|
||||
*/
|
||||
// Qt implementation of the framework.
|
||||
// Currently supports: Symbian
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QUrl>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#include <AknAppUi.h>
|
||||
#endif
|
||||
#include "QtMain.h"
|
||||
|
||||
void LaunchBrowser(const char *url)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
// Lock orientation to landscape on Symbian
|
||||
#ifdef __SYMBIAN32__
|
||||
QT_TRAP_THROWING(dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi())->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
|
||||
#endif
|
||||
net::Init();
|
||||
QSize res = QApplication::desktop()->screenGeometry().size();
|
||||
if (res.width() < res.height())
|
||||
res.transpose();
|
||||
pixel_xres = res.width();
|
||||
pixel_yres = res.height();
|
||||
// Calculate DPI from TWIPS on Symbian
|
||||
#ifdef __SYMBIAN32__
|
||||
TSize sizeTwips = CEikonEnv::Static()->ScreenDevice()->SizeInTwips();
|
||||
float dpi = sqrt((float)(pixel_xres*pixel_xres + pixel_yres*pixel_yres))
|
||||
/ (sqrt((float)(sizeTwips.iHeight*sizeTwips.iHeight + sizeTwips.iWidth*sizeTwips.iWidth)) / KTwipsPerInch);
|
||||
float dpi_scale = dpi / 170.0f;
|
||||
#endif
|
||||
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
|
||||
NativeInit(argc, (const char **)argv,
|
||||
#ifdef __SYMBIAN32__
|
||||
"E:/PPSSPP/", "E:", "BADCOFFEE");
|
||||
#else
|
||||
"./","/tmp","BADCOFFEE");
|
||||
#endif
|
||||
MainUI w;
|
||||
w.resize(pixel_xres, pixel_yres);
|
||||
w.showFullScreen();
|
||||
int ret = a.exec();
|
||||
NativeShutdown();
|
||||
net::Shutdown();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef SYMBIANMAIN_H
|
||||
#define SYMBIANMAIN_H
|
||||
|
||||
#include <QTouchEvent>
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <math.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "base/display.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/timeutil.h"
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include "file/zip_read.h"
|
||||
#include "input/input_state.h"
|
||||
#include "base/NativeApp.h"
|
||||
#include "net/resolve.h"
|
||||
#include "display.h"
|
||||
|
||||
class MainUI : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainUI(float scale, QWidget *parent = 0):
|
||||
QGLWidget(parent), dpi_scale(scale)
|
||||
{
|
||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
}
|
||||
~MainUI() {
|
||||
NativeShutdownGraphics();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e)
|
||||
{
|
||||
QList<QTouchEvent::TouchPoint> touchPoints;
|
||||
switch(e->type())
|
||||
{
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
touchPoints = static_cast<QTouchEvent *>(e)->touchPoints();
|
||||
foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) {
|
||||
switch (touchPoint.state()) {
|
||||
case Qt::TouchPointStationary:
|
||||
break;
|
||||
case Qt::TouchPointPressed:
|
||||
case Qt::TouchPointReleased:
|
||||
input_state.pointer_down[touchPoint.id()] = (touchPoint.state() == Qt::TouchPointPressed);
|
||||
case Qt::TouchPointMoved:
|
||||
input_state.pointer_x[touchPoint.id()] = touchPoint.pos().x() * dpi_scale;
|
||||
input_state.pointer_y[touchPoint.id()] = touchPoint.pos().y() * dpi_scale;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QWidget::event(e);
|
||||
}
|
||||
e->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
void initializeGL()
|
||||
{
|
||||
NativeInitGraphics();
|
||||
}
|
||||
|
||||
void paintGL()
|
||||
{
|
||||
UpdateInputState(&input_state);
|
||||
NativeUpdate(input_state);
|
||||
EndInputState(&input_state);
|
||||
NativeRender();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
private:
|
||||
InputState input_state;
|
||||
float dpi_scale;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user