mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-29 10:09:13 +02:00
Merge pull request #29 from Xele02/qtwindow
Update native for Qt Window
This commit is contained in:
@@ -61,6 +61,7 @@ void NativeRender();
|
||||
// of num_samples.
|
||||
// This function may be called from a totally separate thread from
|
||||
// the rest of the game, so be careful with synchronization.
|
||||
void NativeSetMixer(void* mix);
|
||||
void NativeMix(short *audio, int num_samples);
|
||||
|
||||
// Called when it's time to shutdown. After this has been called,
|
||||
|
||||
+35
-1
@@ -15,6 +15,16 @@
|
||||
#endif
|
||||
#include "QtMain.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "qtapp.h"
|
||||
#ifdef Q_WS_X11
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
MainWindow* qMW;
|
||||
#endif
|
||||
|
||||
void LaunchBrowser(const char *url)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
@@ -52,11 +62,23 @@ float CalculateDPIScale()
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef LINUX
|
||||
#ifdef Q_WS_X11
|
||||
XInitThreads();
|
||||
#endif
|
||||
#endif
|
||||
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
|
||||
#ifdef LINUX
|
||||
pixel_xres = 480;
|
||||
pixel_yres = 272;
|
||||
|
||||
float dpi_scale = 1;
|
||||
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
|
||||
#else
|
||||
QSize res = QApplication::desktop()->screenGeometry().size();
|
||||
#ifdef USING_GLES2
|
||||
if (res.width() < res.height())
|
||||
@@ -70,21 +92,33 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
float dpi_scale = CalculateDPIScale();
|
||||
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
|
||||
#endif
|
||||
|
||||
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
|
||||
#elif !defined(LINUX)
|
||||
NativeInit(argc, (const char **)argv, "./", "/tmp", "BADCOFFEE");
|
||||
#else
|
||||
MainWindow mainWindow;
|
||||
qMW = &mainWindow;
|
||||
mainWindow.show();
|
||||
mainWindow.Create(argc, (const char **)argv, "./", "/tmp", "BADCOFFEE");
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#else
|
||||
MainUI w(dpi_scale);
|
||||
w.resize(pixel_xres, pixel_yres);
|
||||
#ifdef USING_GLES2
|
||||
w.showFullScreen();
|
||||
#else
|
||||
w.show();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
MainAudio *audio = new MainAudio();
|
||||
|
||||
+10
-2
@@ -5,6 +5,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include <QGLWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QAudioOutput>
|
||||
#include <QAudioFormat>
|
||||
@@ -88,7 +89,7 @@ protected:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
input_state.pointer_down[0] = (e->type() == QEvent::MouseButtonPress);
|
||||
@@ -161,16 +162,23 @@ public:
|
||||
output = new QAudioOutput(fmt);
|
||||
output->setNotifyInterval(1000*AUDIO_SAMPLES / AUDIO_FREQ);
|
||||
output->setBufferSize(mixlen);
|
||||
this->connect(output, SIGNAL(notify()), this, SLOT(writeData()));
|
||||
feed = output->start();
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(writeData()));
|
||||
timer->start(1000*AUDIO_SAMPLES / AUDIO_FREQ);
|
||||
|
||||
}
|
||||
~MainAudio() {
|
||||
feed->close();
|
||||
delete feed;
|
||||
output->stop();
|
||||
delete output;
|
||||
free(mixbuf);
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
||||
void writeData() {
|
||||
memset(mixbuf, 0, mixlen);
|
||||
NativeMix((short *)mixbuf, mixlen / 4);
|
||||
|
||||
+5
-3
@@ -115,7 +115,7 @@ public:
|
||||
#ifdef _WIN32
|
||||
SetEvent(event_);
|
||||
#else
|
||||
pthread_cond_signal(&event_);
|
||||
pthread_cond_signal(&event_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -129,7 +129,9 @@ public:
|
||||
ResetEvent(event_); // necessary?
|
||||
// mtx.lock();
|
||||
#else
|
||||
pthread_cond_wait(&event_, &mtx.native_handle());
|
||||
pthread_mutex_lock( &mtx.native_handle() );
|
||||
pthread_cond_wait(&event_, &mtx.native_handle());
|
||||
pthread_mutex_unlock( &mtx.native_handle() );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -139,4 +141,4 @@ private:
|
||||
#else
|
||||
pthread_cond_t event_;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user