ppsspp/base/QtMain.cpp

99 lines
2.3 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 Sacha Refshauge
*
*/
2013-04-06 14:34:46 +00:00
// Qt 4.7 implementation of the framework.
// Currently supports: Symbian, Blackberry, Meego, Linux, Windows
#include <QtGui/QApplication>
#include <QUrl>
2013-02-19 14:18:13 +00:00
#include <QDir>
#include <QDesktopWidget>
#include <QDesktopServices>
#ifdef __SYMBIAN32__
#include <e32std.h>
#endif
#include "QtMain.h"
2013-04-01 12:42:40 +00:00
InputState* input_state;
void LaunchBrowser(const char *url)
{
QDesktopServices::openUrl(QUrl(url));
}
void SimulateGamepad(InputState *input) {
input->pad_lstick_x = 0;
input->pad_lstick_y = 0;
input->pad_rstick_x = 0;
input->pad_rstick_y = 0;
if (input->pad_buttons & PAD_BUTTON_JOY_UP)
input->pad_lstick_y=1;
else if (input->pad_buttons & PAD_BUTTON_JOY_DOWN)
input->pad_lstick_y=-1;
if (input->pad_buttons & PAD_BUTTON_JOY_LEFT)
input->pad_lstick_x=-1;
else if (input->pad_buttons & PAD_BUTTON_JOY_RIGHT)
input->pad_lstick_x=1;
}
2012-12-13 07:05:12 +00:00
float CalculateDPIScale()
{
2013-04-06 14:34:46 +00:00
// Sane default rather than check DPI
2012-12-13 07:05:12 +00:00
#ifdef __SYMBIAN32__
return 1.4f;
2012-12-16 09:47:51 +00:00
#else
return 1.2f;
2012-12-13 07:05:12 +00:00
#endif
}
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#ifdef Q_WS_X11
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
#endif
QApplication a(argc, argv);
#ifdef __SYMBIAN32__
2013-02-20 03:07:19 +00:00
// Set RunFast hardware mode for VFPv2. Denormalised values are treated as 0. NaN used for all NaN situations.
User::SetFloatingPointMode(EFpModeRunFast);
#endif
QSize res = QApplication::desktop()->screenGeometry().size();
if (res.width() < res.height())
res.transpose();
pixel_xres = res.width();
pixel_yres = res.height();
2012-12-13 07:05:12 +00:00
float dpi_scale = CalculateDPIScale();
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
2012-12-13 07:05:12 +00:00
net::Init();
#ifdef __SYMBIAN32__
2013-02-20 03:07:19 +00:00
char* savegame_dir = "E:/PPSSPP/";
#elif defined(BLACKBERRY)
2013-02-20 03:07:19 +00:00
char* savegame_dir = "data/";
2013-04-11 16:50:14 +00:00
#elif defined(MEEGO_EDITION_HARMATTAN)
char* savegame_dir = "/home/user/MyDocs/PPSSPP/";
QDir myDocs("/home/user/MyDocs/");
if (!myDocs.exists("PPSSPP"))
myDocs.mkdir("PPSSPP");
#else
2013-02-20 03:07:19 +00:00
char* savegame_dir = "./";
#endif
2013-02-20 03:07:19 +00:00
NativeInit(argc, (const char **)argv, savegame_dir, QDir::tempPath().toStdString().c_str(), "BADCOFFEE");
2013-04-11 16:50:14 +00:00
#if !defined(Q_WS_X11) || defined(ARM)
2012-12-13 07:05:12 +00:00
MainUI w(dpi_scale);
w.resize(pixel_xres, pixel_yres);
w.showFullScreen();
#endif
2012-12-16 09:47:51 +00:00
MainAudio *audio = new MainAudio();
int ret = a.exec();
2012-12-16 09:47:51 +00:00
delete audio;
NativeShutdown();
net::Shutdown();
return ret;
}