diff --git a/.gitignore b/.gitignore index 1513d14c5..0fca9380d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ project/libs project/assets project/obj project/src -project/res/values* +project/res/values*/strings.xml project/AndroidManifest.xml project/jni/Settings.mk project/jni/application/*/libapplication*.so @@ -17,3 +17,4 @@ project/proguard-project.txt project/proguard-local.cfg project/themes/converter project/jni/android-support +project/res/drawable/banner.png diff --git a/changeAppSettings.sh b/changeAppSettings.sh index 37fb3da26..f3c7b6ffd 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -909,7 +909,7 @@ cat project/jni/SettingsTemplate.mk | \ project/jni/Settings.mk echo Patching strings.xml -rm -rf project/res/values* +rm -rf project/res/values*/strings.xml cd $JAVA_SRC_PATH/translations for F in */strings.xml; do mkdir -p ../../res/`dirname $F` @@ -994,6 +994,13 @@ rm -rf project/bin/res rm -rf project/jni/android-support ln -s "`which ndk-build | sed 's@/ndk-build@@'`/sources/android/support" project/jni/android-support +rm -rf project/res/drawable/banner.png +if [ -e project/jni/application/src/banner.png ]; then + ln -s ../../jni/application/src/banner.png project/res/drawable/banner.png +else + ln -s ../../themes/tv-banner-placeholder.png project/res/drawable/banner.png +fi + if uname -s | grep -i "darwin" > /dev/null ; then find project/src -name "*.killme.tmp" -delete fi diff --git a/project/AndroidManifestTemplate.xml b/project/AndroidManifestTemplate.xml index 010ee6585..7956ad1c7 100644 --- a/project/AndroidManifestTemplate.xml +++ b/project/AndroidManifestTemplate.xml @@ -9,6 +9,8 @@ android:icon="@drawable/icon" android:debuggable="true" android:allowBackup="true" + android:banner="@drawable/banner" + android:isGame="true" > + @@ -55,6 +58,9 @@ + + + diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 50ad00a3c..200123cc1 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -92,6 +92,7 @@ import android.inputmethodservice.Keyboard; import android.app.Notification; import android.app.PendingIntent; import java.util.TreeSet; +import android.app.UiModeManager; public class MainActivity extends Activity { @@ -349,7 +350,13 @@ public class MainActivity extends Activity setContentView(_videoLayout); mGLView = new DemoGLSurfaceView(this); SetLayerType.get().setLayerType(mGLView); - _videoLayout.addView(mGLView); + FrameLayout.LayoutParams margin = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); + // Add TV screen borders, if needed + margin.setMargins( getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal), + getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical), + getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal), + getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical)); + _videoLayout.addView(mGLView, margin); mGLView.setFocusableInTouchMode(true); mGLView.setFocusable(true); mGLView.requestFocus(); @@ -1444,7 +1451,8 @@ public class MainActivity extends Activity return true; } catch (PackageManager.NameNotFoundException e) { } - return Globals.OuyaEmulation; + UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); + return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) || Globals.OuyaEmulation; } public boolean isCurrentOrientationHorizontal() diff --git a/project/java/Settings.java b/project/java/Settings.java index 84dd59d3a..e8ad8655c 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -202,8 +202,6 @@ class Settings } Log.i("SDL", "libSDL: Settings.Load(): enter"); nativeInitKeymap(); - if( p.isRunningOnOUYA() ) - nativeSetKeymapKey(KeyEvent.KEYCODE_MENU, nativeGetKeymapKey(KeyEvent.KEYCODE_BACK)); // Ouya does not have Back key, only Menu, so remap Back keycode to Menu for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) { int sdlKey = nativeGetKeymapKey(i); @@ -635,7 +633,11 @@ class Settings nativeSetEnv( "ANDROID_PACKAGE_PATH", p.getPackageCodePath() ); Log.d("SDL", "libSDL: Is running on OUYA: " + p.isRunningOnOUYA()); if( p.isRunningOnOUYA() ) + { nativeSetEnv( "OUYA", "1" ); + nativeSetEnv( "TV", "1" ); + nativeSetEnv( "ANDROID_TV", "1" ); + } if (p.getIntent().getStringExtra(RestartMainActivity.SDL_RESTART_PARAMS) != null) nativeSetEnv( RestartMainActivity.SDL_RESTART_PARAMS, p.getIntent().getStringExtra(RestartMainActivity.SDL_RESTART_PARAMS) ); try { diff --git a/project/java/Video.java b/project/java/Video.java index 61f600381..37b16258f 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -616,6 +616,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer int mLastPendingResize = 0; public void onWindowResize(final int w, final int h) { + if (context.isRunningOnOUYA()) + return; // TV screen is never resized, and this event will mess up TV borders Log.d("SDL", "libSDL: DemoRenderer.onWindowResize(): " + w + "x" + h); mLastPendingResize ++; final int resizeThreadIndex = mLastPendingResize; @@ -990,6 +992,8 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { @Override public boolean onTouchEvent(final MotionEvent event) { + if (getX() != 0) + event.offsetLocation(-getX(), -getY()); DifferentTouchInput.touchInput.process(event); if( DemoRenderer.mRatelimitTouchEvents ) { diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index 78caf9da2..c50770387 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -658,7 +658,7 @@ int main(int argc, char* argv[]) int mx, my; int b = SDL_GetMouseState(&mx, &my); - //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse buttons: %d", b); + //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse: %04d %04d buttons %d", mx, my, b); int cursorIdx = 0; if( b & SDL_BUTTON_LMASK ) cursorIdx |= 1; diff --git a/project/jni/application/ballfield/banner.png b/project/jni/application/ballfield/banner.png new file mode 100644 index 000000000..bfc20e38c Binary files /dev/null and b/project/jni/application/ballfield/banner.png differ diff --git a/project/jni/application/openttd/src b/project/jni/application/openttd/src index 145d01d3d..9b3502f37 160000 --- a/project/jni/application/openttd/src +++ b/project/jni/application/openttd/src @@ -1 +1 @@ -Subproject commit 145d01d3df58cba497a86308f3125cfe1ebe6516 +Subproject commit 9b3502f3770fd35c13830a5d108c0428ec74e0f2 diff --git a/project/jni/application/teeworlds/src b/project/jni/application/teeworlds/src index 6463636f2..066b0d8dd 160000 --- a/project/jni/application/teeworlds/src +++ b/project/jni/application/teeworlds/src @@ -1 +1 @@ -Subproject commit 6463636f28cbc9f98505c4769a7df9426914cb57 +Subproject commit 066b0d8dd07567ee598b5a3831843b5464a68e52 diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index bcba32cea..a316959d0 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -420,17 +420,6 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, window.w = width; window.h = height; - if( getenv("OUYA") ) - { - // Leave 10% at the borders blank, because all TVs have crazy thick edges and not enough pixels - // Also this is enforced by Ouya guidelines, so there's not much choice. - window.x += window.w / 10; - window.y += window.h / 10; - window.w -= window.w / 5; - window.h -= window.h / 5; - SDL_ANDROID_ForceClearScreenRectAmount = 4; - } - SDL_ANDROID_ForceClearScreenRect[0].x = 0; SDL_ANDROID_ForceClearScreenRect[0].y = 0; SDL_ANDROID_ForceClearScreenRect[0].w = window.x; diff --git a/project/res/values-television/dimen.xml b/project/res/values-television/dimen.xml new file mode 100644 index 000000000..2e4acf666 --- /dev/null +++ b/project/res/values-television/dimen.xml @@ -0,0 +1,4 @@ + + 48dp + 27dp + diff --git a/project/res/values/dimen.xml b/project/res/values/dimen.xml new file mode 100644 index 000000000..704307354 --- /dev/null +++ b/project/res/values/dimen.xml @@ -0,0 +1,4 @@ + + 0dp + 0dp + diff --git a/project/themes/tv-banner-placeholder.png b/project/themes/tv-banner-placeholder.png new file mode 100644 index 000000000..9411ad646 Binary files /dev/null and b/project/themes/tv-banner-placeholder.png differ