- Modified build system
- Initial support for touch and key events --HG-- rename : build-scripts/acc.sh => android/scripts/acc.sh rename : build-scripts/ald.sh => android/scripts/ald.sh
This commit is contained in:
parent
d8e077adbb
commit
d42b7d3970
5 changed files with 33 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Makefile to build the SDL library
|
# 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
|
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 \
|
ANDROID_INCLUDES = -I$(ANDROID_NDK)/build/platforms/android-4/common/include \
|
||||||
-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include
|
-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include
|
||||||
|
|
|
@ -83,14 +83,23 @@ extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyDown(JNIEnv* env
|
||||||
jobject obj, jint keycode){
|
jobject obj, jint keycode){
|
||||||
|
|
||||||
int r = Android_OnKeyDown(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,
|
extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyUp(JNIEnv* env,
|
||||||
jobject obj, jint keycode){
|
jobject obj, jint keycode){
|
||||||
|
|
||||||
int r = Android_OnKeyUp(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 @@ public class SDLActivity extends Activity {
|
||||||
public static native void nativeInit();
|
public static native void nativeInit();
|
||||||
public static native void onNativeKeyDown(int keycode);
|
public static native void onNativeKeyDown(int keycode);
|
||||||
public static native void onNativeKeyUp(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 @@ class SDLRunner implements Runnable{
|
||||||
|
|
||||||
Because of this, that's where we set up the SDL thread
|
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
|
//This is what SDL runs in. It invokes SDL_main(), eventually
|
||||||
private Thread mSDLThread;
|
private Thread mSDLThread;
|
||||||
|
@ -123,6 +125,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
requestFocus();
|
requestFocus();
|
||||||
setOnKeyListener(this);
|
setOnKeyListener(this);
|
||||||
|
setOnTouchListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called when we have a valid drawing surface
|
//Called when we have a valid drawing surface
|
||||||
|
@ -219,7 +222,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Key events
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event){
|
public boolean onKey(View v, int keyCode, KeyEvent event){
|
||||||
|
|
||||||
if(event.getAction() == KeyEvent.ACTION_DOWN){
|
if(event.getAction() == KeyEvent.ACTION_DOWN){
|
||||||
|
@ -235,6 +238,19 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue