Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
65 KB
Referenced Files
None
Subscribers
None
diff --git a/util/android/src/org/liballeg/android/AllegroAPKStream.java b/util/android/src/org/liballeg/android/AllegroAPKStream.java
deleted file mode 100644
index 08efc32b..00000000
--- a/util/android/src/org/liballeg/android/AllegroAPKStream.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.liballeg.android;
-
-import android.content.res.AssetFileDescriptor;
-import android.content.res.AssetManager;
-import android.util.Log;
-import java.io.IOException;
-import java.io.InputStream;
-
-class AllegroAPKStream
-{
- private static final String TAG = "AllegroAPKStream";
-
- private AllegroActivity activity;
- private String fn;
- private InputStream in;
- private long pos = 0;
- private long fsize = -1;
- private boolean at_eof = false;
-
- AllegroAPKStream(AllegroActivity activity, String filename)
- {
- this.activity = activity;
- fn = Path.simplifyPath(filename);
- if (!fn.equals(filename)) {
- Log.d(TAG, filename + " simplified to: " + fn);
- }
- }
-
- boolean open()
- {
- try {
- AssetFileDescriptor fd;
- fd = activity.getResources().getAssets().openFd(fn);
- fsize = fd.getLength();
- fd.close();
- }
- catch (IOException e) {
- Log.w(TAG, "could not get file size: " + e.toString());
- fsize = -1;
- }
-
- return reopen();
- }
-
- boolean reopen()
- {
- if (in != null) {
- close();
- in = null;
- }
-
- try {
- in = activity.getResources().getAssets().open(fn,
- AssetManager.ACCESS_RANDOM);
- }
- catch (IOException e) {
- Log.d(TAG, "Got IOException in reopen. fn='" + fn + "'");
- return false;
- }
-
- in.mark((int)Math.pow(2, 31));
- pos = 0;
- at_eof = false;
- return true;
- }
-
- boolean close()
- {
- try {
- in.close();
- in = null;
- return true;
- }
- catch (IOException e) {
- Log.d(TAG, "IOException in close");
- return false;
- }
- }
-
- boolean seek(long seekto)
- {
- at_eof = false;
-
- if (seekto >= pos) {
- long seek_ahead = seekto - pos;
- return force_skip(seek_ahead);
- }
-
- /* Seek backwards by rewinding to start of file first. */
- try {
- in.reset();
- pos = 0;
- }
- catch (IOException e) {
- if (!reopen()) {
- /* Leaves pos wherever it lands! */
- return false;
- }
- }
- return force_skip(seekto);
- }
-
- private boolean force_skip(long n)
- {
- if (n <= 0)
- return true;
-
- /* NOTE: in.skip doesn't work here! */
- byte[] b = new byte[(int)n];
- while (n > 0) {
- int res;
- try {
- res = in.read(b, 0, (int)n);
- } catch (IOException e) {
- Log.d(TAG, "IOException: " + e.toString());
- return false;
- }
- if (res <= 0)
- break;
- pos += res;
- n -= res;
- }
- return true;
- }
-
- long tell()
- {
- return pos;
- }
-
- int read(byte[] b)
- {
- try {
- int ret = in.read(b);
- if (ret > 0)
- pos += ret;
- else if (ret == -1) {
- at_eof = true;
- }
- return ret;
- }
- catch (IOException e) {
- Log.d(TAG, "IOException in read");
- return -1;
- }
- }
-
- long size()
- {
- return fsize;
- }
-
- boolean eof()
- {
- return at_eof;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/AllegroActivity.java b/util/android/src/org/liballeg/android/AllegroActivity.java
deleted file mode 100644
index ce9ed656..00000000
--- a/util/android/src/org/liballeg/android/AllegroActivity.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.liballeg.android;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.res.AssetManager;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.util.Log;
-import android.view.SurfaceHolder;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import java.io.File;
-import java.lang.Runnable;
-import java.lang.String;
-
-public class AllegroActivity extends Activity
-{
- /* properties */
- private String userLibName = "libapp.so";
- private Handler handler;
- private Sensors sensors;
- private Configuration currentConfig;
- private AllegroSurface surface;
- private ScreenLock screenLock;
- private boolean exitedMain = false;
-
- /* native methods we call */
- native boolean nativeOnCreate();
- native void nativeOnPause();
- native void nativeOnResume();
- native void nativeOnDestroy();
- native void nativeOnOrientationChange(int orientation, boolean init);
-
- /* methods native code calls */
-
- String getUserLibName()
- {
- ApplicationInfo appInfo = getApplicationInfo();
- String libDir = Reflect.getField(appInfo, "nativeLibraryDir");
- /* Android < 2.3 doesn't have .nativeLibraryDir */
- if (libDir == null) {
- libDir = appInfo.dataDir + "/lib";
- }
- return libDir + "/" + userLibName;
- }
-
- String getResourcesDir()
- {
- //return getApplicationInfo().dataDir + "/assets";
- //return getApplicationInfo().sourceDir + "/assets/";
- return getFilesDir().getAbsolutePath();
- }
-
- String getPubDataDir()
- {
- return getFilesDir().getAbsolutePath();
- }
-
- String getApkPath()
- {
- return getApplicationInfo().sourceDir;
- }
-
- String getModel()
- {
- return android.os.Build.MODEL;
- }
-
- void postRunnable(Runnable runme)
- {
- try {
- Log.d("AllegroActivity", "postRunnable");
- handler.post( runme );
- } catch (Exception x) {
- Log.d("AllegroActivity", "postRunnable exception: " + x.getMessage());
- }
- }
-
- void createSurface()
- {
- try {
- Log.d("AllegroActivity", "createSurface");
- surface = new AllegroSurface(getApplicationContext(),
- getWindowManager().getDefaultDisplay());
-
- SurfaceHolder holder = surface.getHolder();
- holder.addCallback(surface);
- holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
- //setContentView(surface);
- Window win = getWindow();
- win.setContentView(surface);
- Log.d("AllegroActivity", "createSurface end");
- } catch (Exception x) {
- Log.d("AllegroActivity", "createSurface exception: " + x.getMessage());
- }
- }
-
- void postCreateSurface()
- {
- try {
- Log.d("AllegroActivity", "postCreateSurface");
-
- handler.post(new Runnable() {
- public void run() {
- createSurface();
- }
- });
- } catch (Exception x) {
- Log.d("AllegroActivity", "postCreateSurface exception: " + x.getMessage());
- }
- }
-
- void destroySurface()
- {
- Log.d("AllegroActivity", "destroySurface");
-
- ViewGroup vg = (ViewGroup)(surface.getParent());
- vg.removeView(surface);
- surface = null;
- }
-
- void postDestroySurface()
- {
- try {
- Log.d("AllegroActivity", "postDestroySurface");
-
- handler.post(new Runnable() {
- public void run() {
- destroySurface();
- }
- });
- } catch (Exception x) {
- Log.d("AllegroActivity", "postDestroySurface exception: " + x.getMessage());
- }
- }
-
- void postFinish()
- {
- exitedMain = true;
-
- try {
- Log.d("AllegroActivity", "posting finish!");
- handler.post(new Runnable() {
- public void run() {
- try {
- AllegroActivity.this.finish();
- System.exit(0);
- } catch (Exception x) {
- Log.d("AllegroActivity", "inner exception: " + x.getMessage());
- }
- }
- });
- } catch (Exception x) {
- Log.d("AllegroActivity", "exception: " + x.getMessage());
- }
- }
-
- boolean getMainReturned()
- {
- return exitedMain;
- }
-
- boolean inhibitScreenLock(boolean inhibit)
- {
- if (screenLock == null) {
- screenLock = new ScreenLock(this);
- }
- return screenLock.inhibitScreenLock(inhibit);
- }
-
- /* end of functions native code calls */
-
- public AllegroActivity(String userLibName)
- {
- super();
- this.userLibName = userLibName;
- }
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- Log.d("AllegroActivity", "onCreate");
-
- Log.d("AllegroActivity", "Files Dir: " + getFilesDir());
- File extdir = Environment.getExternalStorageDirectory();
-
- boolean mExternalStorageAvailable = false;
- boolean mExternalStorageWriteable = false;
- String state = Environment.getExternalStorageState();
-
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- // We can read and write the media
- mExternalStorageAvailable = mExternalStorageWriteable = true;
- } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- // We can only read the media
- mExternalStorageAvailable = true;
- mExternalStorageWriteable = false;
- } else {
- // Something else is wrong. It may be one of many other states, but
- // all we need to know is we can neither read nor write
- mExternalStorageAvailable = mExternalStorageWriteable = false;
- }
-
- Log.d("AllegroActivity", "External Storage Dir: " + extdir.getAbsolutePath());
- Log.d("AllegroActivity", "External Files Dir: " + getExternalFilesDir(null));
-
- Log.d("AllegroActivity", "external: avail = " + mExternalStorageAvailable +
- " writable = " + mExternalStorageWriteable);
-
- Log.d("AllegroActivity", "sourceDir: " + getApplicationInfo().sourceDir);
- Log.d("AllegroActivity", "publicSourceDir: " + getApplicationInfo().publicSourceDir);
-
- handler = new Handler();
- sensors = new Sensors(getApplicationContext());
-
- currentConfig = new Configuration(getResources().getConfiguration());
-
- Log.d("AllegroActivity", "before nativeOnCreate");
- if (!nativeOnCreate()) {
- finish();
- Log.d("AllegroActivity", "nativeOnCreate failed");
- return;
- }
-
- nativeOnOrientationChange(0, true);
-
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
- Log.d("AllegroActivity", "onCreate end");
- }
-
- @Override
- public void onStart()
- {
- super.onStart();
- Log.d("AllegroActivity", "onStart.");
- }
-
- @Override
- public void onRestart()
- {
- super.onRestart();
- Log.d("AllegroActivity", "onRestart.");
- }
-
- @Override
- public void onStop()
- {
- super.onStop();
- Log.d("AllegroActivity", "onStop.");
- }
-
- /** Called when the activity is paused. */
- @Override
- public void onPause()
- {
- super.onPause();
- Log.d("AllegroActivity", "onPause");
-
- sensors.unlisten();
-
- nativeOnPause();
- Log.d("AllegroActivity", "onPause end");
- }
-
- /** Called when the activity is resumed/unpaused */
- @Override
- public void onResume()
- {
- Log.d("AllegroActivity", "onResume");
- super.onResume();
-
- sensors.listen();
-
- nativeOnResume();
-
- Log.d("AllegroActivity", "onResume end");
- }
-
- /** Called when the activity is destroyed */
- @Override
- public void onDestroy()
- {
- super.onDestroy();
- Log.d("AllegroActivity", "onDestroy");
-
- nativeOnDestroy();
- Log.d("AllegroActivity", "onDestroy end");
- }
-
- /** Called when config has changed */
- @Override
- public void onConfigurationChanged(Configuration conf)
- {
- super.onConfigurationChanged(conf);
- Log.d("AllegroActivity", "onConfigurationChanged");
- // compare conf.orientation with some saved value
-
- int changes = currentConfig.diff(conf);
- Log.d("AllegroActivity", "changes: " + Integer.toBinaryString(changes));
-
- if ((changes & ActivityInfo.CONFIG_FONT_SCALE) != 0)
- Log.d("AllegroActivity", "font scale changed");
-
- if ((changes & ActivityInfo.CONFIG_MCC) != 0)
- Log.d("AllegroActivity", "mcc changed");
-
- if ((changes & ActivityInfo.CONFIG_MNC) != 0)
- Log.d("AllegroActivity", " changed");
-
- if ((changes & ActivityInfo.CONFIG_LOCALE) != 0)
- Log.d("AllegroActivity", "locale changed");
-
- if ((changes & ActivityInfo.CONFIG_TOUCHSCREEN) != 0)
- Log.d("AllegroActivity", "touchscreen changed");
-
- if ((changes & ActivityInfo.CONFIG_KEYBOARD) != 0)
- Log.d("AllegroActivity", "keyboard changed");
-
- if ((changes & ActivityInfo.CONFIG_NAVIGATION) != 0)
- Log.d("AllegroActivity", "navigation changed");
-
- if ((changes & ActivityInfo.CONFIG_ORIENTATION) != 0) {
- Log.d("AllegroActivity", "orientation changed");
- nativeOnOrientationChange(getAllegroOrientation(), false);
- }
-
- if ((changes & ActivityInfo.CONFIG_SCREEN_LAYOUT) != 0)
- Log.d("AllegroActivity", "screen layout changed");
-
- if ((changes & ActivityInfo.CONFIG_UI_MODE) != 0)
- Log.d("AllegroActivity", "ui mode changed");
-
- if (currentConfig.screenLayout != conf.screenLayout) {
- Log.d("AllegroActivity", "screenLayout changed!");
- }
-
- Log.d("AllegroActivity",
- "old orientation: " + currentConfig.orientation
- + ", new orientation: " + conf.orientation);
-
- currentConfig = new Configuration(conf);
- }
-
- /** Called when app is frozen **/
- @Override
- public void onSaveInstanceState(Bundle state)
- {
- Log.d("AllegroActivity", "onSaveInstanceState");
- /* do nothing? */
- /* This should get rid of the following warning:
- * couldn't save which view has focus because the focused view has no id.
- */
- }
-
- void setAllegroOrientation(int alleg_orientation)
- {
- setRequestedOrientation(Const.toAndroidOrientation(alleg_orientation));
- }
-
- int getAllegroOrientation()
- {
- int rotation;
- if (Reflect.methodExists(getWindowManager().getDefaultDisplay(),
- "getRotation"))
- {
- /* 2.2+ */
- rotation = getWindowManager().getDefaultDisplay().getRotation();
- }
- else {
- rotation = getWindowManager().getDefaultDisplay().getOrientation();
- }
- return Const.toAllegroOrientation(rotation);
- }
-
- String getOsVersion()
- {
- return android.os.Build.VERSION.RELEASE;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/AllegroInputStream.java b/util/android/src/org/liballeg/android/AllegroInputStream.java
deleted file mode 100644
index 0762e58c..00000000
--- a/util/android/src/org/liballeg/android/AllegroInputStream.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.liballeg.android;
-
-import java.io.InputStream;
-import android.util.Log;
-
-public class AllegroInputStream extends InputStream
-{
- private static final String TAG = "AllegroInputStream";
-
- private int handle;
-
- public native int nativeRead(int handle, byte[] buffer, int offset, int length);
- public native void nativeClose(int handle);
-
- public AllegroInputStream(int handle)
- {
- super();
- this.handle = handle;
- Log.d(TAG, "ctor handle:" + handle);
- }
-
- @Override
- public int available()
- {
- Log.d(TAG, "available");
- return 0;
- }
-
- @Override
- public void close()
- {
- Log.d(TAG, "close");
- nativeClose(handle);
- }
-
- @Override
- public void mark(int limit)
- {
- Log.d(TAG, "mark " + limit);
- }
-
- @Override
- public boolean markSupported()
- {
- Log.d(TAG, "markSupported");
- return false;
- }
-
- @Override
- public int read()
- {
- byte buffer[] = new byte[1];
- int ret = read(buffer, 0, buffer.length);
- if (ret != -1)
- return buffer[0];
- else
- return -1;
- }
-
- @Override
- public int read(byte[] buffer)
- {
- return read(buffer, 0, buffer.length);
- }
-
- @Override
- public int read(byte[] buffer, int offset, int length)
- {
- Log.d(TAG, "read handle: " + handle + ", offset: " + offset +
- ", length: " + length);
- int ret = nativeRead(handle, buffer, offset, length);
- Log.d(TAG, "read end: ret = " + ret);
- return ret;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/AllegroSurface.java b/util/android/src/org/liballeg/android/AllegroSurface.java
deleted file mode 100644
index 39832cfb..00000000
--- a/util/android/src/org/liballeg/android/AllegroSurface.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.liballeg.android;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.Log;
-import android.view.Display;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-class AllegroSurface extends SurfaceView implements SurfaceHolder.Callback
-{
- /** native functions we call */
- public native void nativeOnCreate();
- public native boolean nativeOnDestroy();
- public native void nativeOnChange(int format, int width, int height);
-
- /** functions that native code calls */
-
- boolean egl_Init()
- {
- return egl.egl_Init();
- }
-
- void egl_initRequiredAttribs()
- {
- egl.egl_initRequiredAttribs();
- }
-
- void egl_setRequiredAttrib(int attr, int value)
- {
- egl.egl_setRequiredAttrib(attr, value);
- }
-
- int egl_chooseConfig(boolean programmable_pipeline)
- {
- return egl.egl_chooseConfig(programmable_pipeline);
- }
-
- void egl_getConfigAttribs(int index, int ret[])
- {
- egl.egl_getConfigAttribs(index, ret);
- }
-
- int egl_createContext(int configIndex, boolean programmable_pipeline)
- {
- return egl.egl_createContext(configIndex, programmable_pipeline);
- }
-
- boolean egl_createSurface()
- {
- return egl.egl_createSurface(this);
- }
-
- void egl_clearCurrent()
- {
- egl.egl_clearCurrent();
- }
-
- void egl_makeCurrent()
- {
- egl.egl_makeCurrent();
- }
-
- void egl_SwapBuffers()
- {
- egl.egl_SwapBuffers();
- }
-
- /** main handlers */
-
- private AllegroEGL egl;
- private KeyListener key_listener;
- private TouchListener touch_listener;
-
- public AllegroSurface(Context context, Display display)
- {
- super(context);
-
- Log.d("AllegroSurface", "PixelFormat=" + display.getPixelFormat());
- getHolder().setFormat(display.getPixelFormat());
- getHolder().addCallback(this);
-
- this.egl = new AllegroEGL();
- this.key_listener = new KeyListener(context);
- this.touch_listener = new TouchListener();
- }
-
- private void grabFocus()
- {
- Log.d("AllegroSurface", "Grabbing focus");
-
- setFocusable(true);
- setFocusableInTouchMode(true);
- requestFocus();
- setOnKeyListener(key_listener);
- setOnTouchListener(touch_listener);
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder)
- {
- Log.d("AllegroSurface", "surfaceCreated");
- nativeOnCreate();
- grabFocus();
- Log.d("AllegroSurface", "surfaceCreated end");
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder)
- {
- Log.d("AllegroSurface", "surfaceDestroyed");
-
- if (!nativeOnDestroy()) {
- Log.d("AllegroSurface", "No surface created, returning early");
- return;
- }
-
- egl.egl_Terminate();
-
- Log.d("AllegroSurface", "surfaceDestroyed end");
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
- {
- Log.d("AllegroSurface", "surfaceChanged (width=" + width + " height=" + height + ")");
- nativeOnChange(0xdeadbeef, width, height);
- Log.d("AllegroSurface", "surfaceChanged end");
- }
-
- /* unused */
- @Override
- public void onDraw(Canvas canvas)
- {
- }
-
- /* Events */
-
- /* XXX not exposed in C API yet */
- void setCaptureVolumeKeys(boolean onoff)
- {
- key_listener.setCaptureVolumeKeys(onoff);
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/Const.java b/util/android/src/org/liballeg/android/Const.java
deleted file mode 100644
index 784d8e62..00000000
--- a/util/android/src/org/liballeg/android/Const.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.liballeg.android;
-
-import android.content.pm.ActivityInfo;
-import android.view.Surface;
-
-final class Const
-{
- /* color.h */
- static final int ALLEGRO_PIXEL_FORMAT_ABGR_8888 = 17;
- static final int ALLEGRO_PIXEL_FORMAT_BGR_565 = 20;
- static final int ALLEGRO_PIXEL_FORMAT_RGBA_4444 = 26;
- static final int ALLEGRO_PIXEL_FORMAT_SINGLE_CHANNEL_8 = 27;
-
- /* display.h */
- static final int ALLEGRO_RED_SIZE = 0;
- static final int ALLEGRO_GREEN_SIZE = 1;
- static final int ALLEGRO_BLUE_SIZE = 2;
- static final int ALLEGRO_ALPHA_SIZE = 3;
- static final int ALLEGRO_COLOR_SIZE = 14;
- static final int ALLEGRO_DEPTH_SIZE = 15;
- static final int ALLEGRO_STENCIL_SIZE = 16;
- static final int ALLEGRO_SAMPLE_BUFFERS = 17;
- static final int ALLEGRO_SAMPLES = 18;
-
- static final int ALLEGRO_DISPLAY_ORIENTATION_UNKNOWN = 0;
- static final int ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES = 1;
- static final int ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES = 2;
- static final int ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES = 4;
- static final int ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES = 8;
- static final int ALLEGRO_DISPLAY_ORIENTATION_PORTRAIT = 5;
- static final int ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE = 10;
- static final int ALLEGRO_DISPLAY_ORIENTATION_ALL = 15;
- static final int ALLEGRO_DISPLAY_ORIENTATION_FACE_UP = 16;
- static final int ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN = 32;
-
- /* events.h */
- static final int ALLEGRO_EVENT_TOUCH_BEGIN = 50;
- static final int ALLEGRO_EVENT_TOUCH_END = 51;
- static final int ALLEGRO_EVENT_TOUCH_MOVE = 52;
- static final int ALLEGRO_EVENT_TOUCH_CANCEL = 53;
-
- static int toAndroidOrientation(int alleg_orientation)
- {
- switch (alleg_orientation)
- {
- case ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES:
- return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
-
- case ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES:
- return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
-
- case ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES:
- return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
-
- case ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES:
- return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
-
- case ALLEGRO_DISPLAY_ORIENTATION_PORTRAIT:
- return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
-
- case ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE:
- return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
-
- case ALLEGRO_DISPLAY_ORIENTATION_ALL:
- return ActivityInfo.SCREEN_ORIENTATION_SENSOR;
- }
-
- return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
- }
-
- static int toAllegroOrientation(int rotation)
- {
- switch (rotation) {
- case Surface.ROTATION_0:
- return ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES;
-
- case Surface.ROTATION_180:
- return ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES;
-
- /* Android device orientations are the opposite of Allegro ones.
- * Allegro orientations are the orientation of the device, with 0
- * being holding the device at normal orientation, 90 with the device
- * rotated 90 degrees clockwise and so on. Android orientations are
- * the orientations of the GRAPHICS. By rotating the device by 90
- * degrees clockwise, the graphics are actually rotated 270 degrees,
- * and that's what Android uses.
- */
-
- case Surface.ROTATION_90:
- return ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES;
-
- case Surface.ROTATION_270:
- return ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES;
- }
-
- return ALLEGRO_DISPLAY_ORIENTATION_UNKNOWN;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/ImageLoader.java b/util/android/src/org/liballeg/android/ImageLoader.java
deleted file mode 100644
index b53f6319..00000000
--- a/util/android/src/org/liballeg/android/ImageLoader.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.liballeg.android;
-
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-import java.io.InputStream;
-
-class ImageLoader
-{
- private static final String TAG = "ImageLoader";
-
- static Bitmap decodeBitmapAsset(Activity activity, final String filename)
- {
- Bitmap decodedBitmap;
- Log.d(TAG, "decodeBitmapAsset begin");
- try {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- // Only added in API level 19, avoid for now.
- // options.inPremultiplied = premul;
- InputStream is = activity.getResources().getAssets().open(
- Path.simplifyPath(filename));
- decodedBitmap = BitmapFactory.decodeStream(is, null, options);
- is.close();
- Log.d(TAG, "done waiting for decodeStream");
- } catch (Exception ex) {
- Log.e(TAG,
- "decodeBitmapAsset exception: " + ex.getMessage());
- decodedBitmap = null;
- }
- Log.d(TAG, "decodeBitmapAsset end");
- return decodedBitmap;
- }
-
- static Bitmap decodeBitmapStream(final InputStream is)
- {
- Bitmap decodedBitmap;
- Log.d(TAG, "decodeBitmapStream begin");
- try {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- // Only added in API level 19, avoid for now.
- // options.inPremultiplied = premul;
- decodedBitmap = BitmapFactory.decodeStream(is, null, options);
- Log.d(TAG, "done waiting for decodeStream");
- } catch (Exception ex) {
- Log.e(TAG, "decodeBitmapStream exception: " +
- ex.getMessage());
- decodedBitmap = null;
- }
- Log.d(TAG, "decodeBitmapStream end");
- return decodedBitmap;
- }
-
- /* Unused yet */
- /*
- static Bitmap decodeBitmapByteArray(byte[] array)
- {
- Bitmap decodedBitmap;
- Log.d(TAG, "decodeBitmapByteArray");
- try {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap bmp = BitmapFactory.decodeByteArray(array, 0, array.length, options);
- return bmp;
- }
- catch (Exception ex) {
- Log.e(TAG, "decodeBitmapByteArray exception: " +
- ex.getMessage());
- }
- return null;
- }
- */
-
- static int getBitmapFormat(Bitmap bitmap)
- {
- switch (bitmap.getConfig()) {
- case ALPHA_8:
- return Const.ALLEGRO_PIXEL_FORMAT_SINGLE_CHANNEL_8; // not really
- case ARGB_4444:
- return Const.ALLEGRO_PIXEL_FORMAT_RGBA_4444;
- case ARGB_8888:
- return Const.ALLEGRO_PIXEL_FORMAT_ABGR_8888;
- case RGB_565:
- return Const.ALLEGRO_PIXEL_FORMAT_BGR_565; // untested
- default:
- assert(false);
- return -1;
- }
- }
-
- static int[] getPixels(Bitmap bmp)
- {
- int width = bmp.getWidth();
- int height = bmp.getHeight();
- int[] pixels = new int[width * height];
- bmp.getPixels(pixels, 0, width, 0, 0, width, height);
- return pixels;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/Key.java b/util/android/src/org/liballeg/android/Key.java
deleted file mode 100644
index c5565f9b..00000000
--- a/util/android/src/org/liballeg/android/Key.java
+++ /dev/null
@@ -1,436 +0,0 @@
-package org.liballeg.android;
-
-final class Key
-{
- /* keycodes.h */
- static final int ALLEGRO_KEY_A = 1;
- static final int ALLEGRO_KEY_B = 2;
- static final int ALLEGRO_KEY_C = 3;
- static final int ALLEGRO_KEY_D = 4;
- static final int ALLEGRO_KEY_E = 5;
- static final int ALLEGRO_KEY_F = 6;
- static final int ALLEGRO_KEY_G = 7;
- static final int ALLEGRO_KEY_H = 8;
- static final int ALLEGRO_KEY_I = 9;
- static final int ALLEGRO_KEY_J = 10;
- static final int ALLEGRO_KEY_K = 11;
- static final int ALLEGRO_KEY_L = 12;
- static final int ALLEGRO_KEY_M = 13;
- static final int ALLEGRO_KEY_N = 14;
- static final int ALLEGRO_KEY_O = 15;
- static final int ALLEGRO_KEY_P = 16;
- static final int ALLEGRO_KEY_Q = 17;
- static final int ALLEGRO_KEY_R = 18;
- static final int ALLEGRO_KEY_S = 19;
- static final int ALLEGRO_KEY_T = 20;
- static final int ALLEGRO_KEY_U = 21;
- static final int ALLEGRO_KEY_V = 22;
- static final int ALLEGRO_KEY_W = 23;
- static final int ALLEGRO_KEY_X = 24;
- static final int ALLEGRO_KEY_Y = 25;
- static final int ALLEGRO_KEY_Z = 26;
-
- static final int ALLEGRO_KEY_0 = 27;
- static final int ALLEGRO_KEY_1 = 28;
- static final int ALLEGRO_KEY_2 = 29;
- static final int ALLEGRO_KEY_3 = 30;
- static final int ALLEGRO_KEY_4 = 31;
- static final int ALLEGRO_KEY_5 = 32;
- static final int ALLEGRO_KEY_6 = 33;
- static final int ALLEGRO_KEY_7 = 34;
- static final int ALLEGRO_KEY_8 = 35;
- static final int ALLEGRO_KEY_9 = 36;
-
- static final int ALLEGRO_KEY_PAD_0 = 37;
- static final int ALLEGRO_KEY_PAD_1 = 38;
- static final int ALLEGRO_KEY_PAD_2 = 39;
- static final int ALLEGRO_KEY_PAD_3 = 40;
- static final int ALLEGRO_KEY_PAD_4 = 41;
- static final int ALLEGRO_KEY_PAD_5 = 42;
- static final int ALLEGRO_KEY_PAD_6 = 43;
- static final int ALLEGRO_KEY_PAD_7 = 44;
- static final int ALLEGRO_KEY_PAD_8 = 45;
- static final int ALLEGRO_KEY_PAD_9 = 46;
-
- static final int ALLEGRO_KEY_F1 = 47;
- static final int ALLEGRO_KEY_F2 = 48;
- static final int ALLEGRO_KEY_F3 = 49;
- static final int ALLEGRO_KEY_F4 = 50;
- static final int ALLEGRO_KEY_F5 = 51;
- static final int ALLEGRO_KEY_F6 = 52;
- static final int ALLEGRO_KEY_F7 = 53;
- static final int ALLEGRO_KEY_F8 = 54;
- static final int ALLEGRO_KEY_F9 = 55;
- static final int ALLEGRO_KEY_F10 = 56;
- static final int ALLEGRO_KEY_F11 = 57;
- static final int ALLEGRO_KEY_F12 = 58;
-
- static final int ALLEGRO_KEY_ESCAPE = 59;
- static final int ALLEGRO_KEY_TILDE = 60;
- static final int ALLEGRO_KEY_MINUS = 61;
- static final int ALLEGRO_KEY_EQUALS = 62;
- static final int ALLEGRO_KEY_BACKSPACE = 63;
- static final int ALLEGRO_KEY_TAB = 64;
- static final int ALLEGRO_KEY_OPENBRACE = 65;
- static final int ALLEGRO_KEY_CLOSEBRACE = 66;
- static final int ALLEGRO_KEY_ENTER = 67;
- static final int ALLEGRO_KEY_SEMICOLON = 68;
- static final int ALLEGRO_KEY_QUOTE = 69;
- static final int ALLEGRO_KEY_BACKSLASH = 70;
- static final int ALLEGRO_KEY_BACKSLASH2 = 71; /* DirectInput calls this DIK_OEM_102: "< > | on UK/Germany keyboards" */
- static final int ALLEGRO_KEY_COMMA = 72;
- static final int ALLEGRO_KEY_FULLSTOP = 73;
- static final int ALLEGRO_KEY_SLASH = 74;
- static final int ALLEGRO_KEY_SPACE = 75;
-
- static final int ALLEGRO_KEY_INSERT = 76;
- static final int ALLEGRO_KEY_DELETE = 77;
- static final int ALLEGRO_KEY_HOME = 78;
- static final int ALLEGRO_KEY_END = 79;
- static final int ALLEGRO_KEY_PGUP = 80;
- static final int ALLEGRO_KEY_PGDN = 81;
- static final int ALLEGRO_KEY_LEFT = 82;
- static final int ALLEGRO_KEY_RIGHT = 83;
- static final int ALLEGRO_KEY_UP = 84;
- static final int ALLEGRO_KEY_DOWN = 85;
-
- static final int ALLEGRO_KEY_PAD_SLASH = 86;
- static final int ALLEGRO_KEY_PAD_ASTERISK= 87;
- static final int ALLEGRO_KEY_PAD_MINUS = 88;
- static final int ALLEGRO_KEY_PAD_PLUS = 89;
- static final int ALLEGRO_KEY_PAD_DELETE = 90;
- static final int ALLEGRO_KEY_PAD_ENTER = 91;
-
- static final int ALLEGRO_KEY_PRINTSCREEN = 92;
- static final int ALLEGRO_KEY_PAUSE = 93;
-
- static final int ALLEGRO_KEY_ABNT_C1 = 94;
- static final int ALLEGRO_KEY_YEN = 95;
- static final int ALLEGRO_KEY_KANA = 96;
- static final int ALLEGRO_KEY_CONVERT = 97;
- static final int ALLEGRO_KEY_NOCONVERT = 98;
- static final int ALLEGRO_KEY_AT = 99;
- static final int ALLEGRO_KEY_CIRCUMFLEX = 100;
- static final int ALLEGRO_KEY_COLON2 = 101;
- static final int ALLEGRO_KEY_KANJI = 102;
-
- static final int ALLEGRO_KEY_PAD_EQUALS = 103; /* MacOS X */
- static final int ALLEGRO_KEY_BACKQUOTE = 104; /* MacOS X */
- static final int ALLEGRO_KEY_SEMICOLON2 = 105; /* MacOS X -- TODO: ask lillo what this should be */
- static final int ALLEGRO_KEY_COMMAND = 106; /* MacOS X */
- static final int ALLEGRO_KEY_BACK = 107;
- static final int ALLEGRO_KEY_VOLUME_UP = 108;
- static final int ALLEGRO_KEY_VOLUME_DOWN = 109;
-
- /* Some more standard Android keys.
- * These happen to be the ones used by the Xperia Play.
- */
- static final int ALLEGRO_KEY_SEARCH = 110;
- static final int ALLEGRO_KEY_DPAD_CENTER = 111;
- static final int ALLEGRO_KEY_BUTTON_X = 112;
- static final int ALLEGRO_KEY_BUTTON_Y = 113;
- static final int ALLEGRO_KEY_DPAD_UP = 114;
- static final int ALLEGRO_KEY_DPAD_DOWN = 115;
- static final int ALLEGRO_KEY_DPAD_LEFT = 116;
- static final int ALLEGRO_KEY_DPAD_RIGHT = 117;
- static final int ALLEGRO_KEY_SELECT = 118;
- static final int ALLEGRO_KEY_START = 119;
- static final int ALLEGRO_KEY_BUTTON_L1 = 120;
- static final int ALLEGRO_KEY_BUTTON_R1 = 121;
- static final int ALLEGRO_KEY_BUTTON_L2 = 122;
- static final int ALLEGRO_KEY_BUTTON_R2 = 123;
- static final int ALLEGRO_KEY_BUTTON_A = 124;
- static final int ALLEGRO_KEY_BUTTON_B = 125;
- static final int ALLEGRO_KEY_THUMBL = 126;
- static final int ALLEGRO_KEY_THUMBR = 127;
-
- static final int ALLEGRO_KEY_UNKNOWN = 128;
-
- /* All codes up to before ALLEGRO_KEY_MODIFIERS can be freely
- * assigned as additional unknown keys, like various multimedia
- * and application keys keyboards may have.
- */
-
- static final int ALLEGRO_KEY_MODIFIERS = 215;
-
- static final int ALLEGRO_KEY_LSHIFT = 215;
- static final int ALLEGRO_KEY_RSHIFT = 216;
- static final int ALLEGRO_KEY_LCTRL = 217;
- static final int ALLEGRO_KEY_RCTRL = 218;
- static final int ALLEGRO_KEY_ALT = 219;
- static final int ALLEGRO_KEY_ALTGR = 220;
- static final int ALLEGRO_KEY_LWIN = 221;
- static final int ALLEGRO_KEY_RWIN = 222;
- static final int ALLEGRO_KEY_MENU = 223;
- static final int ALLEGRO_KEY_SCROLLLOCK = 224;
- static final int ALLEGRO_KEY_NUMLOCK = 225;
- static final int ALLEGRO_KEY_CAPSLOCK = 226;
-
- static final int ALLEGRO_KEY_MAX = 227;
-
- protected static int[] keyMap = {
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_UNKNOWN
- ALLEGRO_KEY_LEFT, // KeyEvent.KEYCODE_SOFT_LEFT
- ALLEGRO_KEY_RIGHT, // KeyEvent.KEYCODE_SOFT_RIGHT
- ALLEGRO_KEY_HOME, // KeyEvent.KEYCODE_HOME
- ALLEGRO_KEY_BACK, // KeyEvent.KEYCODE_BACK
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_CALL
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ENDCALL
- ALLEGRO_KEY_0, // KeyEvent.KEYCODE_0
- ALLEGRO_KEY_1, // KeyEvent.KEYCODE_1
- ALLEGRO_KEY_2, // KeyEvent.KEYCODE_2
- ALLEGRO_KEY_3, // KeyEvent.KEYCODE_3
- ALLEGRO_KEY_4, // KeyEvent.KEYCODE_4
- ALLEGRO_KEY_5, // KeyEvent.KEYCODE_5
- ALLEGRO_KEY_6, // KeyEvent.KEYCODE_6
- ALLEGRO_KEY_7, // KeyEvent.KEYCODE_7
- ALLEGRO_KEY_8, // KeyEvent.KEYCODE_8
- ALLEGRO_KEY_9, // KeyEvent.KEYCODE_9
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_STAR
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_POUND
- ALLEGRO_KEY_UP, // KeyEvent.KEYCODE_DPAD_UP
- ALLEGRO_KEY_DOWN, // KeyEvent.KEYCODE_DPAD_DOWN
- ALLEGRO_KEY_LEFT, // KeyEvent.KEYCODE_DPAD_LEFT
- ALLEGRO_KEY_RIGHT, // KeyEvent.KEYCODE_DPAD_RIGHT
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_DPAD_CENTER
- ALLEGRO_KEY_VOLUME_UP, // KeyEvent.KEYCODE_VOLUME_UP
- ALLEGRO_KEY_VOLUME_DOWN, // KeyEvent.KEYCODE_VOLUME_DOWN
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_POWER
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_CAMERA
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_CLEAR
- ALLEGRO_KEY_A, // KeyEvent.KEYCODE_A
- ALLEGRO_KEY_B, // KeyEvent.KEYCODE_B
- ALLEGRO_KEY_C, // KeyEvent.KEYCODE_B
- ALLEGRO_KEY_D, // KeyEvent.KEYCODE_D
- ALLEGRO_KEY_E, // KeyEvent.KEYCODE_E
- ALLEGRO_KEY_F, // KeyEvent.KEYCODE_F
- ALLEGRO_KEY_G, // KeyEvent.KEYCODE_G
- ALLEGRO_KEY_H, // KeyEvent.KEYCODE_H
- ALLEGRO_KEY_I, // KeyEvent.KEYCODE_I
- ALLEGRO_KEY_J, // KeyEvent.KEYCODE_J
- ALLEGRO_KEY_K, // KeyEvent.KEYCODE_K
- ALLEGRO_KEY_L, // KeyEvent.KEYCODE_L
- ALLEGRO_KEY_M, // KeyEvent.KEYCODE_M
- ALLEGRO_KEY_N, // KeyEvent.KEYCODE_N
- ALLEGRO_KEY_O, // KeyEvent.KEYCODE_O
- ALLEGRO_KEY_P, // KeyEvent.KEYCODE_P
- ALLEGRO_KEY_Q, // KeyEvent.KEYCODE_Q
- ALLEGRO_KEY_R, // KeyEvent.KEYCODE_R
- ALLEGRO_KEY_S, // KeyEvent.KEYCODE_S
- ALLEGRO_KEY_T, // KeyEvent.KEYCODE_T
- ALLEGRO_KEY_U, // KeyEvent.KEYCODE_U
- ALLEGRO_KEY_V, // KeyEvent.KEYCODE_V
- ALLEGRO_KEY_W, // KeyEvent.KEYCODE_W
- ALLEGRO_KEY_X, // KeyEvent.KEYCODE_X
- ALLEGRO_KEY_Y, // KeyEvent.KEYCODE_Y
- ALLEGRO_KEY_Z, // KeyEvent.KEYCODE_Z
- ALLEGRO_KEY_COMMA, // KeyEvent.KEYCODE_COMMA
- ALLEGRO_KEY_FULLSTOP, // KeyEvent.KEYCODE_PERIOD
- ALLEGRO_KEY_ALT, // KeyEvent.KEYCODE_ALT_LEFT
- ALLEGRO_KEY_ALTGR, // KeyEvent.KEYCODE_ALT_RIGHT
- ALLEGRO_KEY_LSHIFT, // KeyEvent.KEYCODE_SHIFT_LEFT
- ALLEGRO_KEY_RSHIFT, // KeyEvent.KEYCODE_SHIFT_RIGHT
- ALLEGRO_KEY_TAB, // KeyEvent.KEYCODE_TAB
- ALLEGRO_KEY_SPACE, // KeyEvent.KEYCODE_SPACE
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_SYM
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_EXPLORER
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ENVELOPE
- ALLEGRO_KEY_ENTER, // KeyEvent.KEYCODE_ENTER
- ALLEGRO_KEY_BACKSPACE, // KeyEvent.KEYCODE_DEL
- ALLEGRO_KEY_TILDE, // KeyEvent.KEYCODE_GRAVE
- ALLEGRO_KEY_MINUS, // KeyEvent.KEYCODE_MINUS
- ALLEGRO_KEY_EQUALS, // KeyEvent.KEYCODE_EQUALS
- ALLEGRO_KEY_OPENBRACE, // KeyEvent.KEYCODE_LEFT_BRACKET
- ALLEGRO_KEY_CLOSEBRACE, // KeyEvent.KEYCODE_RIGHT_BRACKET
- ALLEGRO_KEY_BACKSLASH, // KeyEvent.KEYCODE_BACKSLASH
- ALLEGRO_KEY_SEMICOLON, // KeyEvent.KEYCODE_SEMICOLON
- ALLEGRO_KEY_QUOTE, // KeyEvent.KEYCODE_APOSTROPHY
- ALLEGRO_KEY_SLASH, // KeyEvent.KEYCODE_SLASH
- ALLEGRO_KEY_AT, // KeyEvent.KEYCODE_AT
- ALLEGRO_KEY_NUMLOCK, // KeyEvent.KEYCODE_NUM
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_HEADSETHOOK
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_FOCUS
- ALLEGRO_KEY_PAD_PLUS, // KeyEvent.KEYCODE_PLUS
- ALLEGRO_KEY_MENU, // KeyEvent.KEYCODE_MENU
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_NOTIFICATION
- ALLEGRO_KEY_SEARCH, // KeyEvent.KEYCODE_SEARCH
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_STOP
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_NEXT
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_PREVIOUS
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_REWIND
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MUTE
- ALLEGRO_KEY_PGUP, // KeyEvent.KEYCODE_PAGE_UP
- ALLEGRO_KEY_PGDN, // KeyEvent.KEYCODE_PAGE_DOWN
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_PICTSYMBOLS
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_SWITCH_CHARSET
- ALLEGRO_KEY_BUTTON_A, // KeyEvent.KEYCODE_BUTTON_A
- ALLEGRO_KEY_BUTTON_B, // KeyEvent.KEYCODE_BUTTON_B
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_BUTTON_C
- ALLEGRO_KEY_BUTTON_X, // KeyEvent.KEYCODE_BUTTON_X
- ALLEGRO_KEY_BUTTON_Y, // KeyEvent.KEYCODE_BUTTON_Y
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_BUTTON_Z
- ALLEGRO_KEY_BUTTON_L1, // KeyEvent.KEYCODE_BUTTON_L1
- ALLEGRO_KEY_BUTTON_R1, // KeyEvent.KEYCODE_BUTTON_R1
- ALLEGRO_KEY_BUTTON_L2, // KeyEvent.KEYCODE_BUTTON_L2
- ALLEGRO_KEY_BUTTON_R2, // KeyEvent.KEYCODE_BUTTON_R2
- ALLEGRO_KEY_THUMBL, // KeyEvent.KEYCODE_THUMBL
- ALLEGRO_KEY_THUMBR, // KeyEvent.KEYCODE_THUMBR
- ALLEGRO_KEY_START, // KeyEvent.KEYCODE_START
- ALLEGRO_KEY_SELECT, // KeyEvent.KEYCODE_SELECT
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_MODE
- ALLEGRO_KEY_ESCAPE, // KeyEvent.KEYCODE_ESCAPE (111)
- ALLEGRO_KEY_DELETE, // KeyEvent.KEYCODE_FORWARD_DELETE (112)
- ALLEGRO_KEY_LCTRL, // KeyEvent.KEYCODE_CTRL_LEFT (113)
- ALLEGRO_KEY_RCTRL, // KeyEvent.KEYCODE_CONTROL_RIGHT (114)
- ALLEGRO_KEY_CAPSLOCK, // KeyEvent.KEYCODE_CAPS_LOCK (115)
- ALLEGRO_KEY_SCROLLLOCK, // KeyEvent.KEYCODE_SCROLL_LOCK (116)
- ALLEGRO_KEY_LWIN, // KeyEvent.KEYCODE_META_LEFT (117)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (118)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (119)
- ALLEGRO_KEY_PRINTSCREEN, // KeyEvent.KEYCODE_SYSRQ (120)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (121)
- ALLEGRO_KEY_HOME, // KeyEvent.KEYCODE_MOVE_HOME (122)
- ALLEGRO_KEY_END, // KeyEvent.KEYCODE_MOVE_END (123)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (124)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (125)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (126)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (127)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (128)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (129)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (130)
- ALLEGRO_KEY_F1, // KeyEvent.KEYCODE_ (131)
- ALLEGRO_KEY_F2, // KeyEvent.KEYCODE_ (132)
- ALLEGRO_KEY_F3, // KeyEvent.KEYCODE_ (133)
- ALLEGRO_KEY_F4, // KeyEvent.KEYCODE_ (134)
- ALLEGRO_KEY_F5, // KeyEvent.KEYCODE_ (135)
- ALLEGRO_KEY_F6, // KeyEvent.KEYCODE_ (136)
- ALLEGRO_KEY_F7, // KeyEvent.KEYCODE_ (137)
- ALLEGRO_KEY_F8, // KeyEvent.KEYCODE_ (138)
- ALLEGRO_KEY_F9, // KeyEvent.KEYCODE_ (139)
- ALLEGRO_KEY_F10, // KeyEvent.KEYCODE_ (140)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (141)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (142)
- ALLEGRO_KEY_NUMLOCK, // KeyEvent.KEYCODE_NUM_LOCK (143)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (144)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (145)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (146)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (147)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (148)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (149)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (150)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (151)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (152)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (153)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (154)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (155)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (156)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (157)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (158)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (159)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (160)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (161)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (162)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (163)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (164)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (165)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (166)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (167)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (168)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (169)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (170)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (171)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (172)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (173)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (174)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (175)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (176)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (177)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (178)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (179)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (180)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (181)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (182)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (183)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (184)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (185)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (186)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (187)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (188)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (189)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (190)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (191)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (192)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (193)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (194)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (195)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (196)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (197)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (198)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (199)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (200)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (201)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (202)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (203)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (204)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (205)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (206)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (207)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (208)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (209)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (210)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (211)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (212)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (213)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (214)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (215)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (216)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (217)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (218)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (219)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (220)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (221)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (222)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (223)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (224)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (225)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (226)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (227)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (228)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (229)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (230)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (231)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (232)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (233)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (234)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (235)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (236)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (237)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (238)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (239)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (240)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (241)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (242)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (243)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (244)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (245)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (246)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (247)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (248)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (249)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (250)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (251)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (252)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (253)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (254)
- ALLEGRO_KEY_UNKNOWN, // KeyEvent.KEYCODE_ (255)
- };
-
- /* Return Allegro key code for Android key code. */
- static int alKey(int keyCode) {
- return keyMap[keyCode];
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/KeyListener.java b/util/android/src/org/liballeg/android/KeyListener.java
deleted file mode 100644
index 6b1e67dc..00000000
--- a/util/android/src/org/liballeg/android/KeyListener.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.liballeg.android;
-
-import android.media.AudioManager;
-import android.content.Context;
-import android.view.KeyEvent;
-import android.view.View;
-
-class KeyListener implements View.OnKeyListener
-{
- private Context context;
- private boolean captureVolume = false;
-
- native void nativeOnKeyDown(int key);
- native void nativeOnKeyUp(int key);
- native void nativeOnKeyChar(int key, int unichar);
-
- KeyListener(Context context)
- {
- this.context = context;
- }
-
- void setCaptureVolumeKeys(boolean onoff)
- {
- captureVolume = onoff;
- }
-
- @Override
- public boolean onKey(View v, int keyCode, KeyEvent event)
- {
- int unichar;
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- if (!captureVolume) {
- if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
- volumeChange(1);
- return true;
- }
- else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
- volumeChange(-1);
- return true;
- }
- }
- if (Key.alKey(keyCode) == Key.ALLEGRO_KEY_BACKSPACE) {
- unichar = '\b';
- }
- else if (Key.alKey(keyCode) == Key.ALLEGRO_KEY_ENTER) {
- unichar = '\r';
- }
- else {
- unichar = event.getUnicodeChar();
- }
-
- if (event.getRepeatCount() == 0) {
- nativeOnKeyDown(Key.alKey(keyCode));
- nativeOnKeyChar(Key.alKey(keyCode), unichar);
- }
- else {
- nativeOnKeyChar(Key.alKey(keyCode), unichar);
- }
- return true;
- }
- else if (event.getAction() == KeyEvent.ACTION_UP) {
- nativeOnKeyUp(Key.alKey(keyCode));
- return true;
- }
-
- return false;
- }
-
- private void volumeChange(int inc)
- {
- AudioManager mAudioManager =
- (AudioManager)this.context.getApplicationContext()
- .getSystemService(Context.AUDIO_SERVICE);
-
- int curr = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
- int max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
- int vol = curr + inc;
-
- if (0 <= vol && vol <= max) {
- // Set a new volume level manually with the FLAG_SHOW_UI flag.
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol,
- AudioManager.FLAG_SHOW_UI);
- }
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/Path.java b/util/android/src/org/liballeg/android/Path.java
deleted file mode 100644
index 5aaa320c..00000000
--- a/util/android/src/org/liballeg/android/Path.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.liballeg.android;
-
-import android.text.TextUtils;
-import java.util.ArrayList;
-
-final class Path
-{
- // AssetManager does not interpret the path(!) so we do it here.
- static String simplifyPath(final String path)
- {
- final String[] pieces = path.split("/");
- ArrayList<String> keep = new ArrayList<String>();
- for (String piece : pieces) {
- if (piece.equals(""))
- continue;
- if (piece.equals("."))
- continue;
- if (piece.equals("..")) {
- if (keep.size() > 0)
- keep.remove(keep.size() - 1);
- continue;
- }
- keep.add(piece);
- }
- return TextUtils.join("/", keep);
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/Reflect.java b/util/android/src/org/liballeg/android/Reflect.java
deleted file mode 100644
index 30745acb..00000000
--- a/util/android/src/org/liballeg/android/Reflect.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.liballeg.android;
-
-import android.util.Log;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-
-final class Reflect
-{
- static final String TAG = "Reflect";
-
- static boolean fieldExists(Object obj, String fieldName)
- {
- try {
- Class cls = obj.getClass();
- Field m = cls.getField(fieldName);
- return true;
- } catch (Exception x) {
- return false;
- }
- }
-
- static boolean methodExists(Object obj, String methName)
- {
- try {
- Class cls = obj.getClass();
- Method m = cls.getMethod(methName);
- return true;
- } catch (Exception x) {
- return false;
- }
- }
-
- static <T> T getField(Object obj, String field)
- {
- try {
- Class cls = obj.getClass();
- Field f = cls.getField(field);
- return (T)f.get(obj);
- }
- catch (NoSuchFieldException x) {
- Log.v(TAG, "field " + field + " not found in class " +
- obj.getClass().getCanonicalName());
- return null;
- }
- catch (IllegalArgumentException x) {
- Log.v(TAG, "IllegalArgumentException when getting field " + field +
- " from class " + obj.getClass().getCanonicalName());
- return null;
- }
- catch (IllegalAccessException x) {
- Log.v(TAG, "field " + field + " is not accessible in class " +
- obj.getClass().getCanonicalName());
- return null;
- }
- }
-
- static <T>
- T callMethod(Object obj, String methName, Class [] types, Object... args)
- {
- try {
- Class cls = obj.getClass();
- Method m = cls.getMethod(methName, types);
- return (T)m.invoke(obj, args);
- }
- catch (NoSuchMethodException x) {
- Log.v(TAG, "method " + methName + " does not exist in class " +
- obj.getClass().getCanonicalName());
- return null;
- }
- catch (NullPointerException x) {
- Log.v(TAG, "can't invoke null method name");
- return null;
- }
- catch (SecurityException x) {
- Log.v(TAG, "method " + methName + " is inaccessible in class " +
- obj.getClass().getCanonicalName());
- return null;
- }
- catch (IllegalAccessException x) {
- Log.v(TAG, "method " + methName + " is inaccessible in class " +
- obj.getClass().getCanonicalName());
- return null;
- }
- catch (InvocationTargetException x) {
- Log.v(TAG, "method " + methName + " threw an exception");
- return null;
- }
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/ScreenLock.java b/util/android/src/org/liballeg/android/ScreenLock.java
deleted file mode 100644
index e77caa12..00000000
--- a/util/android/src/org/liballeg/android/ScreenLock.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.liballeg.android;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.PowerManager;
-import android.util.Log;
-
-class ScreenLock
-{
- private static final String TAG = "ScreenLock";
-
- private Activity activity;
- private PowerManager.WakeLock wake_lock = null;
-
- ScreenLock(Activity activity)
- {
- this.activity = activity;
- }
-
- boolean inhibitScreenLock(boolean inhibit)
- {
- try {
- if (inhibit && wake_lock == null) {
- acquire();
- }
- else if (!inhibit && wake_lock != null) {
- release();
- }
- return true;
- }
- catch (Exception e) {
- Log.d(TAG, "Got exception in inhibitScreenLock: " + e.getMessage());
- return false;
- }
- }
-
- private void acquire()
- {
- PowerManager pm = (PowerManager)
- activity.getSystemService(Context.POWER_SERVICE);
- wake_lock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
- "Allegro Wake Lock");
- wake_lock.acquire();
- }
-
- private void release()
- {
- wake_lock.release();
- wake_lock = null;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/Sensors.java b/util/android/src/org/liballeg/android/Sensors.java
deleted file mode 100644
index 0f686124..00000000
--- a/util/android/src/org/liballeg/android/Sensors.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.liballeg.android;
-
-import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import java.util.List;
-
-public class Sensors implements SensorEventListener
-{
- private static SensorManager sensorManager;
- private List<Sensor> sensors;
-
- public native void nativeOnAccel(int id, float x, float y, float z);
-
- Sensors(Context context)
- {
- /* Only check for Accelerometers for now, not sure how we should utilize
- * other types.
- */
- sensorManager = (SensorManager)context.getSystemService("sensor");
- sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
- }
-
- void listen()
- {
- for (int i = 0; i < sensors.size(); i++) {
- sensorManager.registerListener(this, sensors.get(i),
- SensorManager.SENSOR_DELAY_GAME);
- }
- }
-
- void unlisten()
- {
- for (int i = 0; i < sensors.size(); i++) {
- sensorManager.unregisterListener(this, sensors.get(i));
- }
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy)
- {
- /* what to do? */
- }
-
- @Override
- public void onSensorChanged(SensorEvent event)
- {
- int i = sensors.indexOf(event.sensor);
- if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
- nativeOnAccel(i, event.values[0], event.values[1], event.values[2]);
- }
- }
-}
-
-/* vim: set sts=3 sw=3 et: */
diff --git a/util/android/src/org/liballeg/android/TouchListener.java b/util/android/src/org/liballeg/android/TouchListener.java
deleted file mode 100644
index c6f061b9..00000000
--- a/util/android/src/org/liballeg/android/TouchListener.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.liballeg.android;
-
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.View;
-
-class TouchListener implements View.OnTouchListener
-{
- private static final String TAG = "TouchListener";
-
- native void nativeOnTouch(int id, int action, float x, float y,
- boolean primary);
-
- TouchListener()
- {
- }
-
- // FIXME: Pull out android version detection into the setup and just check
- // some flags here, rather than checking for the existance of the fields and
- // methods over and over.
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
- int action = 0;
- int pointer_id = 0;
-
- Class[] no_args = new Class[0];
- Class[] int_arg = new Class[1];
- int_arg[0] = int.class;
-
- if (Reflect.methodExists(event, "getActionMasked")) { // android-8 / 2.2.x
- action = Reflect.<Integer>callMethod(event, "getActionMasked", no_args);
- int ptr_idx = Reflect.<Integer>callMethod(event, "getActionIndex", no_args);
- pointer_id = Reflect.<Integer>callMethod(event, "getPointerId", int_arg, ptr_idx);
- } else {
- int raw_action = event.getAction();
-
- if (Reflect.fieldExists(event, "ACTION_MASK")) { // android-5 / 2.0
- int mask = Reflect.<Integer>getField(event, "ACTION_MASK");
- action = raw_action & mask;
-
- int ptr_id_mask = Reflect.<Integer>getField(event, "ACTION_POINTER_ID_MASK");
- int ptr_id_shift = Reflect.<Integer>getField(event, "ACTION_POINTER_ID_SHIFT");
-
- pointer_id = event.getPointerId((raw_action & ptr_id_mask) >> ptr_id_shift);
- }
- else { // android-4 / 1.6
- /* no ACTION_MASK? no multi touch, no pointer_id, */
- action = raw_action;
- }
- }
-
- boolean primary = false;
-
- if (action == MotionEvent.ACTION_DOWN) {
- primary = true;
- action = Const.ALLEGRO_EVENT_TOUCH_BEGIN;
- }
- else if (action == MotionEvent.ACTION_UP) {
- primary = true;
- action = Const.ALLEGRO_EVENT_TOUCH_END;
- }
- else if (action == MotionEvent.ACTION_MOVE) {
- action = Const.ALLEGRO_EVENT_TOUCH_MOVE;
- }
- else if (action == MotionEvent.ACTION_CANCEL) {
- action = Const.ALLEGRO_EVENT_TOUCH_CANCEL;
- }
- // android-5 / 2.0
- else if (Reflect.fieldExists(event, "ACTION_POINTER_DOWN") &&
- action == Reflect.<Integer>getField(event, "ACTION_POINTER_DOWN"))
- {
- action = Const.ALLEGRO_EVENT_TOUCH_BEGIN;
- }
- else if (Reflect.fieldExists(event, "ACTION_POINTER_UP") &&
- action == Reflect.<Integer>getField(event, "ACTION_POINTER_UP"))
- {
- action = Const.ALLEGRO_EVENT_TOUCH_END;
- }
- else {
- Log.v(TAG, "unknown MotionEvent type: " + action);
- return false;
- }
-
- if (Reflect.methodExists(event, "getPointerCount")) { // android-5 / 2.0
- int pointer_count = Reflect.<Integer>callMethod(event,
- "getPointerCount", no_args);
- for (int i = 0; i < pointer_count; i++) {
- float x = Reflect.<Float>callMethod(event, "getX", int_arg, i);
- float y = Reflect.<Float>callMethod(event, "getY", int_arg, i);
- int id = Reflect.<Integer>callMethod(event, "getPointerId",
- int_arg, i);
-
- /* Not entirely sure we need to report move events for non-primary
- * touches here but examples I've seen say that the
- * ACTION_[POINTER_][UP|DOWN] report all touches and they can
- * change between the last MOVE and the UP|DOWN event.
- */
- if (id == pointer_id) {
- nativeOnTouch(id, action, x, y, primary);
- } else {
- nativeOnTouch(id, Const.ALLEGRO_EVENT_TOUCH_MOVE, x, y,
- primary);
- }
- }
- } else {
- nativeOnTouch(pointer_id, action, event.getX(), event.getY(),
- primary);
- }
-
- return true;
- }
-}
-
-/* vim: set sts=3 sw=3 et: */

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 16, 2:22 AM (2 w, 13 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70517
Default Alt Text
(65 KB)

Event Timeline