- Modified build system
authorPaul Hunkin <paul@bieh.net>
Tue, 27 Jul 2010 09:58:17 +0200
changeset 47140f05f2f16fad
parent 4713 ba38983b10c2
child 4715 9bb98766eed0
- Modified build system
- Initial support for touch and key events
Makefile.android
android/scripts/acc.sh
android/scripts/ald.sh
android/testproject/jni/app-android.cpp
android/testproject/src/org/libsdl/android/SDLActivity.java
build-scripts/acc.sh
build-scripts/ald.sh
     1.1 --- a/Makefile.android	Wed Jul 07 00:43:23 2010 +1200
     1.2 +++ b/Makefile.android	Tue Jul 27 09:58:17 2010 +0200
     1.3 @@ -1,6 +1,7 @@
     1.4  # Makefile to build the SDL library
     1.5  
     1.6 -ANDROID_NDK=/home/paul/Projects/gsoc/sdk/android-ndk-r4
     1.7 +include ./android/config.cfg #get ANDROID_NDK
     1.8 +
     1.9  TOOLS_PATH=$(ANDROID_NDK)/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin
    1.10  ANDROID_INCLUDES = 	-I$(ANDROID_NDK)/build/platforms/android-4/common/include \
    1.11  					-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include 
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/android/scripts/acc.sh	Tue Jul 27 09:58:17 2010 +0200
     2.3 @@ -0,0 +1,15 @@
     2.4 +#!/bin/bash
     2.5 +ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
     2.6 +TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
     2.7 +
     2.8 +export PATH=$TOOLS_PATH:$PATH
     2.9 +
    2.10 +CC="arm-eabi-gcc"
    2.11 +
    2.12 +#cflags
    2.13 +ACC_C="	-I$ANDROID_NDK/build/platforms/android-8/common/include \
    2.14 +		-I$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/include \
    2.15 +		-DANDROID -DANDROID_NDK -c"
    2.16 +		
    2.17 +		
    2.18 +$CC $CFLAGS $ACC_C $@
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/android/scripts/ald.sh	Tue Jul 27 09:58:17 2010 +0200
     3.3 @@ -0,0 +1,20 @@
     3.4 +#!/bin/bash
     3.5 +ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
     3.6 +TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
     3.7 +ADDITIONAL_LIBS=`dirname "$0"`/android_libs/
     3.8 +
     3.9 +export PATH=$TOOLS_PATH:$PATH
    3.10 +
    3.11 +LD="arm-eabi-ld"
    3.12 +
    3.13 +#ldflags
    3.14 +ACC_L="	-rpath-link=$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    3.15 +		-dynamic-linker=/system/bin/linker \
    3.16 +		-lc -nostdlib \
    3.17 + 		$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/crtbegin_static.o \
    3.18 + 		-L$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    3.19 + 		-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 \
    3.20 + 		-L$ADDITIONAL_LIBS "
    3.21 +		
    3.22 +$LD $ACC_L $LDFLAGS $@ -lgcc
    3.23 +
     4.1 --- a/android/testproject/jni/app-android.cpp	Wed Jul 07 00:43:23 2010 +1200
     4.2 +++ b/android/testproject/jni/app-android.cpp	Tue Jul 27 09:58:17 2010 +0200
     4.3 @@ -83,14 +83,23 @@
     4.4                 jobject obj, jint keycode){
     4.5      
     4.6      int r = Android_OnKeyDown(keycode);
     4.7 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: native key down %d, %d\n", keycode, r);
     4.8 +    __android_log_print(ANDROID_LOG_INFO, "SDL", 
     4.9 +                        "SDL: native key down %d, %d\n", keycode, r);
    4.10  }
    4.11  
    4.12  extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyUp(JNIEnv*  env, 
    4.13                 jobject obj, jint keycode){
    4.14      
    4.15      int r = Android_OnKeyUp(keycode);
    4.16 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: native key up %d, %d\n", keycode, r);
    4.17 +    __android_log_print(ANDROID_LOG_INFO, "SDL", 
    4.18 +                        "SDL: native key up %d, %d\n", keycode, r);
    4.19 +}
    4.20 +
    4.21 +extern "C" void Java_org_libsdl_android_SDLActivity_onNativeTouch(JNIEnv*  env, 
    4.22 +               jobject obj, jint action, jfloat x, jfloat y, jfloat p){
    4.23 +    __android_log_print(ANDROID_LOG_INFO, "SDL", 
    4.24 +                        "SDL: native touch event %d @ %f/%f, pressure %f\n", 
    4.25 +                        action, x, y, p);
    4.26  }
    4.27  
    4.28  
     5.1 --- a/android/testproject/src/org/libsdl/android/SDLActivity.java	Wed Jul 07 00:43:23 2010 +1200
     5.2 +++ b/android/testproject/src/org/libsdl/android/SDLActivity.java	Tue Jul 27 09:58:17 2010 +0200
     5.3 @@ -63,7 +63,8 @@
     5.4      public static native void nativeInit();
     5.5      public static native void onNativeKeyDown(int keycode);
     5.6      public static native void onNativeKeyUp(int keycode);
     5.7 -
     5.8 +    public static native void onNativeTouch(int action, float x, 
     5.9 +                                            float y, float p);
    5.10  
    5.11  
    5.12  
    5.13 @@ -104,7 +105,8 @@
    5.14  
    5.15      Because of this, that's where we set up the SDL thread
    5.16  */
    5.17 -class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnKeyListener  {
    5.18 +class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, 
    5.19 +    View.OnKeyListener, View.OnTouchListener  {
    5.20  
    5.21      //This is what SDL runs in. It invokes SDL_main(), eventually
    5.22      private Thread mSDLThread;    
    5.23 @@ -122,7 +124,8 @@
    5.24          setFocusable(true);
    5.25          setFocusableInTouchMode(true);
    5.26          requestFocus();
    5.27 -        setOnKeyListener(this);      
    5.28 +        setOnKeyListener(this); 
    5.29 +        setOnTouchListener(this);     
    5.30      }
    5.31  
    5.32      //Called when we have a valid drawing surface
    5.33 @@ -219,7 +222,7 @@
    5.34  
    5.35  
    5.36    
    5.37 -
    5.38 +    //Key events
    5.39      public boolean onKey(View  v, int keyCode, KeyEvent event){
    5.40  
    5.41          if(event.getAction() == KeyEvent.ACTION_DOWN){
    5.42 @@ -235,6 +238,19 @@
    5.43          return false;
    5.44      }
    5.45  
    5.46 +    //Touch events
    5.47 +    public boolean onTouch(View v, MotionEvent event){
    5.48 +    
    5.49 +        int action = event.getAction();
    5.50 +        float x = event.getX();
    5.51 +        float y = event.getY();
    5.52 +        float p = event.getPressure();
    5.53 +
    5.54 +        //TODO: Anything else we need to pass?        
    5.55 +        SDLActivity.onNativeTouch(action, x, y, p);
    5.56 +        return true;
    5.57 +    }
    5.58 +
    5.59  
    5.60  }
    5.61  
     6.1 --- a/build-scripts/acc.sh	Wed Jul 07 00:43:23 2010 +1200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,15 +0,0 @@
     6.4 -#!/bin/bash
     6.5 -ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
     6.6 -TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
     6.7 -
     6.8 -export PATH=$TOOLS_PATH:$PATH
     6.9 -
    6.10 -CC="arm-eabi-gcc"
    6.11 -
    6.12 -#cflags
    6.13 -ACC_C="	-I$ANDROID_NDK/build/platforms/android-8/common/include \
    6.14 -		-I$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/include \
    6.15 -		-DANDROID -DANDROID_NDK -c"
    6.16 -		
    6.17 -		
    6.18 -$CC $CFLAGS $ACC_C $@
     7.1 --- a/build-scripts/ald.sh	Wed Jul 07 00:43:23 2010 +1200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,20 +0,0 @@
     7.4 -#!/bin/bash
     7.5 -ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
     7.6 -TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
     7.7 -ADDITIONAL_LIBS=`dirname "$0"`/android_libs/
     7.8 -
     7.9 -export PATH=$TOOLS_PATH:$PATH
    7.10 -
    7.11 -LD="arm-eabi-ld"
    7.12 -
    7.13 -#ldflags
    7.14 -ACC_L="	-rpath-link=$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    7.15 -		-dynamic-linker=/system/bin/linker \
    7.16 -		-lc -nostdlib \
    7.17 - 		$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/crtbegin_static.o \
    7.18 - 		-L$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    7.19 - 		-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 \
    7.20 - 		-L$ADDITIONAL_LIBS "
    7.21 -		
    7.22 -$LD $ACC_L $LDFLAGS $@ -lgcc
    7.23 -