# HG changeset patch # User Martin Gerhardy # Date 1364710866 -7200 # Node ID 0c704bad4830a8ea5c603e5592db5b8f444c2922 # Parent 8c891504e3255b4aeddbe31998fef12a289315b5 * extracted java classes into separate files * this is useful for easier overriding and keeping track of changes without conflicting each time diff -r 8c891504e325 -r 0c704bad4830 android-project/src/org/libsdl/app/DummyEdit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android-project/src/org/libsdl/app/DummyEdit.java Sun Mar 31 08:21:06 2013 +0200 @@ -0,0 +1,57 @@ +package org.libsdl.app; + +import android.content.Context; +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; + +/* This is a fake invisible editor view that receives the input and defines the + * pan&scan region + */ +public class DummyEdit extends View implements View.OnKeyListener { + InputConnection ic; + + public DummyEdit(Context context) { + super(context); + setFocusableInTouchMode(true); + setFocusable(true); + setOnKeyListener(this); + } + + @Override + public boolean onCheckIsTextEditor() { + return true; + } + + public boolean onKey(View v, int keyCode, KeyEvent event) { + + // This handles the hardware keyboard input + if (event.isPrintingKey()) { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1); + } + return true; + } + + if (event.getAction() == KeyEvent.ACTION_DOWN) { + SDLActivity.onNativeKeyDown(keyCode); + return true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + SDLActivity.onNativeKeyUp(keyCode); + return true; + } + + return false; + } + + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) { + ic = new SDLInputConnection(this, true); + + outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI + | 33554432 /* API 11: EditorInfo.IME_FLAG_NO_FULLSCREEN */; + + return ic; + } +} \ No newline at end of file diff -r 8c891504e325 -r 0c704bad4830 android-project/src/org/libsdl/app/SDLActivity.java --- a/android-project/src/org/libsdl/app/SDLActivity.java Fri Mar 29 21:29:57 2013 -0400 +++ b/android-project/src/org/libsdl/app/SDLActivity.java Sun Mar 31 08:21:06 2013 +0200 @@ -9,9 +9,6 @@ import android.app.*; import android.content.*; import android.view.*; -import android.view.inputmethod.BaseInputConnection; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.AbsoluteLayout; import android.os.*; @@ -518,359 +515,3 @@ } } } - -/** - Simple nativeInit() runnable -*/ -class SDLMain implements Runnable { - public void run() { - // Runs SDL_main() - SDLActivity.nativeInit(); - - //Log.v("SDL", "SDL thread terminated"); - } -} - - -/** - SDLSurface. This is what we draw on, so we need to know when it's created - in order to do anything useful. - - Because of this, that's where we set up the SDL thread -*/ -class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, - View.OnKeyListener, View.OnTouchListener, SensorEventListener { - - // Sensors - private static SensorManager mSensorManager; - - // Keep track of the surface size to normalize touch events - private static float mWidth, mHeight; - - // Startup - public SDLSurface(Context context) { - super(context); - getHolder().addCallback(this); - - setFocusable(true); - setFocusableInTouchMode(true); - requestFocus(); - setOnKeyListener(this); - setOnTouchListener(this); - - // Listen to joystick motion events if supported - if (Build.VERSION.SDK_INT >= 12) { - setOnGenericMotionListener(new SDLOnGenericMotionListener()); - } - - mSensorManager = (SensorManager)context.getSystemService("sensor"); - - // Some arbitrary defaults to avoid a potential division by zero - mWidth = 1.0f; - mHeight = 1.0f; - } - - // Called when we have a valid drawing surface - public void surfaceCreated(SurfaceHolder holder) { - Log.v("SDL", "surfaceCreated()"); - holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); - enableSensor(Sensor.TYPE_ACCELEROMETER, true); - } - - // Called when we lose the surface - public void surfaceDestroyed(SurfaceHolder holder) { - Log.v("SDL", "surfaceDestroyed()"); - if (!SDLActivity.mIsPaused) { - SDLActivity.mIsPaused = true; - SDLActivity.nativePause(); - } - enableSensor(Sensor.TYPE_ACCELEROMETER, false); - } - - // Called when the surface is resized - public void surfaceChanged(SurfaceHolder holder, - int format, int width, int height) { - Log.v("SDL", "surfaceChanged()"); - - int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default - switch (format) { - case PixelFormat.A_8: - Log.v("SDL", "pixel format A_8"); - break; - case PixelFormat.LA_88: - Log.v("SDL", "pixel format LA_88"); - break; - case PixelFormat.L_8: - Log.v("SDL", "pixel format L_8"); - break; - case PixelFormat.RGBA_4444: - Log.v("SDL", "pixel format RGBA_4444"); - sdlFormat = 0x15421002; // SDL_PIXELFORMAT_RGBA4444 - break; - case PixelFormat.RGBA_5551: - Log.v("SDL", "pixel format RGBA_5551"); - sdlFormat = 0x15441002; // SDL_PIXELFORMAT_RGBA5551 - break; - case PixelFormat.RGBA_8888: - Log.v("SDL", "pixel format RGBA_8888"); - sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888 - break; - case PixelFormat.RGBX_8888: - Log.v("SDL", "pixel format RGBX_8888"); - sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888 - break; - case PixelFormat.RGB_332: - Log.v("SDL", "pixel format RGB_332"); - sdlFormat = 0x14110801; // SDL_PIXELFORMAT_RGB332 - break; - case PixelFormat.RGB_565: - Log.v("SDL", "pixel format RGB_565"); - sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 - break; - case PixelFormat.RGB_888: - Log.v("SDL", "pixel format RGB_888"); - // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? - sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888 - break; - default: - Log.v("SDL", "pixel format unknown " + format); - break; - } - - mWidth = (float) width; - mHeight = (float) height; - SDLActivity.onNativeResize(width, height, sdlFormat); - Log.v("SDL", "Window size:" + width + "x"+height); - - SDLActivity.startApp(); - } - - // unused - public void onDraw(Canvas canvas) {} - - - - - // Listen to joystick motion events if supported (API >= 12) - private static class SDLOnGenericMotionListener implements View.OnGenericMotionListener { - @Override - public boolean onGenericMotion(View view, MotionEvent event) { - int actionPointerIndex = event.getActionIndex(); - int action = event.getActionMasked(); - - if ( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { - switch(action) { - case MotionEvent.ACTION_MOVE: - int id = SDLActivity.getJoyId( event.getDeviceId() ); - // The joystick subsystem may be uninitialized, so ignore - if (id < 0) - return true; - // Update values for all joystick axes - List axes = SDLActivity.getJoystickAxesList(id); - for (int axisIndex = 0; axisIndex < axes.size(); axisIndex++) { - SDLActivity.onNativeJoy(id, axisIndex, event.getAxisValue(axes.get(axisIndex), actionPointerIndex)); - } - - return true; - } - } - return false; - } - } - - // Key events - public boolean onKey(View v, int keyCode, KeyEvent event) { - /* Dispatch the different events depending on where they come from: - * If the input device has some joystick source (probably differing - * from the source to which the given key belongs), assume it is a - * game controller button. Otherwise, assume a keyboard key. - * This should also take care of some kinds of manually toggled soft - * keyboards (i.e. not via the SDL text input API). - */ - if ( (event.getDevice().getSources() & 0x00000010 /* API 12: InputDevice.SOURCE_CLASS_JOYSTICK*/) != 0) { - int id = SDLActivity.getJoyId( event.getDeviceId() ); - // The joystick subsystem may be uninitialized, so ignore - if (id < 0) - return true; - if (event.getAction() == KeyEvent.ACTION_DOWN) { - SDLActivity.onNativePadDown(id, keyCode); - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - SDLActivity.onNativePadUp(id, keyCode); - return true; - } - } else { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - //Log.v("SDL", "key down: " + keyCode); - SDLActivity.onNativeKeyDown(keyCode); - return true; - } - else if (event.getAction() == KeyEvent.ACTION_UP) { - //Log.v("SDL", "key up: " + keyCode); - SDLActivity.onNativeKeyUp(keyCode); - return true; - } - } - - return false; - } - - // Touch events - public boolean onTouch(View v, MotionEvent event) { - { - final int touchDevId = event.getDeviceId(); - final int pointerCount = event.getPointerCount(); - // touchId, pointerId, action, x, y, pressure - int actionPointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent. ACTION_POINTER_ID_SHIFT; /* API 8: event.getActionIndex(); */ - int pointerFingerId = event.getPointerId(actionPointerIndex); - int action = (event.getAction() & MotionEvent.ACTION_MASK); /* API 8: event.getActionMasked(); */ - - float x = event.getX(actionPointerIndex) / mWidth; - float y = event.getY(actionPointerIndex) / mHeight; - float p = event.getPressure(actionPointerIndex); - - if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) { - // TODO send motion to every pointer if its position has - // changed since prev event. - for (int i = 0; i < pointerCount; i++) { - pointerFingerId = event.getPointerId(i); - x = event.getX(i) / mWidth; - y = event.getY(i) / mHeight; - p = event.getPressure(i); - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); - } - } else { - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); - } - } - return true; - } - - // Sensor events - public void enableSensor(int sensortype, boolean enabled) { - // TODO: This uses getDefaultSensor - what if we have >1 accels? - if (enabled) { - mSensorManager.registerListener(this, - mSensorManager.getDefaultSensor(sensortype), - SensorManager.SENSOR_DELAY_GAME, null); - } else { - mSensorManager.unregisterListener(this, - mSensorManager.getDefaultSensor(sensortype)); - } - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO - } - - public void onSensorChanged(SensorEvent event) { -/* - if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - SDLActivity.onNativeAccel(event.values[0] / SensorManager.GRAVITY_EARTH, - event.values[1] / SensorManager.GRAVITY_EARTH, - event.values[2] / SensorManager.GRAVITY_EARTH); - } -*/ - } -} - -/* This is a fake invisible editor view that receives the input and defines the - * pan&scan region - */ -class DummyEdit extends View implements View.OnKeyListener { - InputConnection ic; - - public DummyEdit(Context context) { - super(context); - setFocusableInTouchMode(true); - setFocusable(true); - setOnKeyListener(this); - } - - @Override - public boolean onCheckIsTextEditor() { - return true; - } - - public boolean onKey(View v, int keyCode, KeyEvent event) { - - // This handles the hardware keyboard input - if (event.isPrintingKey()) { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1); - } - return true; - } - - if (event.getAction() == KeyEvent.ACTION_DOWN) { - SDLActivity.onNativeKeyDown(keyCode); - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - SDLActivity.onNativeKeyUp(keyCode); - return true; - } - - return false; - } - - @Override - public InputConnection onCreateInputConnection(EditorInfo outAttrs) { - ic = new SDLInputConnection(this, true); - - outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI - | 33554432 /* API 11: EditorInfo.IME_FLAG_NO_FULLSCREEN */; - - return ic; - } -} - -class SDLInputConnection extends BaseInputConnection { - - public SDLInputConnection(View targetView, boolean fullEditor) { - super(targetView, fullEditor); - - } - - @Override - public boolean sendKeyEvent(KeyEvent event) { - - /* - * This handles the keycodes from soft keyboard (and IME-translated - * input from hardkeyboard) - */ - int keyCode = event.getKeyCode(); - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (event.isPrintingKey()) { - commitText(String.valueOf((char) event.getUnicodeChar()), 1); - } - SDLActivity.onNativeKeyDown(keyCode); - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - - SDLActivity.onNativeKeyUp(keyCode); - return true; - } - return super.sendKeyEvent(event); - } - - @Override - public boolean commitText(CharSequence text, int newCursorPosition) { - - nativeCommitText(text.toString(), newCursorPosition); - - return super.commitText(text, newCursorPosition); - } - - @Override - public boolean setComposingText(CharSequence text, int newCursorPosition) { - - nativeSetComposingText(text.toString(), newCursorPosition); - - return super.setComposingText(text, newCursorPosition); - } - - public native void nativeCommitText(String text, int newCursorPosition); - - public native void nativeSetComposingText(String text, int newCursorPosition); - -} diff -r 8c891504e325 -r 0c704bad4830 android-project/src/org/libsdl/app/SDLInputConnection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android-project/src/org/libsdl/app/SDLInputConnection.java Sun Mar 31 08:21:06 2013 +0200 @@ -0,0 +1,56 @@ +package org.libsdl.app; + +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.BaseInputConnection; + +public class SDLInputConnection extends BaseInputConnection { + + public SDLInputConnection(View targetView, boolean fullEditor) { + super(targetView, fullEditor); + + } + + @Override + public boolean sendKeyEvent(KeyEvent event) { + + /* + * This handles the keycodes from soft keyboard (and IME-translated + * input from hardkeyboard) + */ + int keyCode = event.getKeyCode(); + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (event.isPrintingKey()) { + commitText(String.valueOf((char) event.getUnicodeChar()), 1); + } + SDLActivity.onNativeKeyDown(keyCode); + return true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + + SDLActivity.onNativeKeyUp(keyCode); + return true; + } + return super.sendKeyEvent(event); + } + + @Override + public boolean commitText(CharSequence text, int newCursorPosition) { + + nativeCommitText(text.toString(), newCursorPosition); + + return super.commitText(text, newCursorPosition); + } + + @Override + public boolean setComposingText(CharSequence text, int newCursorPosition) { + + nativeSetComposingText(text.toString(), newCursorPosition); + + return super.setComposingText(text, newCursorPosition); + } + + public native void nativeCommitText(String text, int newCursorPosition); + + public native void nativeSetComposingText(String text, int newCursorPosition); + +} \ No newline at end of file diff -r 8c891504e325 -r 0c704bad4830 android-project/src/org/libsdl/app/SDLMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android-project/src/org/libsdl/app/SDLMain.java Sun Mar 31 08:21:06 2013 +0200 @@ -0,0 +1,13 @@ +package org.libsdl.app; + +/** + Simple nativeInit() runnable +*/ +public class SDLMain implements Runnable { + public void run() { + // Runs SDL_main() + SDLActivity.nativeInit(); + + //Log.v("SDL", "SDL thread terminated"); + } +} \ No newline at end of file diff -r 8c891504e325 -r 0c704bad4830 android-project/src/org/libsdl/app/SDLSurface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android-project/src/org/libsdl/app/SDLSurface.java Sun Mar 31 08:21:06 2013 +0200 @@ -0,0 +1,261 @@ +package org.libsdl.app; + +import java.util.List; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.PixelFormat; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.os.Build; +import android.util.Log; +import android.view.InputDevice; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; + +/** + SDLSurface. This is what we draw on, so we need to know when it's created + in order to do anything useful. + + Because of this, that's where we set up the SDL thread +*/ +public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, + View.OnKeyListener, View.OnTouchListener, SensorEventListener { + + // Sensors + private static SensorManager mSensorManager; + + // Keep track of the surface size to normalize touch events + private static float mWidth, mHeight; + + // Startup + public SDLSurface(Context context) { + super(context); + getHolder().addCallback(this); + + setFocusable(true); + setFocusableInTouchMode(true); + requestFocus(); + setOnKeyListener(this); + setOnTouchListener(this); + + // Listen to joystick motion events if supported + if (Build.VERSION.SDK_INT >= 12) { + setOnGenericMotionListener(new SDLOnGenericMotionListener()); + } + + mSensorManager = (SensorManager)context.getSystemService("sensor"); + + // Some arbitrary defaults to avoid a potential division by zero + mWidth = 1.0f; + mHeight = 1.0f; + } + + // Called when we have a valid drawing surface + public void surfaceCreated(SurfaceHolder holder) { + Log.v("SDL", "surfaceCreated()"); + holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); + enableSensor(Sensor.TYPE_ACCELEROMETER, true); + } + + // Called when we lose the surface + public void surfaceDestroyed(SurfaceHolder holder) { + Log.v("SDL", "surfaceDestroyed()"); + if (!SDLActivity.mIsPaused) { + SDLActivity.mIsPaused = true; + SDLActivity.nativePause(); + } + enableSensor(Sensor.TYPE_ACCELEROMETER, false); + } + + // Called when the surface is resized + public void surfaceChanged(SurfaceHolder holder, + int format, int width, int height) { + Log.v("SDL", "surfaceChanged()"); + + int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default + switch (format) { + case PixelFormat.A_8: + Log.v("SDL", "pixel format A_8"); + break; + case PixelFormat.LA_88: + Log.v("SDL", "pixel format LA_88"); + break; + case PixelFormat.L_8: + Log.v("SDL", "pixel format L_8"); + break; + case PixelFormat.RGBA_4444: + Log.v("SDL", "pixel format RGBA_4444"); + sdlFormat = 0x15421002; // SDL_PIXELFORMAT_RGBA4444 + break; + case PixelFormat.RGBA_5551: + Log.v("SDL", "pixel format RGBA_5551"); + sdlFormat = 0x15441002; // SDL_PIXELFORMAT_RGBA5551 + break; + case PixelFormat.RGBA_8888: + Log.v("SDL", "pixel format RGBA_8888"); + sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888 + break; + case PixelFormat.RGBX_8888: + Log.v("SDL", "pixel format RGBX_8888"); + sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888 + break; + case PixelFormat.RGB_332: + Log.v("SDL", "pixel format RGB_332"); + sdlFormat = 0x14110801; // SDL_PIXELFORMAT_RGB332 + break; + case PixelFormat.RGB_565: + Log.v("SDL", "pixel format RGB_565"); + sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 + break; + case PixelFormat.RGB_888: + Log.v("SDL", "pixel format RGB_888"); + // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? + sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888 + break; + default: + Log.v("SDL", "pixel format unknown " + format); + break; + } + + mWidth = (float) width; + mHeight = (float) height; + SDLActivity.onNativeResize(width, height, sdlFormat); + Log.v("SDL", "Window size:" + width + "x"+height); + + SDLActivity.startApp(); + } + + // unused + public void onDraw(Canvas canvas) {} + + + + + // Listen to joystick motion events if supported (API >= 12) + private static class SDLOnGenericMotionListener implements View.OnGenericMotionListener { + @Override + public boolean onGenericMotion(View view, MotionEvent event) { + int actionPointerIndex = event.getActionIndex(); + int action = event.getActionMasked(); + + if ( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { + switch(action) { + case MotionEvent.ACTION_MOVE: + int id = SDLActivity.getJoyId( event.getDeviceId() ); + // The joystick subsystem may be uninitialized, so ignore + if (id < 0) + return true; + // Update values for all joystick axes + List axes = SDLActivity.getJoystickAxesList(id); + for (int axisIndex = 0; axisIndex < axes.size(); axisIndex++) { + SDLActivity.onNativeJoy(id, axisIndex, event.getAxisValue(axes.get(axisIndex), actionPointerIndex)); + } + + return true; + } + } + return false; + } + } + + // Key events + public boolean onKey(View v, int keyCode, KeyEvent event) { + /* Dispatch the different events depending on where they come from: + * If the input device has some joystick source (probably differing + * from the source to which the given key belongs), assume it is a + * game controller button. Otherwise, assume a keyboard key. + * This should also take care of some kinds of manually toggled soft + * keyboards (i.e. not via the SDL text input API). + */ + if ( (event.getDevice().getSources() & 0x00000010 /* API 12: InputDevice.SOURCE_CLASS_JOYSTICK*/) != 0) { + int id = SDLActivity.getJoyId( event.getDeviceId() ); + // The joystick subsystem may be uninitialized, so ignore + if (id < 0) + return true; + if (event.getAction() == KeyEvent.ACTION_DOWN) { + SDLActivity.onNativePadDown(id, keyCode); + return true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + SDLActivity.onNativePadUp(id, keyCode); + return true; + } + } else { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + //Log.v("SDL", "key down: " + keyCode); + SDLActivity.onNativeKeyDown(keyCode); + return true; + } + else if (event.getAction() == KeyEvent.ACTION_UP) { + //Log.v("SDL", "key up: " + keyCode); + SDLActivity.onNativeKeyUp(keyCode); + return true; + } + } + + return false; + } + + // Touch events + public boolean onTouch(View v, MotionEvent event) { + { + final int touchDevId = event.getDeviceId(); + final int pointerCount = event.getPointerCount(); + // touchId, pointerId, action, x, y, pressure + int actionPointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent. ACTION_POINTER_ID_SHIFT; /* API 8: event.getActionIndex(); */ + int pointerFingerId = event.getPointerId(actionPointerIndex); + int action = (event.getAction() & MotionEvent.ACTION_MASK); /* API 8: event.getActionMasked(); */ + + float x = event.getX(actionPointerIndex) / mWidth; + float y = event.getY(actionPointerIndex) / mHeight; + float p = event.getPressure(actionPointerIndex); + + if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) { + // TODO send motion to every pointer if its position has + // changed since prev event. + for (int i = 0; i < pointerCount; i++) { + pointerFingerId = event.getPointerId(i); + x = event.getX(i) / mWidth; + y = event.getY(i) / mHeight; + p = event.getPressure(i); + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); + } + } else { + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); + } + } + return true; + } + + // Sensor events + public void enableSensor(int sensortype, boolean enabled) { + // TODO: This uses getDefaultSensor - what if we have >1 accels? + if (enabled) { + mSensorManager.registerListener(this, + mSensorManager.getDefaultSensor(sensortype), + SensorManager.SENSOR_DELAY_GAME, null); + } else { + mSensorManager.unregisterListener(this, + mSensorManager.getDefaultSensor(sensortype)); + } + } + + public void onAccuracyChanged(Sensor sensor, int accuracy) { + // TODO + } + + public void onSensorChanged(SensorEvent event) { +/* + if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { + SDLActivity.onNativeAccel(event.values[0] / SensorManager.GRAVITY_EARTH, + event.values[1] / SensorManager.GRAVITY_EARTH, + event.values[2] / SensorManager.GRAVITY_EARTH); + } +*/ + } +} \ No newline at end of file