Skip to content

Commit

Permalink
Fixed SDL 1.3 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
pelya committed Mar 18, 2011
1 parent 9fbb3b2 commit 21bf45e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions project/jni/application/alienblaster/AndroidAppSettings.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The application settings for Android libSDL port
AppSettingVersion=16
AppSettingVersion=17
LibSdlVersion=1.3
AppName="Alien Blaster"
AppFullName=de.schwardtnet.alienblaster
Expand All @@ -9,6 +9,7 @@ AppDataDownloadUrl="!Game data|alienblaster110_data1.zip^!Game data|alienblaster
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
SwVideoMode=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
AppNeedsArrowKeys=y
Expand All @@ -29,6 +30,5 @@ CustomBuildScript=n
AppCflags='-O3'
AppLdflags=''
AppSubdirsBuild=''
AppUseCrystaXToolchain=n
AppCmdline=''
ReadmeText='^You can press "Home" now - the data will be downloaded in background^In game press "Menu" for secondary fire, "Volume Up/Down" to cycle weapons'
2 changes: 1 addition & 1 deletion project/jni/application/src
7 changes: 7 additions & 0 deletions project/jni/sdl-1.3/src/video/android/SDL_androidinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ void ProcessDeferredMouseTap()
deferredMouseTap--;
if( deferredMouseTap <= 0 )
{
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Window * window = SDL_GetFocusWindow();
if( !window )
return;
#define SDL_ANDROID_sFakeWindowWidth window->w
#define SDL_ANDROID_sFakeWindowHeight window->h
#endif
if( oldMouseX + 1 < SDL_ANDROID_sFakeWindowWidth )
SDL_ANDROID_MainThreadPushMouseMotion(oldMouseX + 1, oldMouseY);
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
Expand Down
14 changes: 11 additions & 3 deletions project/jni/sdl_main/sdl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <limits.h>
#include <jni.h>
#include <android/log.h>
#include "SDL_version.h"
#include "SDL_thread.h"
#include "SDL_main.h"

Expand All @@ -24,18 +25,21 @@
#define JAVA_EXPORT_NAME1(name,package) JAVA_EXPORT_NAME2(name,package)
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)

extern void SDL_ANDROID_MultiThreadedVideoLoopInit();
extern void SDL_ANDROID_MultiThreadedVideoLoop();

static int argc = 0;
static char ** argv = NULL;

#if SDL_VERSION_ATLEAST(1,3,0)
#else
extern void SDL_ANDROID_MultiThreadedVideoLoopInit();
extern void SDL_ANDROID_MultiThreadedVideoLoop();

static int threadedMain(void * unused)
{
SDL_main( argc, argv );
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Application closed, calling exit(0)");
exit(0);
}
#endif

extern C_LINKAGE void
JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline, jint multiThreadedVideo )
Expand Down Expand Up @@ -97,6 +101,9 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
for( i = 0; i < argc; i++ )
__android_log_print(ANDROID_LOG_INFO, "libSDL", "param %d = \"%s\"", i, argv[i]);

#if SDL_VERSION_ATLEAST(1,3,0)
SDL_main( argc, argv );
#else
if( ! multiThreadedVideo )
SDL_main( argc, argv );
else
Expand All @@ -105,6 +112,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
SDL_CreateThread(threadedMain, NULL);
SDL_ANDROID_MultiThreadedVideoLoop();
}
#endif
};

extern C_LINKAGE void
Expand Down

0 comments on commit 21bf45e

Please sign in to comment.