2012-12-13 06:38:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 Sacha Refshauge
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
// Qt implementation of the framework.
|
2012-12-23 07:47:52 +00:00
|
|
|
// Currently supports: Symbian, Blackberry, Linux
|
2012-12-13 06:38:33 +00:00
|
|
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QUrl>
|
2013-02-19 14:18:13 +00:00
|
|
|
#include <QDir>
|
2012-12-13 06:38:33 +00:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
|
|
|
|
#ifdef __SYMBIAN32__
|
2013-03-19 19:26:53 +00:00
|
|
|
#include <e32std.h>
|
2012-12-13 06:38:33 +00:00
|
|
|
#endif
|
|
|
|
#include "QtMain.h"
|
|
|
|
|
|
|
|
void LaunchBrowser(const char *url)
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
2013-01-10 08:06:11 +00:00
|
|
|
void SimulateGamepad(InputState *input) {
|
|
|
|
input->pad_lstick_x = 0;
|
|
|
|
input->pad_lstick_y = 0;
|
|
|
|
input->pad_rstick_x = 0;
|
|
|
|
input->pad_rstick_y = 0;
|
|
|
|
|
2013-01-11 03:41:21 +00:00
|
|
|
if (input->pad_buttons & PAD_BUTTON_JOY_UP)
|
2013-01-10 08:06:11 +00:00
|
|
|
input->pad_lstick_y=1;
|
2013-01-11 03:41:21 +00:00
|
|
|
else if (input->pad_buttons & PAD_BUTTON_JOY_DOWN)
|
2013-01-10 08:06:11 +00:00
|
|
|
input->pad_lstick_y=-1;
|
2013-01-11 03:41:21 +00:00
|
|
|
if (input->pad_buttons & PAD_BUTTON_JOY_LEFT)
|
2013-01-10 08:06:11 +00:00
|
|
|
input->pad_lstick_x=-1;
|
2013-01-11 03:41:21 +00:00
|
|
|
else if (input->pad_buttons & PAD_BUTTON_JOY_RIGHT)
|
2013-01-10 08:06:11 +00:00
|
|
|
input->pad_lstick_x=1;
|
|
|
|
}
|
|
|
|
|
2012-12-13 07:05:12 +00:00
|
|
|
float CalculateDPIScale()
|
|
|
|
{
|
2013-02-10 14:42:12 +00:00
|
|
|
// Sane default for Symbian, Blackberry and Meego
|
2012-12-13 07:05:12 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-03-19 19:26:53 +00:00
|
|
|
return 1.4f;
|
2012-12-16 09:47:51 +00:00
|
|
|
#else
|
|
|
|
return 1.2f;
|
2012-12-13 07:05:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-13 06:38:33 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2013-01-14 09:20:28 +00:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
|
|
|
|
#endif
|
2012-12-13 06:38:33 +00:00
|
|
|
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);
|
2012-12-13 06:38:33 +00:00
|
|
|
#endif
|
|
|
|
QSize res = QApplication::desktop()->screenGeometry().size();
|
|
|
|
if (res.width() < res.height())
|
|
|
|
res.transpose();
|
|
|
|
pixel_xres = res.width();
|
|
|
|
pixel_yres = res.height();
|
2013-02-12 19:11:56 +00:00
|
|
|
|
2012-12-13 07:05:12 +00:00
|
|
|
float dpi_scale = CalculateDPIScale();
|
2012-12-13 06:38:33 +00:00
|
|
|
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
|
2012-12-13 07:05:12 +00:00
|
|
|
net::Init();
|
2012-12-13 06:38:33 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-02-20 03:07:19 +00:00
|
|
|
char* savegame_dir = "E:/PPSSPP/";
|
2012-12-23 07:47:52 +00:00
|
|
|
#elif defined(BLACKBERRY)
|
2013-02-20 03:07:19 +00:00
|
|
|
char* savegame_dir = "data/";
|
2013-01-11 22:00:33 +00:00
|
|
|
#else
|
2013-02-20 03:07:19 +00:00
|
|
|
char* savegame_dir = "./";
|
2012-12-13 06:38:33 +00:00
|
|
|
#endif
|
2013-02-20 03:07:19 +00:00
|
|
|
NativeInit(argc, (const char **)argv, savegame_dir, QDir::tempPath().toStdString().c_str(), "BADCOFFEE");
|
2013-01-10 08:06:11 +00:00
|
|
|
|
2013-03-19 22:49:50 +00:00
|
|
|
#ifndef Q_WS_X11
|
2012-12-13 07:05:12 +00:00
|
|
|
MainUI w(dpi_scale);
|
2013-03-19 19:26:53 +00:00
|
|
|
w.setAttribute(Qt::WA_LockLandscapeOrientation);
|
2012-12-13 06:38:33 +00:00
|
|
|
w.resize(pixel_xres, pixel_yres);
|
|
|
|
w.showFullScreen();
|
2013-01-10 08:06:11 +00:00
|
|
|
#endif
|
2012-12-16 09:47:51 +00:00
|
|
|
|
|
|
|
MainAudio *audio = new MainAudio();
|
|
|
|
|
2012-12-13 06:38:33 +00:00
|
|
|
int ret = a.exec();
|
2012-12-16 09:47:51 +00:00
|
|
|
delete audio;
|
2012-12-13 06:38:33 +00:00
|
|
|
NativeShutdown();
|
|
|
|
net::Shutdown();
|
|
|
|
return ret;
|
|
|
|
}
|