AdMob support added, you cannot yet hide or reposition the ad from the C code. Also did some cleanup on include files.

This commit is contained in:
pelya
2012-09-05 21:23:36 +03:00
parent 5b21ee268c
commit 96e640f78e
20 changed files with 1251 additions and 258 deletions

View File

@@ -564,6 +564,48 @@ if [ -n "$ReadmeText1" ] ; then
fi
fi
if [ -z "$AUTO" -o -z "$AdmobPublisherId" ]; then
echo
echo -n "Your AdMob Publisher ID, (n) if you don't want advertisements ($AdmobPublisherId): "
read var
if [ -n "$var" ] ; then
AdmobPublisherId="$var"
CHANGED=1
fi
fi
if [ "$AdmobPublisherId" '!=' "n" ]; then
if [ -z "$AUTO" -o -z "$AdmobTestDeviceId" ]; then
echo
echo -n "Your AdMob test device ID, to receive a test ad ($AdmobTestDeviceId): "
read var
if [ -n "$var" ] ; then
AdmobTestDeviceId="$var"
CHANGED=1
fi
fi
if [ -z "$AUTO" -o -z "$AdmobBannerSize" ]; then
echo
echo -n "Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER) ($AdmobBannerSize): "
read var
if [ -n "$var" ] ; then
AdmobBannerSize="$var"
CHANGED=1
fi
fi
fi
if [ -z "$AUTO" -o -z "$MinimumScreenSize" ]; then
echo
echo "Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens"
echo -n "Minimum screen size that application supports: (s)mall / (n)ormal / (l)arge ($MinimumScreenSize): "
read var
if [ -n "$var" ] ; then
MinimumScreenSize="$var"
CHANGED=1
fi
fi
echo
if [ -n "$CHANGED" ]; then
@@ -615,6 +657,10 @@ echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
echo AdmobPublisherId=$AdmobPublisherId >> AndroidAppSettings.cfg
echo AdmobTestDeviceId=$AdmobTestDeviceId >> AndroidAppSettings.cfg
echo AdmobBannerSize=$AdmobBannerSize >> AndroidAppSettings.cfg
fi
AppShortName=`echo $AppName | sed 's/ //g'`
@@ -811,14 +857,6 @@ fi
ReadmeText="`echo $ReadmeText | sed 's/\"/\\\\\\\\\"/g' | sed 's/[&%]//g'`"
echo Patching project/AndroidManifest.xml
cat project/AndroidManifestTemplate.xml | \
sed "s/package=.*/package=\"$AppFullName\"/" | \
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
project/AndroidManifest.xml
rm -rf project/src
mkdir -p project/src
cd project/java
@@ -829,6 +867,38 @@ for F in *.java; do
done
cd ../..
echo Patching project/AndroidManifest.xml
cat project/AndroidManifestTemplate.xml | \
sed "s/package=.*/package=\"$AppFullName\"/" | \
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
project/AndroidManifest.xml
if [ "$AdmobPublisherId" = "n" -o -z "$AdmobPublisherId" ] ; then
sed -i "/==ADMOB==/ d" project/AndroidManifest.xml
AdmobPublisherId=""
else
F=project/java/admob/Advertisement.java
echo Patching $F
echo '// DO NOT EDIT THIS FILE - it is automatically generated, edit file under project/java dir' > project/src/Advertisement.java
cat $F | sed "s/package .*;/package $AppFullName;/" >> project/src/Advertisement.java
fi
case "$MinimumScreenSize" in
n|m)
sed -i "/==SCREEN-SIZE-SMALL==/ d" project/AndroidManifest.xml
sed -i "/==SCREEN-SIZE-LARGE==/ d" project/AndroidManifest.xml
;;
l)
sed -i "/==SCREEN-SIZE-SMALL==/ d" project/AndroidManifest.xml
sed -i "/==SCREEN-SIZE-NORMAL==/ d" project/AndroidManifest.xml
;;
*)
sed -i "/==SCREEN-SIZE-NORMAL==/ d" project/AndroidManifest.xml
sed -i "/==SCREEN-SIZE-LARGE==/ d" project/AndroidManifest.xml
;;
esac
echo Patching project/src/Globals.java
cat project/src/Globals.java | \
sed "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" | \
@@ -863,6 +933,9 @@ cat project/src/Globals.java | \
sed "s@public static Settings.Menu FirstStartMenuOptions .*;@public static Settings.Menu FirstStartMenuOptions [] = { $FirstStartMenuOptions };@" | \
sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \
sed "s%public static String CommandLine = .*%public static String CommandLine = \"$AppCmdline\";%" | \
sed "s/public static String AdmobPublisherId = .*/public static String AdmobPublisherId = \"$AdmobPublisherId\";/" | \
sed "s/public static String AdmobTestDeviceId = .*/public static String AdmobTestDeviceId = \"$AdmobTestDeviceId\";/" | \
sed "s/public static String AdmobBannerSize = .*/public static String AdmobBannerSize = \"$AdmobBannerSize\";/" | \
sed "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" > \
project/src/Globals.java.1
mv -f project/src/Globals.java.1 project/src/Globals.java
@@ -897,7 +970,7 @@ done
cd ../../..
echo Cleaning up dependencies
rm -rf project/libs/* project/gen
rm -rf project/libs/*/* project/gen
for OUT in obj; do
rm -rf project/$OUT/local/*/objs*/sdl_main/* project/$OUT/local/*/libsdl_main.so
rm -rf project/$OUT/local/*/libsdl-*.so

View File

@@ -22,12 +22,17 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<!-- ==ADMOB== --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<!-- <uses-permission android:name="android.permission.VIBRATE"></uses-permission> --> <!-- Vibrator not supported yet by SDL -->
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<!-- ==SCREEN-SIZE-SMALL== --> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<!-- ==SCREEN-SIZE-NORMAL== --> <supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<!-- ==SCREEN-SIZE-LARGE== --> <supports-screens android:smallScreens="false" android:normalScreens="false" android:largeScreens="true" android:xlargeScreens="true" />
</manifest>

View File

@@ -37,7 +37,8 @@ import android.hardware.SensorEvent;
import android.widget.TextView;
class AccelerometerReader implements SensorEventListener {
class AccelerometerReader implements SensorEventListener
{
private SensorManager _manager = null;

View File

@@ -0,0 +1,46 @@
/*
Simple DirectMedia Layer
Java source code (C) 2009-2012 Sergii Pylypenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
package net.sourceforge.clonekeenplus;
import android.app.Activity;
import android.content.Context;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.view.View;
class Advertisement
{
MainActivity parent;
public Advertisement(MainActivity p)
{
parent = p;
}
public View getView()
{
return null;
}
}

View File

@@ -37,7 +37,8 @@ import android.util.Log;
import java.lang.Thread;
class AudioThread {
class AudioThread
{
private MainActivity mParent;
private AudioTrack mAudio;

View File

@@ -59,7 +59,8 @@ import java.lang.String;
import android.text.SpannedString;
class CountingInputStream extends BufferedInputStream {
class CountingInputStream extends BufferedInputStream
{
private long bytesReadMark = 0;
private long bytesRead = 0;

View File

@@ -26,7 +26,8 @@ import android.content.Context;
import java.util.Vector;
import android.view.KeyEvent;
class Globals {
class Globals
{
// These config options are modified by ChangeAppsettings.sh script - see the detailed descriptions there
public static String ApplicationName = "CommanderGenius";
public static String AppLibraries[] = { "sdl-1.2", };
@@ -61,6 +62,9 @@ class Globals {
public static int StartupMenuButtonTimeout = 3000;
public static Settings.Menu HiddenMenuOptions [] = {};
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true) };
public static String AdmobPublisherId = "";
public static String AdmobTestDeviceId = "";
public static String AdmobBannerSize = "";
// Phone-specific config, modified by user in "Change phone config" startup dialog, TODO: move this to settings
public static boolean DownloadToSdcard = true;

View File

@@ -29,8 +29,8 @@ import java.lang.reflect.Field;
// Autogenerated by hand with a command:
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
class SDL_1_2_Keycodes {
class SDL_1_2_Keycodes
{
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_BACKSPACE = 8;
public static final int SDLK_TAB = 9;
@@ -269,8 +269,8 @@ class SDL_1_2_Keycodes {
// Autogenerated by hand with a command:
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
class SDL_1_3_Keycodes {
class SDL_1_3_Keycodes
{
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_A = 4;
public static final int SDLK_B = 5;

View File

@@ -46,6 +46,7 @@ import android.content.Intent;
import android.view.View.OnKeyListener;
import android.view.MenuItem;
import android.view.Menu;
import android.view.Gravity;
import android.text.method.TextKeyListener;
import java.util.LinkedList;
import java.io.SequenceInputStream;
@@ -71,9 +72,11 @@ import android.os.Message;
import java.util.concurrent.Semaphore;
import android.content.pm.ActivityInfo;
public class MainActivity extends Activity {
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setRequestedOrientation(Globals.HorizontalOrientation ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@@ -90,12 +93,12 @@ public class MainActivity extends Activity {
System.out.println("libSDL: Creating startup screen");
_layout = new LinearLayout(this);
_layout.setOrientation(LinearLayout.VERTICAL);
_layout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout2 = new LinearLayout(this);
_layout2.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn = new Button(this);
_btn.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn.setText(getResources().getString(R.string.device_change_cfg));
class onClickListener implements View.OnClickListener
{
@@ -125,11 +128,20 @@ public class MainActivity extends Activity {
{
img.setImageResource(R.drawable.publisherlogo);
}
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout.addView(img);
_videoLayout = new FrameLayout(this);
_videoLayout.addView(_layout);
_ad = new Advertisement(this);
if( _ad.getView() != null )
{
_videoLayout.addView(_ad.getView());
_ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.RIGHT));
_ad.getView().setFocusable(true);
_ad.getView().setFocusableInTouchMode(true);
}
setContentView(_videoLayout);
@@ -232,6 +244,8 @@ public class MainActivity extends Activity {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_videoLayout.removeView(_layout);
if( _ad.getView() != null )
_videoLayout.removeView(_ad.getView());
_layout = null;
_layout2 = null;
_btn = null;
@@ -241,10 +255,18 @@ public class MainActivity extends Activity {
setContentView(_videoLayout);
mGLView = new DemoGLSurfaceView(this);
_videoLayout.addView(mGLView);
// Receive keyboard events
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
if( _ad.getView() != null )
{
_videoLayout.addView(_ad.getView());
_ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT));
_ad.getView().setFocusable(true);
_ad.getView().setFocusableInTouchMode(true);
_ad.getView().requestFocus();
}
// Receive keyboard events
DimSystemStatusBar.get().dim(_videoLayout);
DimSystemStatusBar.get().dim(mGLView);
}
@@ -261,6 +283,8 @@ public class MainActivity extends Activity {
_isPaused = true;
if( mGLView != null )
mGLView.onPause();
//if( _ad.getView() != null )
// _ad.getView().onPause();
super.onPause();
}
@@ -283,6 +307,8 @@ public class MainActivity extends Activity {
initSDL();
}
}
//if( _ad.getView() != null )
// _ad.getView().onResume();
_isPaused = false;
}
@@ -396,6 +422,41 @@ public class MainActivity extends Activity {
mGLView.requestFocus();
};
public void setAdvertisementParams(int visible, int left, int top)
{
if( _ad.getView() != null )
{
if( visible == 0 )
_ad.getView().setVisibility(View.GONE);
else
{
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT);
layout.leftMargin = left;
layout.topMargin = top;
_ad.getView().setLayoutParams(layout);
_ad.getView().setVisibility(View.VISIBLE);
}
}
}
public void getAdvertisementParams(int size[])
{
size[0] = 0;
size[1] = 0;
size[2] = 0;
size[3] = 0;
size[4] = 0;
if( _ad.getView() != null )
{
size[0] = _ad.getView().getMeasuredWidth();
size[1] = _ad.getView().getMeasuredHeight();
size[2] = (_ad.getView().getVisibility() == View.VISIBLE) ? 1 : 0;
FrameLayout.LayoutParams layout = (FrameLayout.LayoutParams) _ad.getView().getLayoutParams();
size[3] = layout.leftMargin;
size[4] = layout.topMargin;
}
}
@Override
public boolean onKeyDown(int keyCode, final KeyEvent event)
{
@@ -442,45 +503,6 @@ public class MainActivity extends Activity {
return true;
}
// Action bar support for Android 3+, which replaces the Menu button, however in emulator everything works, because it's broken
// Also this does not work, because that action bar thingie is NOT shown for fullscreen apps, so we're targetting the legacy compatibility mode here
/*
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if( mGLView != null )
{
if(item.getItemId() == 2)
{
mGLView.nativeKey( KeyEvent.KEYCODE_SEARCH, 1 );
mGLView.nativeKey( KeyEvent.KEYCODE_SEARCH, 0 );
}
else
{
mGLView.nativeKey( KeyEvent.KEYCODE_MENU, 1 );
mGLView.nativeKey( KeyEvent.KEYCODE_MENU, 0 );
}
}
else
if( keyListener != null )
{
if(item.getItemId() == 2)
keyListener.onKeyEvent(KeyEvent.KEYCODE_SEARCH);
else
keyListener.onKeyEvent(KeyEvent.KEYCODE_MENU);
}
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, 1, 0, "Menu");
menu.add(0, 2, 0, "Search");
return true;
}
*/
@Override
public boolean dispatchTouchEvent(final MotionEvent ev)
{
@@ -488,6 +510,15 @@ public class MainActivity extends Activity {
if(_screenKeyboard != null)
_screenKeyboard.dispatchTouchEvent(ev);
else
if( _ad.getView() != null && // User clicked the advertisement, ignore when user moved finger from game screen to advertisement or touches screen with several fingers
((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN ||
(ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) &&
_ad.getView().getLeft() <= (int)ev.getX() &&
_ad.getView().getRight() > (int)ev.getX() &&
_ad.getView().getTop() <= (int)ev.getY() &&
_ad.getView().getBottom() > (int)ev.getY() )
return super.dispatchTouchEvent(ev);
else
if(mGLView != null)
mGLView.onTouchEvent(ev);
else
@@ -832,6 +863,7 @@ public class MainActivity extends Activity {
private Button _btn = null;
private LinearLayout _layout = null;
private LinearLayout _layout2 = null;
private Advertisement _ad = null;
private FrameLayout _videoLayout = null;
private EditText _screenKeyboard = null;

View File

@@ -60,7 +60,6 @@ import android.content.Intent;
import android.app.PendingIntent;
import android.app.AlarmManager;
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
{

View File

@@ -0,0 +1,67 @@
/*
Simple DirectMedia Layer
Java source code (C) 2009-2012 Sergii Pylypenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
package net.sourceforge.clonekeenplus;
import android.app.Activity;
import android.content.Context;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.view.View;
import com.google.ads.*; // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
class Advertisement
{
private AdView ad;
MainActivity parent;
public Advertisement(MainActivity p)
{
parent = p;
AdSize adSize = AdSize.BANNER;
if( Globals.AdmobBannerSize.equals("BANNER") )
adSize = AdSize.BANNER;
else if( Globals.AdmobBannerSize.equals("IAB_BANNER") )
adSize = AdSize.IAB_BANNER;
else if( Globals.AdmobBannerSize.equals("IAB_LEADERBOARD") )
adSize = AdSize.IAB_LEADERBOARD;
else if( Globals.AdmobBannerSize.equals("IAB_MRECT") )
adSize = AdSize.IAB_MRECT;
else if( Globals.AdmobBannerSize.equals("IAB_WIDE_SKYSCRAPER") )
adSize = AdSize.IAB_WIDE_SKYSCRAPER;
else if( Globals.AdmobBannerSize.equals("SMART_BANNER") )
adSize = AdSize.SMART_BANNER;
ad = new AdView(parent, adSize, Globals.AdmobPublisherId);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
adRequest.addTestDevice(Globals.AdmobTestDeviceId);
ad.loadAd(adRequest);
}
public View getView()
{
return ad;
}
}

View File

@@ -0,0 +1,51 @@
# The application settings for Android libSDL port
AppSettingVersion=17
LibSdlVersion=1.2
AppName="Admob test"
AppFullName=ws.openarena.sdl
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="Game data is 1 Mb|ballfield2.zip"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
NeedGles2=n
SwVideoMode=y
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=n
CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
AppUsesMouse=y
AppNeedsTwoButtonMouse=y
ShowMouseCursor=n
ForceRelativeMouseMode=n
AppNeedsArrowKeys=n
AppNeedsTextInput=y
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=y
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
AppTouchscreenKeyboardKeysAmount=0
AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9"
StartupMenuButtonTimeout=3000
HiddenMenuOptions='OptionalDownloadConfig'
FirstStartMenuOptions=''
MultiABI=n
AppVersionCode=101
AppVersionName="1.01"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="sdl_mixer sdl_image"
CustomBuildScript=n
AppCflags='-O2 -finline-functions'
AppLdflags=''
AppSubdirsBuild=''
AppCmdline=''
ReadmeText='^Readme text'
MinimumScreenSize=s
AdmobPublisherId=a14fe4dd0ebe974
AdmobTestDeviceId=66133194946FB6C1CD0ED2EFCCB82539
AdmobBannerSize=BANNER

View File

@@ -0,0 +1,673 @@
/*
* "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 <stdlib.h>
#include <string.h>
#include <math.h>
#include <android/log.h>
#include "SDL.h"
#include "SDL_image.h"
/*----------------------------------------------------------
Definitions...
----------------------------------------------------------*/
#define SCREEN_W 320
#define SCREEN_H 200
#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);
}
/*----------------------------------------------------------
main()
----------------------------------------------------------*/
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 = SDL_HWSURFACE,
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;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
atexit(SDL_Quit);
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;
}
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 |= 0x0f;
}
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_MOUSEBUTTONUP || evt.type == SDL_MOUSEBUTTONDOWN)
{
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL mouse button event: evt %s state %s button %d coords %d:%d", evt.type == SDL_MOUSEBUTTONUP ? "UP " : "DOWN" , evt.button.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.button.button, (int)evt.button.x, (int)evt.button.y);
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);
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,56 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_android_h
#define _SDL_android_h
#include "SDL_video.h"
#include "SDL_screenkeyboard.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/*
Sets callbacks to be called when OS decides to put application to background, and restored to foreground.
*/
typedef void ( * SDL_ANDROID_ApplicationPutToBackgroundCallback_t ) (void);
extern DECLSPEC int SDLCALL SDL_ANDROID_SetApplicationPutToBackgroundCallback(
SDL_ANDROID_ApplicationPutToBackgroundCallback_t appPutToBackground,
SDL_ANDROID_ApplicationPutToBackgroundCallback_t appRestored );
/* Use these functions instead of setting volume to 0, that will save CPU and battery on device */
extern DECLSPEC int SDLCALL SDL_ANDROID_PauseAudioPlayback(void);
extern DECLSPEC int SDLCALL SDL_ANDROID_ResumeAudioPlayback(void);
extern DECLSPEC int SDLCALL SDL_ANDROID_GetAdvertisementParams(int * visible, SDL_Rect * position);
extern DECLSPEC int SDLCALL SDL_ANDROID_SetAdvertisementParams(int visible, int left, int top);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif

View File

@@ -1 +0,0 @@
../../sdl-1.3/include/SDL_config_android.h

View File

@@ -0,0 +1,168 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_android_h
#define _SDL_config_android_h
#include "SDL_platform.h"
/* This is the minimal configuration that can be used to build SDL */
#include <stdarg.h>
#include <stdint.h>
#include <sys/mman.h>
#define SDL_VIDEO_DRIVER_ANDROID 1
#define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES_GL_CONTEXT_LOSING_IMMUNE 1
/* SDL uses some OpenGL textures for drawing in-screen keyboard, so application should allocate OpenGL texture ID-s starting from this value */
#define SDL_GL_FIRST_SAFE_TEXTURE_ID 26
#define SDL_AUDIO_DRIVER_ANDROID 1
#define SDL_CDROM_DISABLED 1
#define SDL_JOYSTICK_ANDROID 1
#define SDL_HAPTIC_DUMMY 1 // TODO: add vibrator and remove that
#define SDL_HAPTIC_ANDROID 1
#define SDL_POWER_DISABLED 1 // TODO: add battery meter and remove that
#define SDL_POWER_ANDROID 1
#undef SDL_POWER_LINUX
#define SDL_LOADSO_DLOPEN 1
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
#define SDL_TIMER_UNIX 1
#define HAVE_STDIO_H 1
#define SIZEOF_VOIDP 4
#define SDL_HAS_64BIT_TYPE 1
/* FireSlash found that SDL native memcpy crashes sometimes, these defines fix it (and they are faster) */
#define HAVE_LIBC 1
#define HAVE_ALLOCA_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#undef HAVE_ICONV_H
#define HAVE_SIGNAL_H 1
#undef HAVE_ALTIVEC_H
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRDUP 1
#undef HAVE__STRREV
#undef HAVE__STRUPR
#undef HAVE__STRLWR
#define HAVE_INDEX 1
#define HAVE_RINDEX 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#undef HAVE_ITOA
#undef HAVE__LTOA
#undef HAVE__UITOA
#undef HAVE__ULTOA
#define HAVE_STRTOL
#define HAVE_STRTOUL
#undef HAVE__I64TOA
#undef HAVE__UI64TOA
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#undef HAVE__STRICMP
#define HAVE_STRCASECMP 1
#undef HAVE__STRNICMP
#define HAVE_STRNCASECMP 1
#define HAVE_SSCANF 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#undef HAVE_ICONV
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_GETPAGESIZE 1
#define HAVE_MPROTECT 1
#define HAVE_CEIL 1
#define HAVE_COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_LOG 1
#define HAVE_M_PI 1
#define HAVE_POW 1
#define HAVE_SCALBN 1
#define HAVE_SETENV 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_SYSCONF 1
#undef HAVE_SYSCTLBYNAME
#undef SDL_ALTIVEC_BLITTERS
#define SDL_ASSEMBLY_ROUTINES 1 // There is no assembly code for Arm CPU yet
#define HAVE_GCC_ATOMICS 1
#endif /* _SDL_config_minimal_h */

View File

@@ -0,0 +1 @@
../../sdl-1.2/include/SDL_android.h

View File

@@ -1,193 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_android_h
#define _SDL_config_android_h
#include "SDL_platform.h"
/* This is the minimal configuration that can be used to build SDL */
#include <stdarg.h>
#include <stdint.h>
#include <sys/mman.h>
#define SDL_VIDEO_DRIVER_ANDROID 1
#define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES_GL_CONTEXT_LOSING_IMMUNE 1
/* SDL uses some OpenGL textures for drawing in-screen keyboard, so application should allocate OpenGL texture ID-s starting from this value */
#define SDL_GL_FIRST_SAFE_TEXTURE_ID 26
#define SDL_AUDIO_DRIVER_ANDROID 1
#define SDL_CDROM_DISABLED 1
#define SDL_JOYSTICK_ANDROID 1
#define SDL_HAPTIC_DUMMY 1 // TODO: add vibrator and remove that
#define SDL_HAPTIC_ANDROID 1
#define SDL_POWER_DISABLED 1 // TODO: add battery meter and remove that
#define SDL_POWER_ANDROID 1
#undef SDL_POWER_LINUX
#define SDL_LOADSO_DLOPEN 1
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
#define SDL_TIMER_UNIX 1
#define HAVE_STDIO_H 1
#define SIZEOF_VOIDP 4
#define SDL_HAS_64BIT_TYPE 1
/* FireSlash found that SDL native memcpy crashes sometimes, these defines fix it (and they are faster) */
#define HAVE_LIBC 1
#define HAVE_ALLOCA_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#undef HAVE_ICONV_H
#define HAVE_SIGNAL_H 1
#undef HAVE_ALTIVEC_H
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRDUP 1
#undef HAVE__STRREV
#undef HAVE__STRUPR
#undef HAVE__STRLWR
#define HAVE_INDEX 1
#define HAVE_RINDEX 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#undef HAVE_ITOA
#undef HAVE__LTOA
#undef HAVE__UITOA
#undef HAVE__ULTOA
#define HAVE_STRTOL
#define HAVE_STRTOUL
#undef HAVE__I64TOA
#undef HAVE__UI64TOA
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#undef HAVE__STRICMP
#define HAVE_STRCASECMP 1
#undef HAVE__STRNICMP
#define HAVE_STRNCASECMP 1
#define HAVE_SSCANF 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#undef HAVE_ICONV
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_GETPAGESIZE 1
#define HAVE_MPROTECT 1
#define HAVE_CEIL 1
#define HAVE_COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_LOG 1
#define HAVE_M_PI 1
#define HAVE_POW 1
#define HAVE_SCALBN 1
#define HAVE_SETENV 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_SYSCONF 1
#undef HAVE_SYSCTLBYNAME
#undef SDL_ALTIVEC_BLITTERS
#define SDL_ASSEMBLY_ROUTINES 1 // There is no assembly code for Arm CPU yet
#define HAVE_GCC_ATOMICS 1
/* Prototypes for Android-specific functions */
#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
Sets callbacks to be called when OS decides to put application to background, and restored to foreground.
*/
typedef void ( * SDL_ANDROID_ApplicationPutToBackgroundCallback_t ) (void);
extern DECLSPEC int SDLCALL SDL_ANDROID_SetApplicationPutToBackgroundCallback(
SDL_ANDROID_ApplicationPutToBackgroundCallback_t appPutToBackground,
SDL_ANDROID_ApplicationPutToBackgroundCallback_t appRestored );
/* Use these functions instead of setting volume to 0, that will save CPU and battery on device */
extern DECLSPEC int SDLCALL SDL_ANDROID_PauseAudioPlayback(void);
extern DECLSPEC int SDLCALL SDL_ANDROID_ResumeAudioPlayback(void);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_config_minimal_h */

View File

@@ -0,0 +1 @@
../../sdl-1.2/include/SDL_config_android.h

View File

@@ -37,6 +37,7 @@
#include "SDL_mouse.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
#include "SDL_android.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
@@ -62,6 +63,8 @@ static jobject JavaRenderer = NULL;
static jmethodID JavaSwapBuffers = NULL;
static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
static jmethodID JavaGetAdvertisementParams = NULL;
static jmethodID JavaSetAdvertisementParams = NULL;
static int glContextLost = 0;
static int showScreenKeyboardDeferred = 0;
static const char * showScreenKeyboardOldText = "";
@@ -291,6 +294,11 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "(Ljava/lang/String;I)V");
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
// TODO: implement it
/*
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "GetAdvertisementParams", "()V");
JavaSetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "SetAdvertisementParams", "(III)V");
*/
ANDROID_InitOSKeymap();
}