2012-12-13 06:38:33 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2012-12-13 06:38:33 +00:00
|
|
|
|
2013-10-18 19:21:44 +00:00
|
|
|
#include <QApplication>
|
2012-12-13 06:38:33 +00:00
|
|
|
#include <QUrl>
|
2013-02-19 14:18:13 +00:00
|
|
|
#include <QDir>
|
2012-12-13 06:38:33 +00:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDesktopServices>
|
2013-10-18 19:21:44 +00:00
|
|
|
#include <QLocale>
|
2012-12-13 06:38:33 +00:00
|
|
|
|
|
|
|
#ifdef __SYMBIAN32__
|
2013-03-19 19:26:53 +00:00
|
|
|
#include <e32std.h>
|
2013-04-17 14:22:38 +00:00
|
|
|
#include <QSystemScreenSaver>
|
2013-10-10 16:49:09 +00:00
|
|
|
#include <hwrmvibra.h>
|
2012-12-13 06:38:33 +00:00
|
|
|
#endif
|
|
|
|
#include "QtMain.h"
|
|
|
|
|
2013-04-01 12:42:40 +00:00
|
|
|
InputState* input_state;
|
|
|
|
|
2013-09-04 09:28:19 +00:00
|
|
|
std::string System_GetProperty(SystemProperty prop) {
|
|
|
|
switch (prop) {
|
|
|
|
case SYSPROP_NAME:
|
2013-08-18 07:28:34 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt:Symbian";
|
2013-08-18 07:28:34 +00:00
|
|
|
#elif defined(BLACKBERRY)
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt:Blackberry10";
|
2013-08-18 07:28:34 +00:00
|
|
|
#elif defined(MEEGO_EDITION_HARMATTAN)
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt:Meego";
|
2013-10-19 19:03:31 +00:00
|
|
|
#elif defined(Q_OS_LINUX)
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt:Linux";
|
2013-08-18 07:28:34 +00:00
|
|
|
#elif defined(_WIN32)
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt:Windows";
|
2013-08-18 07:28:34 +00:00
|
|
|
#else
|
2013-09-04 09:28:19 +00:00
|
|
|
return "Qt";
|
2013-08-18 07:28:34 +00:00
|
|
|
#endif
|
2013-10-17 08:41:00 +00:00
|
|
|
case SYSPROP_LANGREGION:
|
|
|
|
return QLocale::system().name().toStdString();
|
2013-09-04 09:28:19 +00:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
2013-08-18 07:28:34 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 16:49:09 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
CHWRMVibra* vibra;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void Vibrate(int length_ms) {
|
|
|
|
if (length_ms == -1 || length_ms == -3)
|
|
|
|
length_ms = 50;
|
|
|
|
else if (length_ms == -2)
|
|
|
|
length_ms = 25;
|
|
|
|
// Qt 4.8 does not have any cross-platform Vibrate. Symbian-only for now.
|
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
CHWRMVibra::TVibraModeState iState = vibra->VibraSettings();
|
|
|
|
CHWRMVibra::TVibraStatus iStatus = vibra->VibraStatus();
|
|
|
|
// User has not enabled vibration in settings.
|
|
|
|
if(iState != CHWRMVibra::EVibraModeON)
|
|
|
|
return;
|
|
|
|
if(iStatus != CHWRMVibra::EVibraStatusStopped)
|
|
|
|
vibra->StopVibraL();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
vibra->StartVibraL(length_ms, 20);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-13 06:38:33 +00:00
|
|
|
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-04-06 14:34:46 +00:00
|
|
|
// Sane default rather than check DPI
|
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
|
|
|
|
}
|
|
|
|
|
2013-04-13 17:00:43 +00:00
|
|
|
Q_DECL_EXPORT int main(int argc, char *argv[])
|
2012-12-13 06:38:33 +00:00
|
|
|
{
|
2013-10-19 19:03:31 +00:00
|
|
|
#ifdef Q_OS_LINUX
|
2013-01-14 09:20:28 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
|
|
|
|
#endif
|
2012-12-13 06:38:33 +00: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-10-19 19:03:31 +00:00
|
|
|
#if defined(Q_OS_LINUX) && !defined(ARM)
|
2013-09-09 22:48:08 +00:00
|
|
|
g_dpi_scale = 1.0f;
|
|
|
|
#else
|
2013-08-20 10:30:03 +00:00
|
|
|
g_dpi_scale = CalculateDPIScale();
|
2013-09-09 22:48:08 +00:00
|
|
|
#endif
|
2013-08-20 10:30:03 +00:00
|
|
|
dp_xres = (int)(pixel_xres * g_dpi_scale); dp_yres = (int)(pixel_yres * g_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/";
|
2013-07-08 00:04:20 +00:00
|
|
|
char* assets_dir = "E:/PPSSPP/";
|
2012-12-23 07:47:52 +00:00
|
|
|
#elif defined(BLACKBERRY)
|
2013-07-08 00:04:20 +00:00
|
|
|
char* savegame_dir = "/accounts/1000/shared/misc/";
|
|
|
|
char* assets_dir = "app/native/assets/";
|
2013-04-11 16:50:14 +00:00
|
|
|
#elif defined(MEEGO_EDITION_HARMATTAN)
|
|
|
|
char* savegame_dir = "/home/user/MyDocs/PPSSPP/";
|
2013-04-14 07:01:39 +00:00
|
|
|
QDir myDocs("/home/user/MyDocs/");
|
|
|
|
if (!myDocs.exists("PPSSPP"))
|
|
|
|
myDocs.mkdir("PPSSPP");
|
2013-07-08 00:04:20 +00:00
|
|
|
char* assets_dir = "/opt/PPSSPP/";
|
2013-01-11 22:00:33 +00:00
|
|
|
#else
|
2013-02-20 03:07:19 +00:00
|
|
|
char* savegame_dir = "./";
|
2013-07-08 00:04:20 +00:00
|
|
|
char* assets_dir = "./";
|
2012-12-13 06:38:33 +00:00
|
|
|
#endif
|
2013-07-08 00:04:20 +00:00
|
|
|
NativeInit(argc, (const char **)argv, savegame_dir, assets_dir, "BADCOFFEE");
|
2013-01-10 08:06:11 +00:00
|
|
|
|
2013-10-19 19:03:31 +00:00
|
|
|
#if !defined(Q_OS_LINUX) || defined(ARM)
|
2013-08-20 10:30:03 +00:00
|
|
|
MainUI w;
|
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
|
2013-04-21 06:36:05 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
// Set RunFast hardware mode for VFPv2.
|
|
|
|
User::SetFloatingPointMode(EFpModeRunFast);
|
|
|
|
// Disable screensaver
|
|
|
|
QSystemScreenSaver *ssObject = new QSystemScreenSaver(&w);
|
|
|
|
ssObject->setScreenSaverInhibit();
|
2013-10-10 16:49:09 +00:00
|
|
|
// Start vibration service
|
|
|
|
vibra = CHWRMVibra::NewL();
|
2013-04-21 06:36:05 +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;
|
2013-10-10 16:49:09 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
delete vibra;
|
|
|
|
#endif
|
2012-12-13 06:38:33 +00:00
|
|
|
NativeShutdown();
|
|
|
|
net::Shutdown();
|
|
|
|
return ret;
|
|
|
|
}
|