From c4d05afb40da94c85dab0745bc1ec556495f2b30 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 14 Sep 2015 13:56:34 -0700 Subject: [PATCH] Update SDL version --- project/lib/sdl | 2 +- .../src/org/libsdl/app/SDLActivity.java | 51 ++++++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/project/lib/sdl b/project/lib/sdl index 0b8752999..f314cd792 160000 --- a/project/lib/sdl +++ b/project/lib/sdl @@ -1 +1 @@ -Subproject commit 0b87529998091bb42e287d38e40fd10b7e0eec74 +Subproject commit f314cd7925fe36e6767d12d9e8212d853e1873a4 diff --git a/templates/android/template/src/org/libsdl/app/SDLActivity.java b/templates/android/template/src/org/libsdl/app/SDLActivity.java index 05c94ff75..e2f641c93 100644 --- a/templates/android/template/src/org/libsdl/app/SDLActivity.java +++ b/templates/android/template/src/org/libsdl/app/SDLActivity.java @@ -27,6 +27,7 @@ import android.graphics.*; import android.graphics.drawable.Drawable; import android.media.*; import android.hardware.*; +import android.content.pm.ActivityInfo; import org.haxe.HXCPP; @@ -1067,6 +1068,42 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate()); Log.v("SDL", "Window size: " + width + "x" + height); + + boolean skip = false; + int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); + + if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) + { + // Accept any + } + else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + { + if (mWidth > mHeight) { + skip = true; + } + } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { + if (mWidth < mHeight) { + skip = true; + } + } + + // Special Patch for Square Resolution: Black Berry Passport + if (skip) { + double min = Math.min(mWidth, mHeight); + double max = Math.max(mWidth, mHeight); + + if (max / min < 1.20) { + Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); + skip = false; + } + } + + if (skip) { + Log.v("SDL", "Skip .. Surface is not ready."); + return; + } + + // Set mIsSurfaceReady to 'true' *before* making a call to handleResume SDLActivity.mIsSurfaceReady = true; SDLActivity.onNativeSurfaceChanged(); @@ -1098,6 +1135,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, }, "SDLThreadListener"); SDLActivity.mSDLThread.start(); } + + if (SDLActivity.mHasFocus) { + SDLActivity.handleResume(); + } } // unused @@ -1465,7 +1506,13 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler { if (joystick == null) { joystick = new SDLJoystick(); InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]); - if( (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { + + if ( + (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 + || + (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_BUTTON) != 0 + ) + { joystick.device_id = deviceIds[i]; joystick.name = joystickDevice.getName(); joystick.axes = new ArrayList(); @@ -1561,7 +1608,6 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener { @Override public boolean onGenericMotion(View v, MotionEvent event) { float x, y; - int mouseButton; int action; switch ( event.getSource() ) { @@ -1590,6 +1636,7 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener { default: break; } + break; default: break;