From d11679a06e6a992216148fd2ce1730c9912c8564 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 19 Mar 2013 21:53:09 -0500 Subject: Android mega commit of trash. --- Source/Core/DolphinWX/Src/MainAndroid.cpp | 66 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'Source/Core/DolphinWX/Src/MainAndroid.cpp') diff --git a/Source/Core/DolphinWX/Src/MainAndroid.cpp b/Source/Core/DolphinWX/Src/MainAndroid.cpp index ca2119921d..aa6db56aa1 100644 --- a/Source/Core/DolphinWX/Src/MainAndroid.cpp +++ b/Source/Core/DolphinWX/Src/MainAndroid.cpp @@ -36,10 +36,14 @@ #include #include +#include +JNIEnv *g_env = NULL; +ANativeWindow* surf; #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__)) bool rendererHasFocus = true; bool running = true; +bool KeyStates[15]; void Host_NotifyMapLoaded() {} void Host_RefreshDSPDebuggerWindow() {} @@ -53,7 +57,7 @@ void Host_Message(int Id) void* Host_GetRenderHandle() { - return NULL; + return surf; } void* Host_GetInstance() { return NULL; } @@ -72,7 +76,7 @@ void Host_UpdateBreakPointView(){} bool Host_GetKeyState(int keycode) { - return false; + return KeyStates[keycode]; } void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) @@ -118,25 +122,73 @@ void Host_SysMessage(const char *fmt, ...) void Host_SetWiiMoteConnectionState(int _State) {} +extern void DrawReal(); +extern void PrepareShit(); +extern void DrawButton(int tex, int ID); +extern void SetButtonCoords(float *Coords); #ifdef __cplusplus extern "C" { #endif -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_dolphinemuactivity_main(JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PrepareME(JNIEnv *env, jobject obj) { + PrepareShit(); +} +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords) +{ + jfloat* flt1 = env->GetFloatArrayElements(Coords, 0); + SetButtonCoords((float*)flt1); + env->ReleaseFloatArrayElements(Coords, flt1, 0); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawButton(JNIEnv *env, jobject obj, + jint GLTex, jint ID + ) +{ + DrawButton((int)GLTex, (int)ID); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_UnPauseEmulation(JNIEnv *env, jobject obj) +{ + PowerPC::Start(); +} +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PauseEmulation(JNIEnv *env, jobject obj) +{ + PowerPC::Pause(); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_StopEmulation(JNIEnv *env, jobject obj) +{ + PowerPC::Stop(); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawME(JNIEnv *env, jobject obj) +{ + DrawReal(); +} +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key) +{ + WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value); + KeyStates[(int)Key] = (int)Value == 0 ? true : false; +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf) +{ + surf = ANativeWindow_fromSurface(env, _surf); + g_env = env; + LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); VideoBackend::ActivateBackend(SConfig::GetInstance(). m_LocalCoreStartupParameter.m_strVideoBackend); WiimoteReal::LoadSettings(); - + + const char *File = env->GetStringUTFChars(jFile, NULL); // No use running the loop when booting fails - if (BootManager::BootCore("")) - { + if ( BootManager::BootCore( File ) ) while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) updateMainFrameEvent.Wait(); - } WiimoteReal::Shutdown(); VideoBackend::ClearList(); -- cgit v1.2.3 From 7034c79ab9cede868bf324091b7394b75d350976 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 24 Mar 2013 21:06:34 -0500 Subject: Big commit. Fix running the APK, I had missed a view in the manifest. Clean up the Android EGL context creation to fit more in line with how Dolphin works. This breaks input at the moment as well. Change the memarena from 768MB to 64MB to allow 1GB phones to potentially run it. Rename EGL_X11 back to EGL since this merge brings in some of soreau's changes to more easily allow different platforms like Wayland and Android. Not quite all of the code because some needs to be cleaned up still. --- Source/Core/DolphinWX/Src/MainAndroid.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'Source/Core/DolphinWX/Src/MainAndroid.cpp') diff --git a/Source/Core/DolphinWX/Src/MainAndroid.cpp b/Source/Core/DolphinWX/Src/MainAndroid.cpp index aa6db56aa1..73befff785 100644 --- a/Source/Core/DolphinWX/Src/MainAndroid.cpp +++ b/Source/Core/DolphinWX/Src/MainAndroid.cpp @@ -39,6 +39,7 @@ #include JNIEnv *g_env = NULL; ANativeWindow* surf; +int g_width, g_height; #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__)) bool rendererHasFocus = true; @@ -83,8 +84,8 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos; y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos; - width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth; - height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight; + width = g_width; + height = g_height; } void Host_RequestRenderWindowSize(int width, int height) {} @@ -122,18 +123,12 @@ void Host_SysMessage(const char *fmt, ...) void Host_SetWiiMoteConnectionState(int _State) {} -extern void DrawReal(); -extern void PrepareShit(); extern void DrawButton(int tex, int ID); extern void SetButtonCoords(float *Coords); #ifdef __cplusplus extern "C" { #endif -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PrepareME(JNIEnv *env, jobject obj) -{ - PrepareShit(); -} JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords) { jfloat* flt1 = env->GetFloatArrayElements(Coords, 0); @@ -148,33 +143,30 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawButton( DrawButton((int)GLTex, (int)ID); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_UnPauseEmulation(JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj) { PowerPC::Start(); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PauseEmulation(JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_PauseEmulation(JNIEnv *env, jobject obj) { PowerPC::Pause(); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_StopEmulation(JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEmulation(JNIEnv *env, jobject obj) { PowerPC::Stop(); } - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawME(JNIEnv *env, jobject obj) -{ - DrawReal(); -} JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key) { WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value); KeyStates[(int)Key] = (int)Value == 0 ? true : false; } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height) { surf = ANativeWindow_fromSurface(env, _surf); + g_width = (int)_width; + g_height = (int)_height; g_env = env; LogManager::Init(); -- cgit v1.2.3 From bde7ea00ef9fd625a4e453ee9598fc20382a35a5 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 14 Apr 2013 20:39:56 -0500 Subject: Removes the Java ButtonManager for one in the C++ source so the OSD class can call in to it each frame for drawing the buttons. Copy our assets to the dolphin-emu directory for now. Remove NativeRenderer, ButtonManager, and Button Java classes since they aren't used anymore. Buttons A, B, and Start all work and are drawn on screen now. Button input on Android is still a bit hacky, needs a proper controller interface still. Android specific button drawing code is still hanging out in SWRenderer.cpp --- Source/Core/DolphinWX/Src/MainAndroid.cpp | 63 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'Source/Core/DolphinWX/Src/MainAndroid.cpp') diff --git a/Source/Core/DolphinWX/Src/MainAndroid.cpp b/Source/Core/DolphinWX/Src/MainAndroid.cpp index 73befff785..0e1f5ce48a 100644 --- a/Source/Core/DolphinWX/Src/MainAndroid.cpp +++ b/Source/Core/DolphinWX/Src/MainAndroid.cpp @@ -33,19 +33,17 @@ #include "ConfigManager.h" #include "LogManager.h" #include "BootManager.h" +#include "OnScreenDisplay.h" + +#include "Android/ButtonManager.h" #include #include #include -JNIEnv *g_env = NULL; ANativeWindow* surf; int g_width, g_height; #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__)) -bool rendererHasFocus = true; -bool running = true; -bool KeyStates[15]; - void Host_NotifyMapLoaded() {} void Host_RefreshDSPDebuggerWindow() {} @@ -77,7 +75,7 @@ void Host_UpdateBreakPointView(){} bool Host_GetKeyState(int keycode) { - return KeyStates[keycode]; + return ButtonManager::GetButtonPressed((ButtonManager::ButtonType)keycode); } void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) @@ -123,26 +121,29 @@ void Host_SysMessage(const char *fmt, ...) void Host_SetWiiMoteConnectionState(int _State) {} -extern void DrawButton(int tex, int ID); -extern void SetButtonCoords(float *Coords); +void OSDCallbacks(u32 UserData) +{ + switch(UserData) + { + case 0: // Init + ButtonManager::Init(); + break; + case 1: // Draw + ButtonManager::DrawButtons(); + break; + case 2: // Shutdown + ButtonManager::Shutdown(); + break; + default: + WARN_LOG(COMMON, "Error, wrong OSD type"); + break; + } +} + #ifdef __cplusplus extern "C" { #endif -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords) -{ - jfloat* flt1 = env->GetFloatArrayElements(Coords, 0); - SetButtonCoords((float*)flt1); - env->ReleaseFloatArrayElements(Coords, flt1, 0); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawButton(JNIEnv *env, jobject obj, - jint GLTex, jint ID - ) -{ - DrawButton((int)GLTex, (int)ID); -} - JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj) { PowerPC::Start(); @@ -156,10 +157,9 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEm { PowerPC::Stop(); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_onTouchEvent(JNIEnv *env, jobject obj, jint Action, jfloat X, jfloat Y) { - WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value); - KeyStates[(int)Key] = (int)Value == 0 ? true : false; + ButtonManager::TouchEvent(Action, X, Y); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height) @@ -167,16 +167,19 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(J surf = ANativeWindow_fromSurface(env, _surf); g_width = (int)_width; g_height = (int)_height; - g_env = env; - + + // Install our callbacks + OSD::AddCallback(OSD::OSD_INIT, OSDCallbacks, 0); + OSD::AddCallback(OSD::OSD_ONFRAME, OSDCallbacks, 1); + OSD::AddCallback(OSD::OSD_SHUTDOWN, OSDCallbacks, 2); + LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); - VideoBackend::ActivateBackend(SConfig::GetInstance(). - m_LocalCoreStartupParameter.m_strVideoBackend); + VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); WiimoteReal::LoadSettings(); - const char *File = env->GetStringUTFChars(jFile, NULL); + const char *File = env->GetStringUTFChars(jFile, NULL); // No use running the loop when booting fails if ( BootManager::BootCore( File ) ) while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) -- cgit v1.2.3