Some preliminary Ouya support

This commit is contained in:
pelya
2013-01-28 19:27:32 +02:00
parent 5b279e20f6
commit ec136b0bc8
10 changed files with 26 additions and 10 deletions

View File

@@ -20,6 +20,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="ouya.intent.category.GAME" />
</intent-filter> </intent-filter>
</activity> </activity>
<!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> <!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

View File

@@ -112,4 +112,5 @@ class Globals
public static boolean VideoLinearFilter = true; public static boolean VideoLinearFilter = true;
public static boolean MultiThreadedVideo = false; public static boolean MultiThreadedVideo = false;
public static boolean BrokenLibCMessageShown = false; public static boolean BrokenLibCMessageShown = false;
public static boolean IsOuya = false; // Ouya game console has no Back key, so we need to map some game controller key to Back key
} }

View File

@@ -60,6 +60,7 @@ import java.io.FileInputStream;
import java.util.zip.*; import java.util.zip.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.Set;
import android.text.SpannedString; import android.text.SpannedString;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@@ -92,6 +93,18 @@ public class MainActivity extends Activity
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if( getIntent().getCategories() != null )
{
for( String cat: getIntent().getCategories() )
{
System.out.println("libSDL: getIntent().getCategories(): " + cat);
if( cat.equals("ouya.intent.category.GAME") ) {
System.out.println("libSDL: Ouya game console detected");
Globals.IsOuya = true;
}
}
}
System.out.println("libSDL: Creating startup screen"); System.out.println("libSDL: Creating startup screen");
_layout = new LinearLayout(this); _layout = new LinearLayout(this);
_layout.setOrientation(LinearLayout.VERTICAL); _layout.setOrientation(LinearLayout.VERTICAL);

View File

@@ -170,7 +170,7 @@ class Settings
return; return;
} }
System.out.println("libSDL: Settings.Load(): enter"); System.out.println("libSDL: Settings.Load(): enter");
nativeInitKeymap(); nativeInitKeymap(Globals.IsOuya ? 1 : 0);
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
{ {
int sdlKey = nativeGetKeymapKey(i); int sdlKey = nativeGetKeymapKey(i);
@@ -2812,7 +2812,7 @@ class Settings
private static native void nativeSetVideoForceSoftwareMode(); private static native void nativeSetVideoForceSoftwareMode();
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency); private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
private static native void nativeSetupScreenKeyboardButtons(byte[] img); private static native void nativeSetupScreenKeyboardButtons(byte[] img);
private static native void nativeInitKeymap(); private static native void nativeInitKeymap(int isOuya);
private static native int nativeGetKeymapKey(int key); private static native int nativeGetKeymapKey(int key);
private static native void nativeSetKeymapKey(int javakey, int key); private static native void nativeSetKeymapKey(int javakey, int key);
private static native int nativeGetKeymapKeyScreenKb(int keynum); private static native int nativeGetKeymapKeyScreenKb(int keynum);

View File

@@ -37,8 +37,8 @@ HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
FirstStartMenuOptions='' FirstStartMenuOptions=''
MultiABI=y MultiABI=y
AppMinimumRAM=300 AppMinimumRAM=300
AppVersionCode=08818 AppVersionCode=08819
AppVersionName="0.8.8.18" AppVersionName="0.8.8.19"
ResetSdlConfigForThisVersion=y ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag" DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag"
CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg" CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg"

View File

@@ -2194,7 +2194,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetTouchscreenCalibration) (JNIEnv* env, jobject
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeInitKeymap) ( JNIEnv* env, jobject thiz ) JAVA_EXPORT_NAME(Settings_nativeInitKeymap) ( JNIEnv* env, jobject thiz, jint isOuya )
{ {
SDL_android_init_keymap(SDL_android_keymap); SDL_android_init_keymap(SDL_android_keymap, isOuya);
} }

View File

@@ -200,7 +200,7 @@ extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed); extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed);
extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y); extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y);
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode ); extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode );
extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap); extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap, int isOuya);
extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only
extern void SDL_ANDROID_MainThreadPushAppActive(int active); extern void SDL_ANDROID_MainThreadPushAppActive(int active);
#endif #endif

View File

@@ -4,7 +4,7 @@
#include "SDL_androidinput.h" #include "SDL_androidinput.h"
#include "SDL_screenkeyboard.h" #include "SDL_screenkeyboard.h"
void SDL_android_init_keymap(SDLKey *SDL_android_keymap) void SDL_android_init_keymap(SDLKey *SDL_android_keymap, int isOuya)
{ {
int i; int i;
SDLKey * keymap = SDL_android_keymap; SDLKey * keymap = SDL_android_keymap;
@@ -131,7 +131,7 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT); keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT);
keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT); keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT);
keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2)); keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
keymap[KEYCODE_BUTTON_B] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); keymap[KEYCODE_BUTTON_B] = isOuya ? SDL_KEY(ESCAPE) : SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3));
keymap[KEYCODE_BUTTON_C] = SDL_KEY(C); keymap[KEYCODE_BUTTON_C] = SDL_KEY(C);
keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0)); keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0));
keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1)); keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1));

View File

@@ -0,0 +1 @@
icon.png