Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

- Modified build system

- Initial support for touch and key events
  • Loading branch information
bieh committed Jul 27, 2010
1 parent b839e97 commit 0c36b9bb164e688bd89dbd3aa06a98986b11502b
@@ -1,6 +1,7 @@
# Makefile to build the SDL library

ANDROID_NDK=/home/paul/Projects/gsoc/sdk/android-ndk-r4
include ./android/config.cfg #get ANDROID_NDK

TOOLS_PATH=$(ANDROID_NDK)/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin
ANDROID_INCLUDES = -I$(ANDROID_NDK)/build/platforms/android-4/common/include \
-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include
File renamed without changes.
File renamed without changes.
@@ -83,14 +83,23 @@ extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyDown(JNIEnv* env
jobject obj, jint keycode){

int r = Android_OnKeyDown(keycode);
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: native key down %d, %d\n", keycode, r);
__android_log_print(ANDROID_LOG_INFO, "SDL",
"SDL: native key down %d, %d\n", keycode, r);
}

extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyUp(JNIEnv* env,
jobject obj, jint keycode){

int r = Android_OnKeyUp(keycode);
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: native key up %d, %d\n", keycode, r);
__android_log_print(ANDROID_LOG_INFO, "SDL",
"SDL: native key up %d, %d\n", keycode, r);
}

extern "C" void Java_org_libsdl_android_SDLActivity_onNativeTouch(JNIEnv* env,
jobject obj, jint action, jfloat x, jfloat y, jfloat p){
__android_log_print(ANDROID_LOG_INFO, "SDL",
"SDL: native touch event %d @ %f/%f, pressure %f\n",
action, x, y, p);
}


@@ -63,7 +63,8 @@ protected void onResume() {
public static native void nativeInit();
public static native void onNativeKeyDown(int keycode);
public static native void onNativeKeyUp(int keycode);

public static native void onNativeTouch(int action, float x,
float y, float p);



@@ -104,7 +105,8 @@ public void run(){
Because of this, that's where we set up the SDL thread
*/
class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnKeyListener {
class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
View.OnKeyListener, View.OnTouchListener {

//This is what SDL runs in. It invokes SDL_main(), eventually
private Thread mSDLThread;
@@ -122,7 +124,8 @@ public SDLSurface(Context context) {
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
setOnKeyListener(this);
setOnKeyListener(this);
setOnTouchListener(this);
}

//Called when we have a valid drawing surface
@@ -219,7 +222,7 @@ public void flipEGL(){




//Key events
public boolean onKey(View v, int keyCode, KeyEvent event){

if(event.getAction() == KeyEvent.ACTION_DOWN){
@@ -235,6 +238,19 @@ else if(event.getAction() == KeyEvent.ACTION_UP){
return false;
}

//Touch events
public boolean onTouch(View v, MotionEvent event){

int action = event.getAction();
float x = event.getX();
float y = event.getY();
float p = event.getPressure();

//TODO: Anything else we need to pass?
SDLActivity.onNativeTouch(action, x, y, p);
return true;
}


}

0 comments on commit 0c36b9b

Please sign in to comment.