2012-12-13 16:38:33 +10:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 Sacha Refshauge
|
|
|
|
*
|
|
|
|
*/
|
2013-10-29 11:23:42 +10:00
|
|
|
// Qt 4.7+ / 5.0+ implementation of the framework.
|
2014-01-06 10:41:53 +10:00
|
|
|
// Currently supports: Symbian, Blackberry, Maemo/Meego, Linux, Windows, Mac OSX
|
2012-12-13 16:38:33 +10:00
|
|
|
|
2013-10-19 05:21:44 +10:00
|
|
|
#include <QApplication>
|
2012-12-13 16:38:33 +10:00
|
|
|
#include <QUrl>
|
2013-02-20 00:18:13 +10:00
|
|
|
#include <QDir>
|
2012-12-13 16:38:33 +10:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDesktopServices>
|
2013-10-19 05:21:44 +10:00
|
|
|
#include <QLocale>
|
2013-10-22 14:52:14 +10:00
|
|
|
#include <QThread>
|
2012-12-13 16:38:33 +10:00
|
|
|
|
|
|
|
#ifdef __SYMBIAN32__
|
2013-03-20 05:26:53 +10:00
|
|
|
#include <e32std.h>
|
2013-04-18 00:22:38 +10:00
|
|
|
#include <QSystemScreenSaver>
|
2013-10-27 05:32:31 +10:00
|
|
|
#include <QFeedbackHapticsEffect>
|
2013-10-26 17:20:08 +03:00
|
|
|
#include "SymbianMediaKeys.h"
|
2012-12-13 16:38:33 +10:00
|
|
|
#endif
|
2013-11-22 01:59:18 +01:00
|
|
|
#ifdef QT_HAS_SDL
|
|
|
|
#include "SDL/SDLJoystick.h"
|
|
|
|
#endif
|
2012-12-13 16:38:33 +10:00
|
|
|
#include "QtMain.h"
|
|
|
|
|
2014-02-12 11:54:53 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-04-01 22:42:40 +10:00
|
|
|
InputState* input_state;
|
|
|
|
|
2013-09-04 11:28:19 +02:00
|
|
|
std::string System_GetProperty(SystemProperty prop) {
|
|
|
|
switch (prop) {
|
|
|
|
case SYSPROP_NAME:
|
2013-08-18 17:28:34 +10:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-09-04 11:28:19 +02:00
|
|
|
return "Qt:Symbian";
|
2013-08-18 17:28:34 +10:00
|
|
|
#elif defined(BLACKBERRY)
|
2013-11-26 16:38:00 +10:00
|
|
|
return "Qt:Blackberry";
|
2013-08-18 17:28:34 +10:00
|
|
|
#elif defined(MEEGO_EDITION_HARMATTAN)
|
2013-09-04 11:28:19 +02:00
|
|
|
return "Qt:Meego";
|
2014-01-05 10:53:47 +10:00
|
|
|
#elif defined(MAEMO)
|
|
|
|
return "Qt:Maemo";
|
2013-10-20 05:03:31 +10:00
|
|
|
#elif defined(Q_OS_LINUX)
|
2013-09-04 11:28:19 +02:00
|
|
|
return "Qt:Linux";
|
2013-08-18 17:28:34 +10:00
|
|
|
#elif defined(_WIN32)
|
2013-09-04 11:28:19 +02:00
|
|
|
return "Qt:Windows";
|
2013-12-08 20:14:49 +10:00
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
return "Qt:Mac";
|
2013-08-18 17:28:34 +10:00
|
|
|
#else
|
2013-09-04 11:28:19 +02:00
|
|
|
return "Qt";
|
2013-08-18 17:28:34 +10:00
|
|
|
#endif
|
2013-10-17 18:41:00 +10:00
|
|
|
case SYSPROP_LANGREGION:
|
|
|
|
return QLocale::system().name().toStdString();
|
2013-09-04 11:28:19 +02:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
2013-08-18 17:28:34 +10:00
|
|
|
}
|
|
|
|
|
2013-12-04 18:12:57 +01:00
|
|
|
void System_SendMessage(const char *command, const char *parameter) {
|
2014-02-15 01:42:48 -08:00
|
|
|
if (!strcmp(command, "finish")) {
|
2014-05-15 17:47:33 +10:00
|
|
|
qApp->exit(0);
|
2014-02-15 01:42:48 -08:00
|
|
|
}
|
2013-12-04 18:12:57 +01:00
|
|
|
}
|
|
|
|
|
2014-02-15 01:46:47 -08:00
|
|
|
bool System_InputBoxGetString(const char *title, const char *defaultValue, char *outValue, size_t outLength)
|
2013-12-08 20:14:49 +10:00
|
|
|
{
|
|
|
|
QString text = emugl->InputBoxGetQString(QString(title), QString(defaultValue));
|
|
|
|
if (text.isEmpty())
|
|
|
|
return false;
|
|
|
|
strcpy(outValue, text.toStdString().c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-11 02:49:09 +10:00
|
|
|
void Vibrate(int length_ms) {
|
|
|
|
if (length_ms == -1 || length_ms == -3)
|
|
|
|
length_ms = 50;
|
|
|
|
else if (length_ms == -2)
|
|
|
|
length_ms = 25;
|
2013-10-27 05:32:31 +10:00
|
|
|
// Symbian only for now
|
|
|
|
#if defined(__SYMBIAN32__)
|
|
|
|
QFeedbackHapticsEffect effect;
|
2013-11-04 23:49:30 +10:00
|
|
|
effect.setIntensity(0.8);
|
2013-10-27 05:32:31 +10:00
|
|
|
effect.setDuration(length_ms);
|
|
|
|
effect.start();
|
2013-10-11 02:49:09 +10:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-13 16:38:33 +10:00
|
|
|
void LaunchBrowser(const char *url)
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
2012-12-13 17:05:12 +10:00
|
|
|
float CalculateDPIScale()
|
|
|
|
{
|
2013-04-07 00:34:46 +10:00
|
|
|
// Sane default rather than check DPI
|
2012-12-13 17:05:12 +10:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-03-20 05:26:53 +10:00
|
|
|
return 1.4f;
|
2013-12-08 20:14:49 +10:00
|
|
|
#elif defined(USING_GLES2)
|
2012-12-16 19:47:51 +10:00
|
|
|
return 1.2f;
|
2013-10-29 11:23:42 +10:00
|
|
|
#else
|
|
|
|
return 1.0f;
|
2012-12-13 17:05:12 +10:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-02-15 01:42:48 -08:00
|
|
|
static int mainInternal(QApplication &a)
|
|
|
|
{
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
emugl = new MainUI();
|
|
|
|
emugl->resize(pixel_xres, pixel_yres);
|
|
|
|
emugl->showFullScreen();
|
|
|
|
#endif
|
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
// Set RunFast hardware mode for VFPv2.
|
|
|
|
User::SetFloatingPointMode(EFpModeRunFast);
|
|
|
|
// Disable screensaver
|
|
|
|
QScopedPointer<QSystemScreenSaver> ssObject(new QSystemScreenSaver(emugl));
|
|
|
|
ssObject->setScreenSaverInhibit();
|
|
|
|
QScopedPointer<SymbianMediaKeys> mediakeys(new SymbianMediaKeys());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QScopedPointer<QThread> thread(new QThread);
|
|
|
|
QScopedPointer<MainAudio> audio(new MainAudio());
|
|
|
|
audio->moveToThread(thread.data());
|
|
|
|
QObject::connect(thread.data(), SIGNAL(started()), audio.data(), SLOT(run()));
|
|
|
|
thread->start();
|
|
|
|
|
|
|
|
#ifdef QT_HAS_SDL
|
|
|
|
SDLJoystick joy(true);
|
|
|
|
joy.startEventLoop();
|
|
|
|
#endif
|
|
|
|
int ret = a.exec();
|
|
|
|
thread->quit();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-22 01:59:18 +01:00
|
|
|
#ifndef QT_HAS_SDL
|
|
|
|
Q_DECL_EXPORT
|
|
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
2012-12-13 16:38:33 +10:00
|
|
|
{
|
2014-01-05 10:53:47 +10:00
|
|
|
#if defined(Q_OS_LINUX) && !defined(MAEMO)
|
2013-01-14 19:20:28 +10:00
|
|
|
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
|
|
|
|
#endif
|
2012-12-13 16:38:33 +10:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
QSize res = QApplication::desktop()->screenGeometry().size();
|
|
|
|
if (res.width() < res.height())
|
|
|
|
res.transpose();
|
|
|
|
pixel_xres = res.width();
|
|
|
|
pixel_yres = res.height();
|
2013-08-20 20:30:03 +10:00
|
|
|
g_dpi_scale = CalculateDPIScale();
|
|
|
|
dp_xres = (int)(pixel_xres * g_dpi_scale); dp_yres = (int)(pixel_yres * g_dpi_scale);
|
2012-12-13 17:05:12 +10:00
|
|
|
net::Init();
|
2012-12-13 16:38:33 +10:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-10-19 14:36:55 -07:00
|
|
|
const char *savegame_dir = "E:/PPSSPP/";
|
2013-10-19 22:36:04 -07:00
|
|
|
const char *assets_dir = "E:/PPSSPP/";
|
2012-12-23 17:47:52 +10:00
|
|
|
#elif defined(BLACKBERRY)
|
2013-10-19 14:36:55 -07:00
|
|
|
const char *savegame_dir = "/accounts/1000/shared/misc/";
|
|
|
|
const char *assets_dir = "app/native/assets/";
|
2014-01-05 10:53:47 +10:00
|
|
|
#elif defined(MEEGO_EDITION_HARMATTAN) || defined(MAEMO)
|
2013-10-19 14:36:55 -07:00
|
|
|
const char *savegame_dir = "/home/user/MyDocs/PPSSPP/";
|
|
|
|
const char *assets_dir = "/opt/PPSSPP/";
|
2013-01-11 23:00:33 +01:00
|
|
|
#else
|
2013-10-19 14:36:55 -07:00
|
|
|
const char *savegame_dir = "./";
|
|
|
|
const char *assets_dir = "./";
|
2012-12-13 16:38:33 +10:00
|
|
|
#endif
|
2013-07-08 10:04:20 +10:00
|
|
|
NativeInit(argc, (const char **)argv, savegame_dir, assets_dir, "BADCOFFEE");
|
2012-12-16 19:47:51 +10:00
|
|
|
|
2014-02-15 01:42:48 -08:00
|
|
|
int ret = mainInternal(a);
|
2012-12-16 19:47:51 +10:00
|
|
|
|
2012-12-13 16:38:33 +10:00
|
|
|
NativeShutdown();
|
|
|
|
net::Shutdown();
|
|
|
|
return ret;
|
|
|
|
}
|
2013-10-29 11:23:42 +10:00
|
|
|
|