diff --git a/android/app-android.cpp b/android/app-android.cpp index e570406719..16651f7c7b 100644 --- a/android/app-android.cpp +++ b/android/app-android.cpp @@ -84,11 +84,6 @@ void LaunchEmail(const char *email_address) { frameCommandParam = email_address; } -void System_InputBox(const char *title, const char *defaultValue) { - frameCommand = "inputBox"; - frameCommandParam = title; -} - void System_SendMessage(const char *command, const char *parameter) { frameCommand = command; frameCommandParam = parameter; diff --git a/base/NativeApp.h b/base/NativeApp.h index 03035b6e29..c81ffe8303 100644 --- a/base/NativeApp.h +++ b/base/NativeApp.h @@ -107,7 +107,8 @@ void Vibrate(int length_ms); void LaunchBrowser(const char *url); void LaunchMarket(const char *url); void LaunchEmail(const char *email_address); -void System_InputBox(const char *title, const char *defaultValue); +bool System_InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength); +bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &defaultValue, std::wstring &outValue); void System_SendMessage(const char *command, const char *parameter); enum SystemProperty { diff --git a/base/PCMain.cpp b/base/PCMain.cpp index 4f76254ff2..3b4668eaa9 100644 --- a/base/PCMain.cpp +++ b/base/PCMain.cpp @@ -200,11 +200,6 @@ void System_SendMessage(const char *command, const char *parameter) { // Log? } -void System_InputBox(const char *title, const char *defaultValue) { - // Stub - NativeMessageReceived((std::string("INPUTBOX:") + title).c_str(), "TestFile"); -} - void LaunchBrowser(const char *url) { #ifdef _WIN32 ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); diff --git a/base/QtMain.cpp b/base/QtMain.cpp index 806af47c8d..1025b46755 100644 --- a/base/QtMain.cpp +++ b/base/QtMain.cpp @@ -3,7 +3,7 @@ * */ // Qt 4.7+ / 5.0+ implementation of the framework. -// Currently supports: Symbian, Blackberry, Meego, Linux, Windows +// Currently supports: Symbian, Blackberry, Meego, Linux, Windows, Mac OSX #include #include @@ -24,8 +24,6 @@ #endif #include "QtMain.h" - - InputState* input_state; std::string System_GetProperty(SystemProperty prop) { @@ -41,6 +39,8 @@ std::string System_GetProperty(SystemProperty prop) { return "Qt:Linux"; #elif defined(_WIN32) return "Qt:Windows"; +#elif defined(Q_OS_MAC) + return "Qt:Mac"; #else return "Qt"; #endif @@ -55,6 +55,24 @@ void System_SendMessage(const char *command, const char *parameter) { // Log? } +bool System_InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength) +{ + QString text = emugl->InputBoxGetQString(QString(title), QString(defaultValue)); + if (text.isEmpty()) + return false; + strcpy(outValue, text.toStdString().c_str()); + return true; +} + +bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &defaultValue, std::wstring &outValue) +{ + QString text = emugl->InputBoxGetQString(QString::fromStdWString(title), QString::fromStdWString(defaultValue)); + if (text.isEmpty()) + return false; + outValue = text.toStdWString(); + return true; +} + void Vibrate(int length_ms) { if (length_ms == -1 || length_ms == -3) length_ms = 50; @@ -79,7 +97,7 @@ float CalculateDPIScale() // Sane default rather than check DPI #ifdef __SYMBIAN32__ return 1.4f; -#elif defined(ARM) +#elif defined(USING_GLES2) return 1.2f; #else return 1.0f; @@ -120,17 +138,16 @@ int main(int argc, char *argv[]) const char *assets_dir = "./"; #endif NativeInit(argc, (const char **)argv, savegame_dir, assets_dir, "BADCOFFEE"); - -#if defined(ARM) - MainUI w; - w.resize(pixel_xres, pixel_yres); - w.showFullScreen(); +#ifdef USING_GLES2 + emugl = new MainUI(this); + emugl->resize(pixel_xres, pixel_yres); + emugl->showFullScreen(); #endif #ifdef __SYMBIAN32__ // Set RunFast hardware mode for VFPv2. User::SetFloatingPointMode(EFpModeRunFast); // Disable screensaver - QSystemScreenSaver *ssObject = new QSystemScreenSaver(&w); + QSystemScreenSaver *ssObject = new QSystemScreenSaver(emugl); ssObject->setScreenSaverInhibit(); SymbianMediaKeys* mediakeys = new SymbianMediaKeys(); #endif diff --git a/base/QtMain.h b/base/QtMain.h index a6f7badc97..067460e8c8 100644 --- a/base/QtMain.h +++ b/base/QtMain.h @@ -3,6 +3,7 @@ #include #include +#include #include "gfx_es2/glsl_program.h" #include @@ -59,6 +60,15 @@ public: NativeShutdownGraphics(); } +public slots: + QString InputBoxGetQString(QString title, QString defaultValue) { + bool ok; + QString text = QInputDialog::getText(this, title, title, QLineEdit::Normal, defaultValue, &ok); + if (!ok) + text = QString(); + return text; + } + signals: void doubleClick(); void newFrame(); @@ -201,6 +211,8 @@ private: #endif }; +static MainUI* emugl = NULL; + // Audio #define AUDIO_FREQ 44100 #define AUDIO_CHANNELS 2