ppsspp/base/QtMain.cpp

99 lines
2.4 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 Sacha Refshauge
*
*/
// Qt implementation of the framework.
// Currently supports: Symbian, Blackberry, Linux
#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));
}
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-10 10:25:10 +00:00
if (input->pad_buttons & (1<<14))
input->pad_lstick_y=1;
2013-01-10 10:25:10 +00:00
else if (input->pad_buttons & (1<<15))
input->pad_lstick_y=-1;
2013-01-10 10:25:10 +00:00
if (input->pad_buttons & (1<<16))
input->pad_lstick_x=-1;
2013-01-10 10:25:10 +00:00
else if (input->pad_buttons & (1<<17))
input->pad_lstick_x=1;
}
2012-12-13 07:05:12 +00:00
float CalculateDPIScale()
{
// Calculate DPI from TWIPS on Symbian
#ifdef __SYMBIAN32__
TSize sTwips = CEikonEnv::Static()->ScreenDevice()->SizeInTwips();
2012-12-13 07:05:12 +00:00
float dpi = sqrt((float)(pixel_xres*pixel_xres + pixel_yres*pixel_yres))
/ (sqrt((float)(sTwips.iHeight*sTwips.iHeight + sTwips.iWidth*sTwips.iWidth)) / KTwipsPerInch);
2012-12-13 07:05:12 +00:00
return dpi / 170.0f;
2012-12-16 09:47:51 +00:00
#else
// Sane default for Blackberry and Meego
2012-12-16 09:47:51 +00:00
return 1.2f;
2012-12-13 07:05:12 +00:00
#endif
}
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
QSize res = QApplication::desktop()->screenGeometry().size();
#ifdef USING_GLES2
if (res.width() < res.height())
res.transpose();
pixel_xres = res.width();
pixel_yres = res.height();
#else
// Set resolution to half of the monitor on desktop systems
pixel_xres = res.width() / 2;
pixel_yres = res.height() / 2;
#endif
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__
NativeInit(argc, (const char **)argv, "E:/PPSSPP/", "E:", "BADCOFFEE");
#elif defined(BLACKBERRY)
NativeInit(argc, (const char **)argv, "data/", "/tmp", "BADCOFFEE");
#else
NativeInit(argc, (const char **)argv, "./", "/tmp", "BADCOFFEE");
#endif
2012-12-13 07:05:12 +00:00
MainUI w(dpi_scale);
w.resize(pixel_xres, pixel_yres);
#ifdef USING_GLES2
w.showFullScreen();
#else
w.show();
#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;
}