Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android

Conflicts:
	project/jni/application/commandergenius/commandergenius
This commit is contained in:
Gerhard Stein
2013-09-20 19:45:39 +02:00
30 changed files with 1803 additions and 95 deletions

View File

@@ -1,10 +1,6 @@
Known bugs (see also todo.txt)
==============================
- With 4:3 screen aspect ratio the on-screen buttons are not shown on the inactive part of screen.
- Put video at the center of the screen with 4:3 aspect ratio option
- Calling SDL_SetVideoMode() with SDL 1.3 several times makes it crash.
- Calling SDL_Init()/SDL_Quit() several times will make SDL 1.2 crash.

View File

@@ -475,6 +475,22 @@ if [ -n "$var" ] ; then
fi
fi
if [ -z "$TouchscreenKeysTheme" -o -z "$AUTO" ]; then
echo
echo "On-screen keys theme"
echo "1 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)"
echo "2 = Simple Theme by Beholder (white, with gamepad joystick)"
echo "3 = Sun by Sirea (yellow, with round joystick)"
echo "4 = Mystery by Gerstrong (unknown color, unknown joystick)"
echo ""
echo -n "($TouchscreenKeysTheme): "
read var
if [ -n "$var" ] ; then
TouchscreenKeysTheme="$var"
CHANGED=1
fi
fi
if [ -z "$RedefinedKeysGamepad" -o -z "$AUTO" ]; then
if [ -z "$RedefinedKeysGamepad" ]; then
RedefinedKeysGamepad="$RedefinedKeysScreenKb"
@@ -881,6 +897,13 @@ echo >> AndroidAppSettings.cfg
echo "# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu" >> AndroidAppSettings.cfg
echo RedefinedKeysScreenKbNames=\"$RedefinedKeysScreenKbNames\" >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# On-screen keys theme" >> AndroidAppSettings.cfg
echo "# 1 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)" >> AndroidAppSettings.cfg
echo "# 2 = Simple Theme by Beholder (white, with gamepad joystick)" >> AndroidAppSettings.cfg
echo "# 3 = Sun by Sirea (yellow, with round joystick)" >> AndroidAppSettings.cfg
echo "# 4 = Mystery by Gerstrong (unknown color, unknown joystick)" >> AndroidAppSettings.cfg
echo TouchscreenKeysTheme=$TouchscreenKeysTheme >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Redefine gamepad keys to SDL keysyms, button order is:" >> AndroidAppSettings.cfg
echo "# A B X Y L1 R1 L2 R2 LThumb RThumb" >> AndroidAppSettings.cfg
echo RedefinedKeysGamepad=\"$RedefinedKeysGamepad\" >> AndroidAppSettings.cfg
@@ -1298,6 +1321,7 @@ $SEDI "s|public static String DeleteFilesOnUpgrade = .*;|public static String De
$SEDI "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" project/src/Globals.java
$SEDI "s/public static int AppTouchscreenKeyboardKeysAmountAutoFire = .*;/public static int AppTouchscreenKeyboardKeysAmountAutoFire = $AppTouchscreenKeyboardKeysAmountAutoFire;/" project/src/Globals.java
$SEDI "s@public static String\\[\\] AppTouchscreenKeyboardKeysNames = .*;@public static String[] AppTouchscreenKeyboardKeysNames = \"$RedefinedKeysScreenKbNames\".split(\" \");@" project/src/Globals.java
$SEDI "s/public static int TouchscreenKeyboardTheme = .*;/public static int TouchscreenKeyboardTheme = $TouchscreenKeysTheme;/" project/src/Globals.java
$SEDI "s/public static int StartupMenuButtonTimeout = .*;/public static int StartupMenuButtonTimeout = $StartupMenuButtonTimeout;/" project/src/Globals.java
$SEDI "s/public static int AppMinimumRAM = .*;/public static int AppMinimumRAM = $AppMinimumRAM;/" project/src/Globals.java
$SEDI "s/public static SettingsMenu.Menu HiddenMenuOptions .*;/public static SettingsMenu.Menu HiddenMenuOptions [] = { $HiddenMenuOptions1 };/" project/src/Globals.java

View File

@@ -8,7 +8,7 @@ if [ -d "project/jni/application/src/AndroidData" ] ; then
for F in project/assets/*; do
if [ `cat $F | wc -c` -gt 1000000 ] ; then
echo "The file $F is bigger than 1 megabyte - splitting it into smaller chunks"
split -b 1000000 -d $F $F && rm $F || { echo "Error: 'split' command not installed" ; exit 1 ; }
split -b 1000000 -a 3 -d $F $F && rm $F || { echo "Error: 'split' command not installed" ; exit 1 ; }
fi
done
fi

View File

@@ -317,7 +317,7 @@ class DataDownloader extends Thread
stream1.close();
} catch( Exception e ) {
try {
stream1 = Parent.getAssets().open(url + "00");
stream1 = Parent.getAssets().open(url + "000");
stream1.close();
} catch( Exception ee ) {
Log.i("SDL", "Failed to open file in assets: " + url);
@@ -367,8 +367,8 @@ class DataDownloader extends Thread
while( true )
{
try {
// Make string ".zip00", ".zip01" etc for multipart archives
String url1 = url + String.format("%02d", multipartCounter);
// Make string ".zip000", ".zip001" etc for multipart archives
String url1 = url + String.format("%03d", multipartCounter);
CountingInputStream stream1 = new CountingInputStream(Parent.getAssets().open(url1), 8192);
while( stream1.skip(65536) > 0 ) { };
totalLen += stream1.getBytesRead();
@@ -420,6 +420,8 @@ class DataDownloader extends Thread
}
}
long updateStatusTime = 0;
if(DoNotUnzip)
{
Log.i("SDL", "Saving file '" + path + "'");
@@ -477,7 +479,11 @@ class DataDownloader extends Thread
float percent = 0.0f;
if( totalLen > 0 )
percent = (stream.getBytesRead() + partialDownloadLen) * 100.0f / (totalLen + partialDownloadLen);
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
if( System.currentTimeMillis() > updateStatusTime + 1000 )
{
updateStatusTime = System.currentTimeMillis();
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
}
}
out.flush();
out.close();
@@ -547,7 +553,11 @@ class DataDownloader extends Thread
Log.i("SDL", "File '" + path + "' exists and passed CRC check - not overwriting it");
if( totalLen > 0 )
percent = stream.getBytesRead() * 100.0f / totalLen;
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
if( System.currentTimeMillis() > updateStatusTime + 1000 )
{
updateStatusTime = System.currentTimeMillis();
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
}
continue;
} catch( Exception e ) { }
@@ -567,7 +577,11 @@ class DataDownloader extends Thread
if( totalLen > 0 )
percent = stream.getBytesRead() * 100.0f / totalLen;
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
if( System.currentTimeMillis() > updateStatusTime + 1000 )
{
updateStatusTime = System.currentTimeMillis();
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
}
try {
int len = zip.read(buf);
@@ -580,7 +594,11 @@ class DataDownloader extends Thread
percent = 0.0f;
if( totalLen > 0 )
percent = stream.getBytesRead() * 100.0f / totalLen;
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
if( System.currentTimeMillis() > updateStatusTime + 1000 )
{
updateStatusTime = System.currentTimeMillis();
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
}
}
out.flush();
out.close();

View File

@@ -121,4 +121,5 @@ class Globals
public static boolean BrokenLibCMessageShown = false;
// Gyroscope calibration
public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
public static boolean OuyaEmulation = false; // For debugging
}

View File

@@ -38,6 +38,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.FrameLayout;
import android.graphics.drawable.Drawable;
import android.graphics.Color;
import android.content.res.Configuration;
import android.app.Notification;
import android.app.NotificationManager;
@@ -70,6 +71,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import java.util.concurrent.Semaphore;
import android.content.pm.ActivityInfo;
import android.view.Display;
@@ -218,7 +220,8 @@ public class MainActivity extends Activity
if( Parent._tv == null )
{
Parent._tv = new TextView(Parent);
Parent._tv.setMaxLines(2);
Parent._tv.setMaxLines(2); // To show some long texts on smaller devices
Parent._tv.setMinLines(2); // Otherwise the background picture is getting resized at random, which does not look good
Parent._tv.setText(R.string.init);
Parent._layout2.addView(Parent._tv);
}
@@ -404,6 +407,7 @@ public class MainActivity extends Activity
{
_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
_inputManager.showSoftInput(mGLView, InputMethodManager.SHOW_FORCED);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
public void showScreenKeyboard(final String oldText, boolean sendBackspace)
@@ -420,9 +424,20 @@ public class MainActivity extends Activity
MainActivity _parent;
boolean sendBackspace;
simpleKeyListener(MainActivity parent, boolean sendBackspace) { _parent = parent; this.sendBackspace = sendBackspace; };
public boolean onKey(View v, int keyCode, KeyEvent event)
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if ((event.getAction() == KeyEvent.ACTION_UP) && ((keyCode == KeyEvent.KEYCODE_ENTER) || (keyCode == KeyEvent.KEYCODE_BACK)))
if ((event.getAction() == KeyEvent.ACTION_UP) && (
keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_BACK ||
keyCode == KeyEvent.KEYCODE_MENU ||
keyCode == KeyEvent.KEYCODE_BUTTON_A ||
keyCode == KeyEvent.KEYCODE_BUTTON_B ||
keyCode == KeyEvent.KEYCODE_BUTTON_X ||
keyCode == KeyEvent.KEYCODE_BUTTON_Y ||
keyCode == KeyEvent.KEYCODE_BUTTON_1 ||
keyCode == KeyEvent.KEYCODE_BUTTON_2 ||
keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
keyCode == KeyEvent.KEYCODE_BUTTON_4 ))
{
_parent.hideScreenKeyboard();
return true;
@@ -475,14 +490,41 @@ public class MainActivity extends Activity
String hint = _screenKeyboardHintMessage;
_screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
_screenKeyboard.setText(oldText);
_screenKeyboard.setSelection(_screenKeyboard.getText().length());
_screenKeyboard.setOnKeyListener(new simpleKeyListener(this, sendBackspace));
_screenKeyboard.setBackgroundColor(Color.BLACK); // Full opaque - do not show semi-transparent edit box, it's confusing
_screenKeyboard.setTextColor(Color.WHITE); // Just to be sure about gamma
if( isRunningOnOUYA() )
_screenKeyboard.setPadding(100, 100, 100, 100); // Bad bad HDMI TVs all have cropped borders
_videoLayout.addView(_screenKeyboard);
//_screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false));
_screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
_screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT);
_screenKeyboard.setFocusableInTouchMode(true);
_screenKeyboard.setFocusable(true);
_screenKeyboard.requestFocus();
_inputManager.showSoftInput(_screenKeyboard, InputMethodManager.SHOW_FORCED);
_inputManager.showSoftInput(_screenKeyboard, InputMethodManager.SHOW_IMPLICIT);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
// Hack to try to force on-screen keyboard
final EditText keyboard = _screenKeyboard;
keyboard.postDelayed( new Runnable()
{
public void run()
{
keyboard.requestFocus();
//_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
_inputManager.showSoftInput(keyboard, InputMethodManager.SHOW_FORCED);
// Hack from Stackoverflow, to force text input on Ouya
keyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN , 0, 0, 0));
keyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
keyboard.postDelayed( new Runnable()
{
public void run()
{
keyboard.setSelection(keyboard.getText().length());
}
}, 100 );
}
}, 500 );
};
public void hideScreenKeyboard()
@@ -1045,7 +1087,7 @@ public class MainActivity extends Activity
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
return Globals.OuyaEmulation;
}
public boolean isCurrentOrientationHorizontal()

View File

@@ -170,6 +170,8 @@ class Settings
out.writeFloat(Globals.gyro_z2);
out.writeFloat(Globals.gyro_zc);
out.writeBoolean(Globals.OuyaEmulation);
out.close();
settingsLoaded = true;
@@ -349,6 +351,8 @@ class Settings
Globals.gyro_z2 = settingsFile.readFloat();
Globals.gyro_zc = settingsFile.readFloat();
Globals.OuyaEmulation = settingsFile.readBoolean();
settingsLoaded = true;
Log.i("SDL", "libSDL: Settings.Load(): loaded settings successfully");
@@ -514,6 +518,8 @@ class Settings
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
if( Globals.ScreenKbControlsShown[i] )
screenKbReallyUsed = true;
if( p.isRunningOnOUYA() )
screenKbReallyUsed = false;
if( screenKbReallyUsed )
{
nativeSetTouchscreenKeyboardUsed();

View File

@@ -332,6 +332,7 @@ class SettingsMenuMisc extends SettingsMenu
static class VideoSettingsConfig extends Menu
{
static int debugMenuShowCount = 0;
String title(final MainActivity p)
{
return p.getResources().getString(R.string.video);
@@ -339,6 +340,7 @@ class SettingsMenuMisc extends SettingsMenu
//boolean enabled() { return true; };
void run (final MainActivity p)
{
debugMenuShowCount++;
CharSequence[] items = {
p.getResources().getString(R.string.pointandclick_keepaspectratio),
p.getResources().getString(R.string.video_smooth)
@@ -391,6 +393,48 @@ class SettingsMenuMisc extends SettingsMenu
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
if( debugMenuShowCount > 5 || Globals.OuyaEmulation )
showDebugMenu(p);
else
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
goBack(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
void showDebugMenu (final MainActivity p)
{
CharSequence[] items = {
"OUYA emulation"
};
boolean defaults[] = {
Globals.OuyaEmulation,
};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle("Debug settings");
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if( item == 0 )
Globals.OuyaEmulation = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
@@ -425,6 +469,8 @@ class SettingsMenuMisc extends SettingsMenu
{
String readmes[] = Globals.ReadmeText.split("\\^");
String lang = new String(Locale.getDefault().getLanguage()) + ":";
if( p.isRunningOnOUYA() )
lang = "ouya:";
String readme = readmes[0];
String buttonName = "", buttonUrl = "";
for( String r: readmes )

View File

@@ -112,6 +112,8 @@ abstract class DifferentTouchInput
Log.i("SDL", "Device model: " + android.os.Build.MODEL);
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
{
if( DetectCrappyDragonRiseDatexGamepad() )
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance;
return IcsTouchInput.Holder.sInstance;
}
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
@@ -131,6 +133,13 @@ abstract class DifferentTouchInput
}
}
}
private static boolean DetectCrappyDragonRiseDatexGamepad()
{
if( CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance == null )
return false;
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance.detect();
}
private static class SingleTouchInput extends DifferentTouchInput
{
private static class Holder
@@ -351,7 +360,6 @@ abstract class DifferentTouchInput
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
{
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
@@ -369,6 +377,69 @@ abstract class DifferentTouchInput
super.processGenericEvent(event);
}
}
private static class CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad extends IcsTouchInput
{
private static class Holder
{
private static final CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad sInstance = new CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad();
}
float hatX = 0.0f, hatY = 0.0f;
public void processGenericEvent(final MotionEvent event)
{
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
{
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
event.getAxisValue(MotionEvent.AXIS_RX), event.getAxisValue(MotionEvent.AXIS_RZ),
0, 0);
if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX )
{
hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
if( hatX == 0.0f )
{
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0);
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0);
}
else
DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1);
}
if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY )
{
hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
if( hatY == 0.0f )
{
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0);
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0);
}
else
DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1);
}
return;
}
super.processGenericEvent(event);
}
public boolean detect()
{
int[] devIds = InputDevice.getDeviceIds();
for( int id : devIds )
{
InputDevice device = InputDevice.getDevice(id);
if( device == null )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
if( (device.getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD &&
(device.getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK &&
device.getName().indexOf("DragonRise Inc") == 0 )
{
System.out.println("libSDL: Detected crappy DragonRise gamepad, enabling special hack for it. Please press button labeled 'Analog', otherwise it won't work, because it's cheap and crappy");
return true;
}
}
return false;
}
}
}

View File

@@ -1,51 +1,219 @@
# The application settings for Android libSDL port
AppSettingVersion=17
AppSettingVersion=19
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="Biniax2"
# Specify reversed site name of application (e.x. com.mysite.myapp)
AppFullName=com.biniax.sdl
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=y
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
AppDataDownloadUrl="!Game data|data3.zip"
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
VideoDepthBpp=16
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedDepthBuffer=n
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedStencilBuffer=n
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles2=n
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
SwVideoMode=y
# Application video output will be resized to fit into native device screen (y)/(n)
SdlVideoResize=y
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
CompatibilityHacks=n
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
CompatibilityHacksStaticInit=n
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
CompatibilityHacksTextInputEmulatesHwKeyboard=n
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=n
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
CompatibilityHacksAppIgnoresAudioBufferSize=n
# Hack for VCMI: preload additional shared libraries before aplication start
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=y
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
AppNeedsTwoButtonMouse=n
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
AppNeedsArrowKeys=n
# Application needs text input (y) or (n), enables button for text input on screen
AppNeedsTextInput=n
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
AppUsesJoystick=n
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=n
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
AppUsesAccelerometer=n
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
AppUsesGyroscope=n
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
AppUsesMultitouch=n
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
# This option will add additional permission to Android manifest (y)/(n)
AppRecordsAudio=n
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
# This option is reported to be buggy, sometimes failing to restore video state
NonBlockingSwapBuffers=n
# Redefine common hardware keys to SDL keysyms
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
RedefinedKeys="RETURN"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=0
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="RETURN SPACE"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="RETURN SPACE"
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
RedefinedKeysGamepad="RETURN ESCAPE SPACE SPACE"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=0
HiddenMenuOptions='DisplaySizeConfig MouseConfigMainMenu'
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions='SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.MouseConfigMainMenu'
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
MultiABI=n
AppVersionCode=1401
AppVersionName="1.4.01"
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
# Application version code (integer)
AppVersionCode=1404
# Application user-visible version name (string)
AppVersionName="1.4.04"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="sdl_image sdl_mixer"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags=''
# Additional LDFLAGS for application
AppLdflags=''
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=
# Build only following subdirs (empty will build all dirs, ignored with custom script)
AppSubdirsBuild='src/*'
# Exclude these files from build
AppBuildExclude=''
# Application command line parameters, including app name as 0-th param
AppCmdline=''
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
ReadmeText='^.'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
MinimumScreenSize=n
# Your AdMob Publisher ID, (n) if you don't want advertisements
AdmobPublisherId=n
# Your AdMob test device ID, to receive a test ad
AdmobTestDeviceId=
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
AdmobBannerSize=

View File

@@ -28,6 +28,9 @@ For complete product license refer to LICENSE.TXT file
INCLUDES
******************************************************************************/
#include <string.h>
#ifdef __ANDROID__
#include <SDL_screenkeyboard.h>
#endif
#include "inc.h"
@@ -222,6 +225,10 @@ BNX_BOOL hofEnter( BNX_GAME *game )
strcpy( recEntry->name, " " );
recEntry->score = game->score[ cPlayer1 ];
inpInit();
#ifdef __ANDROID__
SDL_ANDROID_SetScreenKeyboardHintMesage("Enter your name");
SDL_ANDROID_ToggleScreenKeyboardTextInput("");
#endif
do
{
startTime = sysGetTime();
@@ -256,6 +263,10 @@ BNX_BOOL hofEnter( BNX_GAME *game )
{
sysUpdate();
}
#ifdef __ANDROID__
if ( !SDL_IsScreenKeyboardShown(NULL) )
break;
#endif
}
while ( inpKeyA() == BNX_FALSE && inpKeyB() == BNX_FALSE );
hofResetCursor( curPos, recEntry->name );

View File

@@ -1,62 +1,219 @@
# The application settings for Android libSDL port
AppSettingVersion=17
AppSettingVersion=19
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="FFPlay test"
# Specify reversed site name of application (e.x. com.mysite.myapp)
AppFullName=org.ffmpeg.ffplay.test
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=y
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
AppDataDownloadUrl="!!Data|video.zip"
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
VideoDepthBpp=24
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedDepthBuffer=n
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedStencilBuffer=n
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles2=n
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
SwVideoMode=y
# Application video output will be resized to fit into native device screen (y)/(n)
SdlVideoResize=y
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
CompatibilityHacks=n
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
CompatibilityHacksStaticInit=n
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
CompatibilityHacksTextInputEmulatesHwKeyboard=n
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=n
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
CompatibilityHacksAppIgnoresAudioBufferSize=n
# Hack for VCMI: preload additional shared libraries before aplication start
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=n
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
AppNeedsTwoButtonMouse=n
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
AppNeedsArrowKeys=y
# Application needs text input (y) or (n), enables button for text input on screen
AppNeedsTextInput=n
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
AppUsesJoystick=n
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=n
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
AppUsesAccelerometer=n
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
AppUsesGyroscope=n
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
AppUsesMultitouch=n
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
# This option will add additional permission to Android manifest (y)/(n)
AppRecordsAudio=n
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
# This option is reported to be buggy, sometimes failing to restore video state
NonBlockingSwapBuffers=n
# Redefine common hardware keys to SDL keysyms
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=0
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="0 1 2 3 4 5 6 7 8 9"
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
RedefinedKeysGamepad="0 1 2 3 4 5 6 7 8 9"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=0
HiddenMenuOptions='OptionalDownloadConfig'
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig'
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
MultiABI=y
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
# Application version code (integer)
AppVersionCode=100
# Application user-visible version name (string)
AppVersionName="1.00"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="avutil avcodec avformat avdevice swscale swresample avresample avfilter"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags='-O3 -Ijni/ffmpeg'
# Additional LDFLAGS for application
AppLdflags=''
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=n
# Build only following subdirs (empty will build all dirs, ignored with custom script)
AppSubdirsBuild=''
# Exclude these files from build
AppBuildExclude=''
AppCmdline='ffplay -loglevel verbose -nostats small.mp4' # http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi
# Application command line parameters, including app name as 0-th param
AppCmdline='ffplay -loglevel verbose -nostats small.mp4'
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
ReadmeText='^Readme text'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
MinimumScreenSize=s
# Your AdMob Publisher ID, (n) if you don't want advertisements
AdmobPublisherId=n
# Your AdMob test device ID, to receive a test ad
AdmobTestDeviceId=
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
AdmobBannerSize=

View File

@@ -133,14 +133,14 @@ AppTouchscreenKeyboardKeysAmount=6
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
RedefinedKeysScreenKb="RETURN BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="Change_weapon Sniper_view Show_scores Center_view Fire Jump"
RedefinedKeysScreenKbNames="Change_weapon Sniper_view Show_scores Quick_rotate Fire Jump"
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
RedefinedKeysGamepad="SLASH BACKSPACE TAB END SPACE LCTRL SPACE LCTRL V RETURN"
RedefinedKeysGamepad="RETURN BACKSPACE TAB END SPACE LCTRL SPACE LCTRL V E"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=3000

View File

@@ -133,10 +133,21 @@ AppTouchscreenKeyboardKeysAmount=4
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="SPACE PAGEDOWN PAGEUP TAB RCTRL RETURN"
RedefinedKeysScreenKb="SPACE PAGEDOWN PAGEUP TAB RETURN RCTRL"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="Jump Next_weapon Previous_weapon Show_scores Fire Hook"
RedefinedKeysScreenKbNames="Jump Next_weapon Previous_weapon Show_scores Hook Fire"
# On-screen keys theme
# 1 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
# 2 = Simple Theme by Beholder (white, with gamepad joystick)
# 3 = Sun by Sirea (yellow, with round joystick)
# 4 = Mystery by Gerstrong (unknown color, unknown joystick)
TouchscreenKeysTheme=3
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
RedefinedKeysGamepad="RETURN PAGEDOWN TAB T SPACE RCTRL RETURN RCTRL SPACE PAGEDOWN"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=3000
@@ -159,16 +170,16 @@ MultiABI=y
AppMinimumRAM=0
# Application version code (integer)
AppVersionCode=06212
AppVersionCode=06213
# Application user-visible version name (string)
AppVersionName="0.6.2.12"
AppVersionName="0.6.2.13"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=y
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="data .teeworlds"
DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
@@ -198,7 +209,7 @@ AppCmdline=''
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
ReadmeText='Tap left joystick to launch hook\\\\nSwipe left joystick up or down to jump'
ReadmeText='Tap left joystick to launch hook\\nSwipe left joystick up or down to jump^ouya:'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge

View File

@@ -0,0 +1,219 @@
# The application settings for Android libSDL port
AppSettingVersion=19
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="SDL MIDI music test"
# Specify reversed site name of application (e.x. com.mysite.myapp)
AppFullName=net.olofson.ballfield.testmidi
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=n
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
AppDataDownloadUrl="!Game data|ballfield2.zip^!Music|MilkyTracker-ExampleSongs.zip^!MIDI instruments|timidity.zip|http://sourceforge.net/projects/libsdl-android/files/timidity.zip"
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
VideoDepthBpp=16
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedDepthBuffer=n
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedStencilBuffer=n
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles2=n
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
SwVideoMode=y
# Application video output will be resized to fit into native device screen (y)/(n)
SdlVideoResize=y
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
CompatibilityHacks=n
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
CompatibilityHacksStaticInit=n
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
CompatibilityHacksTextInputEmulatesHwKeyboard=n
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=n
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
CompatibilityHacksAppIgnoresAudioBufferSize=n
# Hack for VCMI: preload additional shared libraries before aplication start
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=y
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
AppNeedsTwoButtonMouse=y
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
AppNeedsArrowKeys=n
# Application needs text input (y) or (n), enables button for text input on screen
AppNeedsTextInput=y
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
AppUsesJoystick=n
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=n
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
AppUsesAccelerometer=n
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
AppUsesGyroscope=n
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
AppUsesMultitouch=y
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
# This option will add additional permission to Android manifest (y)/(n)
AppRecordsAudio=n
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
# This option is reported to be buggy, sometimes failing to restore video state
NonBlockingSwapBuffers=n
# Redefine common hardware keys to SDL keysyms
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=0
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="0 1 2 3 4 5 6 7 8 9"
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
RedefinedKeysGamepad="0 1 2 3 4 5 6 7 8 9"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=3000
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMouse.DisplaySizeConfig'
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
MultiABI=y
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
# Application version code (integer)
AppVersionCode=101
# Application user-visible version name (string)
AppVersionName="1.01"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="sdl_mixer sdl_image"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags='-O2 -finline-functions'
# Additional LDFLAGS for application
AppLdflags=''
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=
# Build only following subdirs (empty will build all dirs, ignored with custom script)
AppSubdirsBuild=''
# Exclude these files from build
AppBuildExclude=''
# Application command line parameters, including app name as 0-th param
AppCmdline=''
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
ReadmeText='^Readme text'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
MinimumScreenSize=s
# Your AdMob Publisher ID, (n) if you don't want advertisements
AdmobPublisherId=n
# Your AdMob test device ID, to receive a test ad
AdmobTestDeviceId=
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
AdmobBannerSize=

View File

@@ -0,0 +1,750 @@
/*
* "Ballfield"
*
* (C) David Olofson <david@olofson.net>, 2002, 2003
*
* This software is released under the terms of the GPL.
*
* Contact author for permission if you want to use this
* software, or work derived from it, under other terms.
*/
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <android/log.h>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
/*----------------------------------------------------------
Definitions...
----------------------------------------------------------*/
#define SCREEN_W 320
#define SCREEN_H 240
#define BALLS 300
#define COLORS 2
typedef struct
{
Sint32 x, y, z; /* Position */
Uint32 c; /* Color */
} point_t;
/*
* Ballfield
*/
typedef struct
{
point_t points[BALLS];
SDL_Rect *frames;
SDL_Surface *gfx[COLORS];
int use_alpha;
} ballfield_t;
/*
* Size of the biggest ball image in pixels
*
* Balls are scaled down and *packed*, one pixel
* smaller for each frame down to 1x1. The actual
* image width is (obviously...) the same as the
* width of the first frame.
*/
#define BALL_W 32
#define BALL_H 32
/*----------------------------------------------------------
General tool functions
----------------------------------------------------------*/
/*
* Bump areas of low and high alpha to 0% or 100%
* respectively, just in case the graphics contains
* "alpha noise".
*/
SDL_Surface *clean_alpha(SDL_Surface *s)
{
SDL_Surface *work;
SDL_Rect r;
Uint32 *pixels;
int pp;
int x, y;
work = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h,
32, 0xff000000, 0x00ff0000, 0x0000ff00,
0x000000ff);
if(!work)
return NULL;
r.x = r.y = 0;
r.w = s->w;
r.h = s->h;
if(SDL_BlitSurface(s, &r, work, NULL) < 0)
{
SDL_FreeSurface(work);
return NULL;
}
SDL_LockSurface(work);
pixels = (Uint32 *)work->pixels;
pp = work->pitch / sizeof(Uint32);
for(y = 0; y < work->h; ++y)
for(x = 0; x < work->w; ++x)
{
Uint32 pix = pixels[y*pp + x];
switch((pix & 0xff) >> 4)
{
case 0:
pix = 0x00000000;
break;
default:
break;
case 15:
pix |= 0xff;
break;
}
pixels[y*pp + x] = pix;
}
SDL_UnlockSurface(work);
return work;
}
/*
* Load and convert an antialiazed, zoomed set of sprites.
*/
SDL_Surface *load_zoomed(char *name, int alpha)
{
SDL_Surface *sprites;
SDL_Surface *temp = IMG_Load(name);
if(!temp)
return NULL;
/*
sprites = temp;
SDL_SetAlpha(sprites, 0, 255);
temp = clean_alpha(sprites);
SDL_FreeSurface(sprites);
*/
if(!temp)
{
fprintf(stderr, "Could not clean alpha!\n");
return NULL;
}
if(alpha)
{
SDL_SetAlpha(temp, 0, SDL_ALPHA_OPAQUE);
sprites = SDL_DisplayFormatAlpha(temp);
}
else
{
SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
SDL_MapRGB(temp->format, 0, 0, 0));
sprites = SDL_DisplayFormat(temp);
}
SDL_FreeSurface(temp);
return sprites;
}
void print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, float value)
{
char buf[16];
int val = (int)(value * 10.0);
int pos, p = 0;
SDL_Rect from;
/* Sign */
if(val < 0)
{
buf[p++] = 10;
val = -val;
}
/* Integer part */
pos = 10000000;
while(pos > 1)
{
int num = val / pos;
val -= num * pos;
pos /= 10;
if(p || num)
buf[p++] = num;
}
/* Decimals */
if(val / pos)
{
buf[p++] = 11;
while(pos > 0)
{
int num = val / pos;
val -= num * pos;
pos /= 10;
buf[p++] = num;
}
}
/* Render! */
from.y = 0;
from.w = 7;
from.h = 10;
for(pos = 0; pos < p; ++pos)
{
SDL_Rect to;
to.x = x + pos * 7;
to.y = y;
from.x = buf[pos] * 7;
SDL_BlitSurface(font, &from, dst, &to);
}
}
void print_num_hex(SDL_Surface *dst, SDL_Surface *font, int x, int y, unsigned val)
{
char buf[8];
int pos, p = 0;
SDL_Rect from;
//val = htonl(val); // Big-endian
/* Render! */
from.y = 0;
from.w = 7;
from.h = 10;
for(pos = 0; pos < 8; ++pos)
{
SDL_Rect to;
to.x = 8 * 7 - (x + pos * 7); // Little-endian number wrapped backwards
to.y = y;
from.x = ( ( val >> (pos * 4) ) & 0xf ) * 7;
SDL_BlitSurface(font, &from, dst, &to);
}
}
/*----------------------------------------------------------
ballfield_t functions
----------------------------------------------------------*/
ballfield_t *ballfield_init(void)
{
int i;
ballfield_t *bf = (ballfield_t *)calloc(sizeof(ballfield_t), 1);
if(!bf)
return NULL;
for(i = 0; i < BALLS; ++i)
{
bf->points[i].x = rand() % 0x20000;
bf->points[i].y = rand() % 0x20000;
bf->points[i].z = 0x20000 * i / BALLS;
if(rand() % 100 > 80)
bf->points[i].c = 1;
else
bf->points[i].c = 0;
}
return bf;
}
void ballfield_free(ballfield_t *bf)
{
int i;
for(i = 0; i < COLORS; ++i)
SDL_FreeSurface(bf->gfx[i]);
}
static int ballfield_init_frames(ballfield_t *bf)
{
int i, j;
/*
* Set up source rects for all frames
*/
bf->frames = (SDL_Rect *)calloc(sizeof(SDL_Rect), bf->gfx[0]->w);
if(!bf->frames)
{
fprintf(stderr, "No memory for frame rects!\n");
return -1;
}
for(j = 0, i = 0; i < bf->gfx[0]->w; ++i)
{
bf->frames[i].x = 0;
bf->frames[i].y = j;
bf->frames[i].w = bf->gfx[0]->w - i;
bf->frames[i].h = bf->gfx[0]->w - i;
j += bf->gfx[0]->w - i;
}
return 0;
}
int ballfield_load_gfx(ballfield_t *bf, char *name, unsigned int color)
{
if(color >= COLORS)
return -1;
bf->gfx[color] = load_zoomed(name, bf->use_alpha);
if(!bf->gfx[color])
return -2;
if(!bf->frames)
return ballfield_init_frames(bf);
return 0;
}
void ballfield_move(ballfield_t *bf, Sint32 dx, Sint32 dy, Sint32 dz)
{
int i;
for(i = 0; i < BALLS; ++i)
{
bf->points[i].x += dx;
bf->points[i].x &= 0x1ffff;
bf->points[i].y += dy;
bf->points[i].y &= 0x1ffff;
bf->points[i].z += dz;
bf->points[i].z &= 0x1ffff;
}
}
void ballfield_render(ballfield_t *bf, SDL_Surface *screen)
{
int i, j, z;
/*
* Find the ball with the highest Z.
*/
z = 0;
j = 0;
for(i = 0; i < BALLS; ++i)
{
if(bf->points[i].z > z)
{
j = i;
z = bf->points[i].z;
}
}
/*
* Render all balls in back->front order.
*/
for(i = 0; i < BALLS; ++i)
{
SDL_Rect r;
int f;
z = bf->points[j].z;
z += 50;
f = ((bf->frames[0].w << 12) + 100000) / z;
f = bf->frames[0].w - f;
if(f < 0)
f = 0;
else if(f > bf->frames[0].w - 1)
f = bf->frames[0].w - 1;
z >>= 7;
z += 1;
r.x = (bf->points[j].x - 0x10000) / z;
r.y = (bf->points[j].y - 0x10000) / z;
r.x += (screen->w - bf->frames[f].w) >> 1;
r.y += (screen->h - bf->frames[f].h) >> 1;
SDL_BlitSurface(bf->gfx[bf->points[j].c],
&bf->frames[f], screen, &r);
if(--j < 0)
j = BALLS - 1;
}
}
/*----------------------------------------------------------
Other rendering functions
----------------------------------------------------------*/
/*
* Draw tiled background image with offset.
*/
void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
{
/*
int x, y;
SDL_Rect r;
if(xo < 0)
xo += back->w*(-xo/back->w + 1);
if(yo < 0)
yo += back->h*(-yo/back->h + 1);
xo %= back->w;
yo %= back->h;
for(y = -yo; y < screen->h; y += back->h)
for(x = -xo; x < screen->w; x += back->w)
{
r.x = x;
r.y = y;
SDL_BlitSurface(back, NULL, screen, &r);
}
*/
SDL_Rect r;
xo %= back->w/8;
yo %= back->h/8;
r.x = xo - back->w/2 + screen->w/2;
r.y = yo - back->h/2 + screen->h/2;
r.w = back->w;
r.h = back->h;
SDL_BlitSurface(back, NULL, screen, &r);
}
#pragma GCC push_options
#pragma GCC optimize ("O0")
extern "C" unsigned misaligned_mem_access(unsigned value, unsigned shift);
unsigned misaligned_mem_access(unsigned value, unsigned shift)
{
volatile unsigned *iptr = NULL;
volatile char *cptr = NULL;
volatile unsigned ret = 0;
#if defined(__GNUC__)
# if defined(__i386__)
/* Enable Alignment Checking on x86 */
__asm__("pushf\norl $0x40000,(%esp)\npopf");
# elif defined(__x86_64__)
/* Enable Alignment Checking on x86_64 */
__asm__("pushf\norl $0x40000,(%rsp)\npopf");
# endif
#endif
/* malloc() always provides aligned memory */
cptr = (volatile char *)malloc(sizeof(unsigned) + 10);
/* Increment the pointer by one, making it misaligned */
iptr = (volatile unsigned *) (cptr + shift);
/* Dereference it as an int pointer, causing an unaligned access */
/* GCC usually tries to optimize this, thus our test succeeds when it should fail, if we remove "volatile" specifiers */
*iptr = value;
//memcpy( &ret, iptr, sizeof(unsigned) );
ret = *iptr;
/*
*((volatile char *)(&ret) + 0) = cptr[shift+0];
*((volatile char *)(&ret) + 1) = cptr[shift+1];
*((volatile char *)(&ret) + 2) = cptr[shift+2];
*((volatile char *)(&ret) + 3) = cptr[shift+3];
*/
free((void *)cptr);
return ret;
}
#pragma GCC pop_options
/*----------------------------------------------------------
main()
----------------------------------------------------------*/
extern "C" void unaligned_test(unsigned * data, unsigned * target);
extern "C" unsigned val0, val1, val2, val3, val4;
unsigned val0 = 0x01234567, val1, val2, val3;
int main(int argc, char* argv[])
{
ballfield_t *balls;
SDL_Surface *screen;
SDL_Surface *temp_image;
SDL_Surface *back, *logo, *font, *font_hex;
SDL_Event event;
int bpp = 16,
flags = 0,
alpha = 1;
int x_offs = 0, y_offs = 0;
long tick,
last_tick,
last_avg_tick;
double t = 0;
float dt;
int i;
float fps = 0.0;
int fps_count = 0;
int fps_start = 0;
float x_speed, y_speed, z_speed;
Mix_Music *music = NULL;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
atexit(SDL_Quit);
if(Mix_OpenAudio(44100, AUDIO_S16, 2, 8192))
{
fprintf(stderr, "Failed to open audio\n");
exit(1);
}
if((music = Mix_LoadMUS("modern_motion.mid")) == NULL)
{
fprintf(stderr, "Failed to load music file modern_motion.mid\n");
exit(1);
}
Mix_PlayMusic(music, -1);
screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, bpp, flags);
if(!screen)
{
fprintf(stderr, "Failed to open screen!\n");
exit(-1);
}
SDL_WM_SetCaption("Ballfield", "Ballfield");
if(flags & SDL_FULLSCREEN)
SDL_ShowCursor(0);
balls = ballfield_init();
if(!balls)
{
fprintf(stderr, "Failed to create ballfield!\n");
exit(-1);
}
/*
* Load and prepare balls...
*/
balls->use_alpha = alpha;
if( ballfield_load_gfx(balls, "blueball.png", 0)
||
ballfield_load_gfx(balls, "redball.png", 1) )
{
fprintf(stderr, "Could not load balls!\n");
exit(-1);
}
/*
* Load background image
*/
temp_image = IMG_Load("sun.gif");
if(!temp_image)
{
fprintf(stderr, "Could not load background!\n");
exit(-1);
}
back = SDL_DisplayFormat(temp_image);
SDL_FreeSurface(temp_image);
/*
* Load logo
*/
temp_image = SDL_LoadBMP("logo.bmp");
if(!temp_image)
{
fprintf(stderr, "Could not load logo!\n");
exit(-1);
}
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
SDL_MapRGB(temp_image->format, 255, 0, 255));
logo = SDL_DisplayFormat(temp_image);
SDL_FreeSurface(temp_image);
/*
* Load font
*/
temp_image = SDL_LoadBMP("font7x10.bmp");
if(!temp_image)
{
fprintf(stderr, "Could not load font!\n");
exit(-1);
}
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
SDL_MapRGB(temp_image->format, 255, 0, 255));
font = SDL_DisplayFormat(temp_image);
SDL_FreeSurface(temp_image);
temp_image = SDL_LoadBMP("font7x10-hex.bmp");
if(!temp_image)
{
fprintf(stderr, "Could not load hex font!\n");
exit(-1);
}
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
SDL_MapRGB(temp_image->format, 255, 0, 255));
font_hex = SDL_DisplayFormat(temp_image);
SDL_FreeSurface(temp_image);
last_avg_tick = last_tick = SDL_GetTicks();
enum { MAX_POINTERS = 16, PTR_PRESSED = 4 };
int touchPointers[MAX_POINTERS][5];
memset(touchPointers, 0, sizeof(touchPointers));
SDL_Joystick * joysticks[MAX_POINTERS+1];
for(i=0; i<MAX_POINTERS; i++)
joysticks[i] = SDL_JoystickOpen(i);
while(1)
{
SDL_Rect r;
/* Timing */
tick = SDL_GetTicks();
dt = (tick - last_tick) * 0.001f;
last_tick = tick;
if( bpp == 32 )
SDL_FillRect(screen, NULL, 0); // Clear alpha channel
/* Background image */
tiled_back(back, screen, x_offs>>11, y_offs>>11);
/* Ballfield */
ballfield_render(balls, screen);
/* Logo */
r.x = 2;
r.y = 2;
SDL_BlitSurface(logo, NULL, screen, &r);
/* FPS counter */
if(tick > fps_start + 1000)
{
fps = (float)fps_count * 1000.0 / (tick - fps_start);
fps_count = 0;
fps_start = tick;
*((unsigned char *)(&val0) + 0) += 1;
*((unsigned char *)(&val0) + 1) += 1;
*((unsigned char *)(&val0) + 2) += 1;
*((unsigned char *)(&val0) + 3) += 1;
}
// MISALIGNED MEMORY ACCESS HERE! However all the devices that I have won't report it and won't send a signal or write to the /proc/kmsg,
// despite the /proc/cpu/alignment flag set.
val1 = misaligned_mem_access(val0, 1);
val2 = misaligned_mem_access(val0, 2);
val3 = misaligned_mem_access(val0, 3);
/*
print_num_hex(screen, font_hex, 0, 40, val0);
print_num_hex(screen, font_hex, 0, 60, val1);
print_num_hex(screen, font_hex, 0, 80, val2);
print_num_hex(screen, font_hex, 0, 100, val3);
*/
print_num(screen, font, screen->w-37, screen->h-12, fps);
++fps_count;
for(i=0; i<MAX_POINTERS; i++)
{
if( !touchPointers[i][PTR_PRESSED] )
continue;
r.x = touchPointers[i][0];
r.y = touchPointers[i][1];
r.w = 80 + touchPointers[i][2] / 10; // Pressure
r.h = 80 + touchPointers[i][3] / 10; // Touch point size
r.x -= r.w/2;
r.y -= r.h/2;
SDL_FillRect(screen, &r, 0xaaaaaa);
print_num(screen, font, r.x, r.y, i+1);
}
int mx, my;
int b = SDL_GetMouseState(&mx, &my);
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse buttons: %d", b);
Uint32 color = 0xff;
if( b )
{
color = 0;
if( b & SDL_BUTTON_LMASK )
color |= 0xf000;
if( b & SDL_BUTTON_RMASK )
color |= 0x1f0;
if( b & SDL_BUTTON_MMASK )
color |= 0x1f;
}
r.x = mx;
r.y = my;
r.w = 30;
r.h = 30;
r.x -= r.w/2;
r.y -= r.h/2;
SDL_FillRect(screen, &r, color);
SDL_Flip(SDL_GetVideoSurface());
SDL_Event evt;
while( SDL_PollEvent(&evt) )
{
if(evt.type == SDL_KEYUP || evt.type == SDL_KEYDOWN)
{
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %d scancode %d mod %d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode);
if(evt.key.keysym.sym == SDLK_ESCAPE)
return 0;
}
if(evt.type == SDL_VIDEORESIZE)
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL resize event: %d x %d", evt.resize.w, evt.resize.h);
if(evt.type == SDL_ACTIVEEVENT)
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state);
/*
if( evt.type == SDL_ACTIVEEVENT && evt.active.gain == 0 && evt.active.state & SDL_APPACTIVE )
{
// We've lost GL context, we are not allowed to do any GFX output here, or app will crash!
while( 1 )
{
SDL_PollEvent(&evt);
if( evt.type == SDL_ACTIVEEVENT && evt.active.gain && evt.active.state & SDL_APPACTIVE )
{
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state);
SDL_Flip(SDL_GetVideoSurface()); // One SDL_Flip() call is required here to restore OpenGL context
// Re-load all textures, matrixes and all other GL states if we're in SDL+OpenGL mode
// Re-load all images to SDL_Texture if we're using it
// Now we can draw
break;
}
// Process network stuff, maybe play some sounds using SDL_ANDROID_PauseAudioPlayback() / SDL_ANDROID_ResumeAudioPlayback()
SDL_Delay(300);
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Waiting");
}
}
*/
if( evt.type == SDL_JOYAXISMOTION )
{
if( evt.jaxis.which == 0 ) // 0 = The accelerometer
continue;
int joyid = evt.jaxis.which - 1;
touchPointers[joyid][evt.jaxis.axis] = evt.jaxis.value; // Axis 0 and 1 are coordinates, 2 and 3 are pressure and touch point radius
}
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
{
if( evt.jbutton.which == 0 ) // 0 = The accelerometer
continue;
int joyid = evt.jbutton.which - 1;
touchPointers[joyid][PTR_PRESSED] = (evt.jbutton.state == SDL_PRESSED);
}
}
/* Animate */
x_speed = 500.0 * sin(t * 0.37);
y_speed = 500.0 * sin(t * 0.53);
z_speed = 400.0 * sin(t * 0.21);
ballfield_move(balls, x_speed, y_speed, z_speed);
x_offs -= x_speed;
y_offs -= y_speed;
t += dt;
}
ballfield_free(balls);
SDL_FreeSurface(back);
SDL_FreeSurface(logo);
SDL_FreeSurface(font);
std::ostringstream os;
os << "lalala" << std::endl << "more text" << std::endl;
std::cout << os.str() << std::endl << "text text" << std::endl;
exit(0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -1,62 +1,215 @@
# The application settings for Android libSDL port
AppSettingVersion=17
AppSettingVersion=19
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="SDL music test"
# Specify reversed site name of application (e.x. com.mysite.myapp)
AppFullName=net.olofson.ballfield.testmusic
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=n
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
AppDataDownloadUrl="!Game data|ballfield2.zip^!Music|MilkyTracker-ExampleSongs.zip"
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
VideoDepthBpp=16
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedDepthBuffer=n
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedStencilBuffer=n
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles2=n
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
SwVideoMode=y
# Application video output will be resized to fit into native device screen (y)/(n)
SdlVideoResize=y
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
CompatibilityHacks=n
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
CompatibilityHacksStaticInit=n
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
CompatibilityHacksTextInputEmulatesHwKeyboard=n
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=n
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
CompatibilityHacksAppIgnoresAudioBufferSize=n
# Hack for VCMI: preload additional shared libraries before aplication start
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=y
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
AppNeedsTwoButtonMouse=y
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
AppNeedsArrowKeys=n
# Application needs text input (y) or (n), enables button for text input on screen
AppNeedsTextInput=y
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
AppUsesJoystick=n
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=n
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
AppUsesAccelerometer=n
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
AppUsesGyroscope=n
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
AppUsesMultitouch=y
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
# This option will add additional permission to Android manifest (y)/(n)
AppRecordsAudio=n
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
# This option is reported to be buggy, sometimes failing to restore video state
NonBlockingSwapBuffers=n
# Redefine common hardware keys to SDL keysyms
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=0
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
AppTouchscreenKeyboardKeysAmountAutoFire=0
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9"
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
RedefinedKeysScreenKbNames="0 1 2 3 4 5 6 7 8 9"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=3000
HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMouse.DisplaySizeConfig'
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
MultiABI=y
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
# Application version code (integer)
AppVersionCode=101
# Application user-visible version name (string)
AppVersionName="1.01"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="sdl_mixer sdl_image"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags='-O2 -finline-functions'
# Additional LDFLAGS for application
AppLdflags=''
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=
# Build only following subdirs (empty will build all dirs, ignored with custom script)
AppSubdirsBuild=''
# Exclude these files from build
AppBuildExclude=''
# Application command line parameters, including app name as 0-th param
AppCmdline=''
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
ReadmeText='^Readme text'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
MinimumScreenSize=s
# Your AdMob Publisher ID, (n) if you don't want advertisements
AdmobPublisherId=n
# Your AdMob test device ID, to receive a test ad
AdmobTestDeviceId=
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
AdmobBannerSize=

View File

@@ -41,6 +41,7 @@
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <string.h> // for memset()
#include <dlfcn.h>
@@ -381,9 +382,54 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
{
SDL_DisplayMode mode;
SDL_RendererInfo SDL_VideoRendererInfo;
SDL_Rect window;
SDL_ANDROID_sWindowWidth = SDL_ANDROID_sRealWindowWidth;
SDL_ANDROID_sWindowHeight = SDL_ANDROID_sRealWindowHeight;
SDL_ANDROID_ForceClearScreenRectAmount = 0;
if( SDL_ANDROID_ScreenKeep43Ratio )
{
SDL_ANDROID_sWindowWidth = (SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sRealWindowHeight) / SDL_ANDROID_sFakeWindowHeight;
SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth;
SDL_ANDROID_ForceClearScreenRectAmount = 2;
}
window.x = (SDL_ANDROID_sRealWindowWidth - SDL_ANDROID_sWindowWidth) / 2;
window.y = 0;
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;
SDL_ANDROID_ForceClearScreenRect[0].h = SDL_ANDROID_sRealWindowHeight;
SDL_ANDROID_ForceClearScreenRect[1].x = SDL_ANDROID_sRealWindowWidth - window.x;
SDL_ANDROID_ForceClearScreenRect[1].y = 0;
SDL_ANDROID_ForceClearScreenRect[1].w = window.x;
SDL_ANDROID_ForceClearScreenRect[1].h = SDL_ANDROID_sRealWindowHeight;
SDL_ANDROID_ForceClearScreenRect[2].x = window.x;
SDL_ANDROID_ForceClearScreenRect[2].y = 0;
SDL_ANDROID_ForceClearScreenRect[2].w = SDL_ANDROID_sRealWindowWidth - window.x * 2;
SDL_ANDROID_ForceClearScreenRect[2].h = window.y;
SDL_ANDROID_ForceClearScreenRect[3].x = window.x;
SDL_ANDROID_ForceClearScreenRect[3].y = SDL_ANDROID_sRealWindowHeight - window.y;
SDL_ANDROID_ForceClearScreenRect[3].w = SDL_ANDROID_sRealWindowWidth - window.x * 2;
SDL_ANDROID_ForceClearScreenRect[3].h = window.y;
SDL_SelectVideoDisplay(0);
SDL_VideoWindow = SDL_CreateWindow("", (SDL_ANDROID_sRealWindowWidth-SDL_ANDROID_sWindowWidth)/2, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
SDL_VideoWindow = SDL_CreateWindow("", window.x, window.y, window.w, window.h, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
SDL_memset(&mode, 0, sizeof(mode));
mode.format = PixelFormatEnum;
@@ -423,7 +469,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
DEBUGOUT("ANDROID_SetVideoMode() HwSurfaceCount %d HwSurfaceList %p", HwSurfaceCount, HwSurfaceList);
}
glViewport(0, 0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight);
glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sWindowHeight, 0, 0, 1);
glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0, 0, 1);
}
/* Allocate the new pixel format for the screen */

View File

@@ -54,7 +54,9 @@ int SDL_ANDROID_sWindowHeight = 0;
int SDL_ANDROID_sRealWindowWidth = 0;
int SDL_ANDROID_sRealWindowHeight = 0;
SDL_Rect SDL_ANDROID_ForceClearScreenRect[2] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
int SDL_ANDROID_ScreenKeep43Ratio = 0;
SDL_Rect SDL_ANDROID_ForceClearScreenRect[4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
int SDL_ANDROID_ForceClearScreenRectAmount = 0;
// Extremely wicked JNI environment to call Java functions from C code
@@ -162,38 +164,16 @@ int SDL_ANDROID_CallJavaSwapBuffers()
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoRenderer_nativeResize) ( JNIEnv* env, jobject thiz, jint w, jint h, jint keepRatio )
{
if( SDL_ANDROID_sWindowWidth == 0 )
if( SDL_ANDROID_sRealWindowWidth == 0 )
{
SDL_ANDROID_sRealWindowWidth = w;
SDL_ANDROID_sRealWindowHeight = h;
#if SDL_VERSION_ATLEAST(1,3,0)
// Not supported in SDL 1.3
#else
if( keepRatio )
{
// TODO: tweak that parameters when app calls SetVideoMode(), not here - app may request something else than 640x480, it's okay for most apps though
SDL_ANDROID_sWindowWidth = (SDL_ANDROID_sFakeWindowWidth*h)/SDL_ANDROID_sFakeWindowHeight;
SDL_ANDROID_sWindowHeight = h;
SDL_ANDROID_ForceClearScreenRect[0].x = 0;
SDL_ANDROID_ForceClearScreenRect[0].y = 0;
SDL_ANDROID_ForceClearScreenRect[0].w = (SDL_ANDROID_sRealWindowWidth - SDL_ANDROID_sWindowWidth) / 2;
SDL_ANDROID_ForceClearScreenRect[0].h = h;
SDL_ANDROID_ForceClearScreenRect[1].x = SDL_ANDROID_sRealWindowWidth - SDL_ANDROID_ForceClearScreenRect[0].w;
SDL_ANDROID_ForceClearScreenRect[1].y = 0;
SDL_ANDROID_ForceClearScreenRect[1].w = SDL_ANDROID_ForceClearScreenRect[0].w;
SDL_ANDROID_ForceClearScreenRect[1].h = h;
SDL_ANDROID_ForceClearScreenRectAmount = 2;
}
else
#endif
{
SDL_ANDROID_sWindowWidth = w;
SDL_ANDROID_sWindowHeight = h;
SDL_ANDROID_ForceClearScreenRectAmount = 0;
}
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d, virtual screen %dx%d", w, h, SDL_ANDROID_sWindowWidth, SDL_ANDROID_sWindowHeight );
SDL_ANDROID_sWindowWidth = w;
SDL_ANDROID_sWindowHeight = h;
SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth;
SDL_ANDROID_TouchscreenCalibrationHeight = SDL_ANDROID_sWindowHeight;
SDL_ANDROID_ScreenKeep43Ratio = keepRatio;
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d", w, h );
}
}

View File

@@ -36,6 +36,7 @@ extern int SDL_ANDROID_sRealWindowWidth;
extern int SDL_ANDROID_sRealWindowHeight;
extern int SDL_ANDROID_sFakeWindowWidth; // SDL 1.2 only
extern int SDL_ANDROID_sFakeWindowHeight; // SDL 1.2 only
extern int SDL_ANDROID_ScreenKeep43Ratio;
extern int SDL_ANDROID_TouchscreenCalibrationWidth;
extern int SDL_ANDROID_TouchscreenCalibrationHeight;
extern int SDL_ANDROID_TouchscreenCalibrationX;

View File

@@ -2796,6 +2796,7 @@ SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect,
if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
return 0;
}
#if !(SDL_VIDEO_RENDER_RESIZE)
/* Clip srcrect by the same amount as dstrect was clipped */
if (dstrect->w != real_dstrect.w) {
int deltax = (real_dstrect.x - dstrect->x);
@@ -2809,6 +2810,7 @@ SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect,
real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
}
#endif
}
#if SDL_VIDEO_RENDER_RESIZE
@@ -2830,7 +2832,7 @@ SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect,
real_dstrect.y += renderer->window->y;
real_dstrect.w -= renderer->window->x;
real_dstrect.h -= renderer->window->y;
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_RenderCopy dest %d:%d+%d+%d desktop_mode %d:%d", (int)real_dstrect.x, (int)real_dstrect.y, (int)real_dstrect.w, (int)real_dstrect.h, (int)realW, (int)realH);
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_RenderCopy dst %d:%d+%d+%d realWH %d:%d", (int)real_dstrect.x, (int)real_dstrect.y, (int)real_dstrect.w, (int)real_dstrect.h, (int)realW, (int)realH);
}
#endif

View File

@@ -222,18 +222,19 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
keymap[KEYCODE_PROG_YELLOW] = SDL_KEY(F15);
keymap[KEYCODE_PROG_BLUE] = SDL_KEY(F1);
keymap[KEYCODE_APP_SWITCH] = SDL_KEY(F2);
keymap[KEYCODE_BUTTON_1] = SDL_KEY(A);
keymap[KEYCODE_BUTTON_2] = SDL_KEY(B);
keymap[KEYCODE_BUTTON_3] = SDL_KEY(C);
keymap[KEYCODE_BUTTON_4] = SDL_KEY(D);
keymap[KEYCODE_BUTTON_5] = SDL_KEY(E);
keymap[KEYCODE_BUTTON_6] = SDL_KEY(F);
keymap[KEYCODE_BUTTON_7] = SDL_KEY(G);
keymap[KEYCODE_BUTTON_8] = SDL_KEY(H);
keymap[KEYCODE_BUTTON_9] = SDL_KEY(I);
keymap[KEYCODE_BUTTON_10] = SDL_KEY(J);
keymap[KEYCODE_BUTTON_11] = SDL_KEY(K);
keymap[KEYCODE_BUTTON_12] = SDL_KEY(L);
// Key layout of my cheap crappy Datex gamepad, USB identifier is "DragonRise Inc."
keymap[KEYCODE_BUTTON_1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_3));
keymap[KEYCODE_BUTTON_2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_1));
keymap[KEYCODE_BUTTON_3] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_0));
keymap[KEYCODE_BUTTON_4] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_2));
keymap[KEYCODE_BUTTON_5] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_4));
keymap[KEYCODE_BUTTON_6] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_5));
keymap[KEYCODE_BUTTON_7] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_6));
keymap[KEYCODE_BUTTON_8] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_7));
keymap[KEYCODE_BUTTON_9] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_5));
keymap[KEYCODE_BUTTON_10] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_4));
keymap[KEYCODE_BUTTON_11] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_8));
keymap[KEYCODE_BUTTON_12] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_GAMEPAD_KEYCODE_9));
keymap[KEYCODE_BUTTON_13] = SDL_KEY(M);
keymap[KEYCODE_BUTTON_14] = SDL_KEY(N);
keymap[KEYCODE_BUTTON_15] = SDL_KEY(O);

View File

@@ -1,14 +1,8 @@
Requested features (see also bugs.txt)
======================================
- Redesign on-screen keyboard layout dialog, to show all keys, and to use dragon droppings.
- Option for default on-screen key theme in AndroidAppSettings.cfg.
Requested features, might never get implemented
===============================================
- Select between normal mouse input and magnifying glass/relative input automatically, based on screen size.
- Split Settings.java into several files.
- Show/hide screen controls with longpress on Text Edit button.
- Floating on-screen joystick - initially invisible, it appears when you touch the screen,
@@ -18,17 +12,28 @@ Requested features (see also bugs.txt)
- Control screen brightness with SDL_SetGamma().
- Zoom in-out whole screen in SW mode with some SDL key or gesture, as in AndroidVNC. -
- Zoom in-out whole screen in SW mode with some SDL key or gesture, as in AndroidVNC.
- Support of libjnigraphics (it will disable on-screen keyboard, only SW SDL screen surface supported).
This is not relevant already, as every device around is fast enough with GL.
- TeeWorlds: jump with gamepad button, remove it from gamepad joystick.
TODO, which will get actually done
==================================
- TeeWorlds: external mouse support.
- TeeWorlds: add accelerometer jump, improve touchscreen controls if possible.
- TeeWorlds: fix Ouya bugs (whole-screen shrink, remove controls from settings), submit to Ouya store.
- UQM: On-screen buttons are re-appearing when using gamepad and switching between game screens.
- UQM: Redesign gamepad controls.
- UQM: Arrow keys do not steer the ship.
- OpenArena: move 3-rd person camera to the side, above shoulder.
- OpenArena: finish Ouya port.
- SuperTux: Update, enable OpenGL renderer, add touchscreen jump helper.
- UfoAI: huge huge update.