SDL: Android TV support, preliminary for now.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user