aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authordhewg2011-02-26 12:51:13 +0100
committerdhewg2011-02-27 09:04:31 +0100
commit983e16b36a68292021833aa9b69305a37ffe2f91 (patch)
tree49ede037996e347f38ac7c27c781d1098579447d /backends
parent6b1c575d1d6471a922978559c69426b1f9856768 (diff)
downloadscummvm-rg350-983e16b36a68292021833aa9b69305a37ffe2f91.tar.gz
scummvm-rg350-983e16b36a68292021833aa9b69305a37ffe2f91.tar.bz2
scummvm-rg350-983e16b36a68292021833aa9b69305a37ffe2f91.zip
ANDROID: Formatting
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java13
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java14
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVM.java128
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java90
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java4
5 files changed, 174 insertions, 75 deletions
diff --git a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java b/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
index 1a0972d4dd..cede7eedd4 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
@@ -19,7 +19,7 @@ public class EditableSurfaceView extends SurfaceView {
}
public EditableSurfaceView(Context context, AttributeSet attrs,
- int defStyle) {
+ int defStyle) {
super(context, attrs, defStyle);
}
@@ -40,7 +40,9 @@ public class EditableSurfaceView extends SurfaceView {
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
- return super.performEditorAction(actionCode); // Sends enter key
+
+ // Sends enter key
+ return super.performEditorAction(actionCode);
}
}
@@ -49,11 +51,12 @@ public class EditableSurfaceView extends SurfaceView {
outAttrs.initialCapsMode = 0;
outAttrs.initialSelEnd = outAttrs.initialSelStart = -1;
outAttrs.inputType = (InputType.TYPE_CLASS_TEXT |
- InputType.TYPE_TEXT_VARIATION_NORMAL |
- InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
+ InputType.TYPE_TEXT_VARIATION_NORMAL |
+ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
outAttrs.imeOptions = (EditorInfo.IME_ACTION_DONE |
- EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ EditorInfo.IME_FLAG_NO_EXTRACT_UI);
return new MyInputConnection();
}
}
+
diff --git a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java b/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
index c94ab0a3ff..3c91d9f5dc 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
@@ -28,7 +28,7 @@ public class PluginProvider extends BroadcastReceiver {
try {
info = context.getPackageManager()
.getReceiverInfo(new ComponentName(context, this.getClass()),
- PackageManager.GET_META_DATA);
+ PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
Log.e(LOG_TAG, "Error finding my own info?", e);
return;
@@ -38,17 +38,17 @@ public class PluginProvider extends BroadcastReceiver {
if (mylib != null) {
ArrayList<String> all_libs =
extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS);
-
all_libs.add(new Uri.Builder()
- .scheme("plugin")
- .authority(context.getPackageName())
- .path(mylib)
- .toString());
+ .scheme("plugin")
+ .authority(context.getPackageName())
+ .path(mylib)
+ .toString());
extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS,
- all_libs);
+ all_libs);
}
setResultExtras(extras);
}
}
+
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
index 0e905f43a5..698e508605 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
@@ -35,16 +35,19 @@ import java.util.LinkedHashMap;
public class ScummVM implements SurfaceHolder.Callback {
protected final static String LOG_TAG = "ScummVM";
- private final int AUDIO_FRAME_SIZE = 2 * 2; // bytes. 16bit audio * stereo
+ // bytes. 16bit audio * stereo
+ private final int AUDIO_FRAME_SIZE = 2 * 2;
public static class AudioSetupException extends Exception {}
- private long nativeScummVM; // native code hangs itself here
+ // native code hangs itself here
+ private long nativeScummVM;
boolean scummVMRunning = false;
private native void create(AssetManager am);
public ScummVM(Context context) {
- create(context.getAssets()); // Init C++ code, set nativeScummVM
+ // Init C++ code, set nativeScummVM
+ create(context.getAssets());
}
private native void nativeDestroy();
@@ -55,6 +58,7 @@ public class ScummVM implements SurfaceHolder.Callback {
nativeScummVM = 0;
}
}
+
protected void finalize() {
destroy();
}
@@ -62,17 +66,17 @@ public class ScummVM implements SurfaceHolder.Callback {
// Surface creation:
// GUI thread: create surface, release lock
// ScummVM thread: acquire lock (block), read surface
- //
+
// Surface deletion:
// GUI thread: post event, acquire lock (block), return
// ScummVM thread: read event, free surface, release lock
- //
+
// In other words, ScummVM thread does this:
// acquire lock
// setup surface
// when SCREEN_CHANGED arrives:
- // destroy surface
- // release lock
+ // destroy surface
+ // release lock
// back to acquire lock
static final int configSpec[] = {
EGL10.EGL_RED_SIZE, 5,
@@ -82,6 +86,7 @@ public class ScummVM implements SurfaceHolder.Callback {
EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
EGL10.EGL_NONE,
};
+
EGL10 egl;
EGLDisplay eglDisplay = EGL10.EGL_NO_DISPLAY;
EGLConfig eglConfig;
@@ -96,7 +101,7 @@ public class ScummVM implements SurfaceHolder.Callback {
}
public void surfaceChanged(SurfaceHolder holder, int format,
- int width, int height) {
+ int width, int height) {
// Disabled while I debug GL problems
pushEvent(new Event(Event.EVENT_SCREEN_CHANGED));
}
@@ -111,6 +116,7 @@ public class ScummVM implements SurfaceHolder.Callback {
// For debugging
private static final Map<String, Integer> attribs;
+
static {
attribs = new LinkedHashMap<String, Integer>();
attribs.put("CONFIG_ID", EGL10.EGL_CONFIG_ID);
@@ -141,11 +147,14 @@ public class ScummVM implements SurfaceHolder.Callback {
attribs.put("TRANSPARENT_GREEN_VALUE", EGL10.EGL_TRANSPARENT_GREEN_VALUE);
attribs.put("TRANSPARENT_BLUE_VALUE", EGL10.EGL_TRANSPARENT_BLUE_VALUE);
}
+
private void dumpEglConfig(EGLConfig config) {
int[] value = new int[1];
+
for (Map.Entry<String, Integer> entry : attribs.entrySet()) {
egl.eglGetConfigAttrib(eglDisplay, config,
- entry.getValue(), value);
+ entry.getValue(), value);
+
if (value[0] == EGL10.EGL_NONE)
Log.d(LOG_TAG, entry.getKey() + ": NONE");
else
@@ -157,12 +166,15 @@ public class ScummVM implements SurfaceHolder.Callback {
private void createScummVMGLContext() {
egl = (EGL10)EGLContext.getEGL();
eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+
int[] version = new int[2];
egl.eglInitialize(eglDisplay, version);
+
int[] num_config = new int[1];
egl.eglChooseConfig(eglDisplay, configSpec, null, 0, num_config);
final int numConfigs = num_config[0];
+
if (numConfigs <= 0)
throw new IllegalArgumentException("No configs match configSpec");
@@ -179,13 +191,15 @@ public class ScummVM implements SurfaceHolder.Callback {
// Android's eglChooseConfig is busted in several versions and
// devices so we have to filter/rank the configs again ourselves.
eglConfig = chooseEglConfig(configs);
+
if (false) {
Log.d(LOG_TAG, String.format("Chose EGL config from %d possibilities.", numConfigs));
dumpEglConfig(eglConfig);
}
eglContext = egl.eglCreateContext(eglDisplay, eglConfig,
- EGL10.EGL_NO_CONTEXT, null);
+ EGL10.EGL_NO_CONTEXT, null);
+
if (eglContext == EGL10.EGL_NO_CONTEXT)
throw new RuntimeException("Failed to create context");
}
@@ -198,32 +212,43 @@ public class ScummVM implements SurfaceHolder.Callback {
for (int i = 0; i < configs.length; i++) {
EGLConfig config = configs[i];
int score = 10000;
+
egl.eglGetConfigAttrib(eglDisplay, config,
- EGL10.EGL_SURFACE_TYPE, value);
+ EGL10.EGL_SURFACE_TYPE, value);
+
+ // must have
if ((value[0] & EGL10.EGL_WINDOW_BIT) == 0)
- continue; // must have
+ continue;
egl.eglGetConfigAttrib(eglDisplay, config,
- EGL10.EGL_CONFIG_CAVEAT, value);
+ EGL10.EGL_CONFIG_CAVEAT, value);
+
if (value[0] != EGL10.EGL_NONE)
score -= 1000;
// Must be at least 555, but then smaller is better
- final int[] colorBits = {EGL10.EGL_RED_SIZE,
- EGL10.EGL_GREEN_SIZE,
- EGL10.EGL_BLUE_SIZE,
- EGL10.EGL_ALPHA_SIZE};
+ final int[] colorBits = { EGL10.EGL_RED_SIZE,
+ EGL10.EGL_GREEN_SIZE,
+ EGL10.EGL_BLUE_SIZE,
+ EGL10.EGL_ALPHA_SIZE
+ };
+
for (int component : colorBits) {
- egl.eglGetConfigAttrib(eglDisplay, config,
- component, value);
+ egl.eglGetConfigAttrib(eglDisplay, config, component, value);
+
+ // boost if >5 bits accuracy
if (value[0] >= 5)
- score += 10; // boost if >5 bits accuracy
- score -= value[0]; // penalize for wasted bits
+ score += 10;
+
+ // penalize for wasted bits
+ score -= value[0];
}
egl.eglGetConfigAttrib(eglDisplay, config,
- EGL10.EGL_DEPTH_SIZE, value);
- score -= value[0]; // penalize for wasted bits
+ EGL10.EGL_DEPTH_SIZE, value);
+
+ // penalize for wasted bits
+ score -= value[0];
if (score > bestScore) {
best = i;
@@ -248,28 +273,35 @@ public class ScummVM implements SurfaceHolder.Callback {
Log.e(LOG_TAG, "Interrupted while waiting for surface lock", e);
return;
}
+
eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig,
nativeSurface, null);
+
if (eglSurface == EGL10.EGL_NO_SURFACE)
Log.e(LOG_TAG, "CreateWindowSurface failed!");
+
egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
GL10 gl = (GL10)eglContext.getGL();
if (_log_version) {
Log.i(LOG_TAG, String.format("Using EGL %s (%s); GL %s/%s (%s)",
- egl.eglQueryString(eglDisplay, EGL10.EGL_VERSION),
- egl.eglQueryString(eglDisplay, EGL10.EGL_VENDOR),
- gl.glGetString(GL10.GL_VERSION),
- gl.glGetString(GL10.GL_RENDERER),
- gl.glGetString(GL10.GL_VENDOR)));
- _log_version = false; // only log this once
+ egl.eglQueryString(eglDisplay, EGL10.EGL_VERSION),
+ egl.eglQueryString(eglDisplay, EGL10.EGL_VENDOR),
+ gl.glGetString(GL10.GL_VERSION),
+ gl.glGetString(GL10.GL_RENDERER),
+ gl.glGetString(GL10.GL_VENDOR)));
+
+ // only log this once
+ _log_version = false;
}
int[] value = new int[1];
egl.eglQuerySurface(eglDisplay, eglSurface, EGL10.EGL_WIDTH, value);
+
int width = value[0];
egl.eglQuerySurface(eglDisplay, eglSurface, EGL10.EGL_HEIGHT, value);
+
int height = value[0];
Log.i(LOG_TAG, String.format("New surface is %dx%d", width, height));
setSurfaceSize(width, height);
@@ -279,7 +311,8 @@ public class ScummVM implements SurfaceHolder.Callback {
protected void destroyScummVMSurface() {
if (eglSurface != null) {
egl.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE,
- EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+ EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+
egl.eglDestroySurface(eglDisplay, eglSurface);
eglSurface = EGL10.EGL_NO_SURFACE;
}
@@ -298,6 +331,7 @@ public class ScummVM implements SurfaceHolder.Callback {
if (error == EGL11.EGL_CONTEXT_LOST)
return false;
}
+
return true;
}
@@ -324,6 +358,7 @@ public class ScummVM implements SurfaceHolder.Callback {
protected void showVirtualKeyboard(boolean enable) {}
protected String[] getSysArchives() { return new String[0]; }
protected String[] getPluginDirectories() { return new String[0]; }
+
protected void initBackend() throws AudioSetupException {
createScummVMGLContext();
initAudio();
@@ -375,17 +410,19 @@ public class ScummVM implements SurfaceHolder.Callback {
scummvm.audioMixCallback(buf);
offset = 0;
}
+
int len = buf.length - offset;
int ret = audio_track.write(buf, offset, len);
if (ret < 0) {
Log.w(LOG_TAG, String.format(
- "AudioTrack.write(%dB) returned error %d",
- buf.length, ret));
+ "AudioTrack.write(%dB) returned error %d",
+ buf.length, ret));
break;
} else if (ret != len) {
Log.w(LOG_TAG, String.format(
- "Short audio write. Wrote %dB, not %dB",
- ret, buf.length));
+ "Short audio write. Wrote %dB, not %dB",
+ ret, buf.length));
+
// Buffer is full, so yield cpu for a while
Thread.sleep(100);
}
@@ -409,21 +446,27 @@ public class ScummVM implements SurfaceHolder.Callback {
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT);
if (buf_size < 0) {
- int guess = AUDIO_FRAME_SIZE * sample_rate / 100; // 10ms of audio
+ // 10ms of audio
+ int guess = AUDIO_FRAME_SIZE * sample_rate / 100;
+
Log.w(LOG_TAG, String.format(
"Unable to get min audio buffer size (error %d). Guessing %dB.",
buf_size, guess));
+
buf_size = guess;
}
+
Log.d(LOG_TAG, String.format("Using %dB buffer for %dHZ audio",
- buf_size, sample_rate));
+ buf_size, sample_rate));
+
AudioTrack audio_track =
new AudioTrack(AudioManager.STREAM_MUSIC,
- sample_rate,
- AudioFormat.CHANNEL_CONFIGURATION_STEREO,
- AudioFormat.ENCODING_PCM_16BIT,
- buf_size,
- AudioTrack.MODE_STREAM);
+ sample_rate,
+ AudioFormat.CHANNEL_CONFIGURATION_STEREO,
+ AudioFormat.ENCODING_PCM_16BIT,
+ buf_size,
+ AudioTrack.MODE_STREAM);
+
if (audio_track.getState() != AudioTrack.STATE_INITIALIZED) {
Log.e(LOG_TAG, "Error initialising Android audio system.");
throw new AudioSetupException();
@@ -448,7 +491,7 @@ public class ScummVM implements SurfaceHolder.Callback {
final boolean sleep_for_debugger = false;
if (sleep_for_debugger) {
try {
- Thread.sleep(20*1000);
+ Thread.sleep(20 * 1000);
} catch (InterruptedException e) {
}
}
@@ -460,3 +503,4 @@ public class ScummVM implements SurfaceHolder.Callback {
System.load(libpath.getPath());
}
}
+
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
index 8929809999..0dd110942b 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
@@ -38,6 +38,7 @@ public class ScummVMActivity extends Activity {
// devices :(
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
+
try {
// This 'density' term is very confusing.
int DENSITY_LOW = metrics.getClass().getField("DENSITY_LOW").getInt(null);
@@ -63,6 +64,7 @@ public class ScummVMActivity extends Activity {
scummvmRunning = true;
notifyAll();
}
+
super.initBackend();
}
@@ -104,6 +106,7 @@ public class ScummVMActivity extends Activity {
});
}
}
+
private MyScummVM scummvm;
private Thread scummvm_thread;
@@ -125,18 +128,18 @@ public class ScummVMActivity extends Activity {
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.no_sdcard)
.setNegativeButton(R.string.quit,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- finish();
- }
- })
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int which) {
+ finish();
+ }
+ })
.show();
+
return;
}
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
-
main_surface.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return onTouchEvent(event);
@@ -151,6 +154,7 @@ public class ScummVMActivity extends Activity {
// Start ScummVM
scummvm = new MyScummVM();
+
scummvm_thread = new Thread(new Runnable() {
public void run() {
try {
@@ -166,6 +170,7 @@ public class ScummVMActivity extends Activity {
}
}
}, "ScummVM");
+
scummvm_thread.start();
// Block UI thread until ScummVM has started. In particular,
@@ -207,14 +212,17 @@ public class ScummVMActivity extends Activity {
was_paused = true;
scummvm.pause();
}
+
super.onPause();
}
@Override
public void onResume() {
super.onResume();
+
if (scummvm != null && was_paused)
scummvm.resume();
+
was_paused = false;
}
@@ -222,16 +230,20 @@ public class ScummVMActivity extends Activity {
public void onStop() {
if (scummvm != null) {
scummvm.pushEvent(new Event(Event.EVENT_QUIT));
+
try {
- scummvm_thread.join(1000); // 1s timeout
+ // 1s timeout
+ scummvm_thread.join(1000);
} catch (InterruptedException e) {
Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e);
}
}
+
super.onStop();
}
static final int MSG_MENU_LONG_PRESS = 1;
+
private final Handler keycodeMenuTimeoutHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -251,7 +263,7 @@ public class ScummVMActivity extends Activity {
@Override
public boolean onKeyMultiple(int keyCode, int repeatCount,
- KeyEvent kevent) {
+ KeyEvent kevent) {
return onKeyDown(keyCode, kevent);
}
@@ -261,12 +273,12 @@ public class ScummVMActivity extends Activity {
switch (keyCode) {
case KeyEvent.KEYCODE_MENU:
// Have to reimplement hold-down-menu-brings-up-softkeybd
- // ourselves, since we are otherwise hijacking the menu
- // key :(
+ // ourselves, since we are otherwise hijacking the menu key :(
// See com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel()
// for the usual Android implementation of this feature.
+
+ // Ignore keyrepeat for menu
if (kevent.getRepeatCount() > 0)
- // Ignore keyrepeat for menu
return false;
boolean timeout_fired = !keycodeMenuTimeoutHandler.hasMessages(MSG_MENU_LONG_PRESS);
@@ -274,20 +286,24 @@ public class ScummVMActivity extends Activity {
if (kevent.getAction() == KeyEvent.ACTION_DOWN) {
keycodeMenuTimeoutHandler.sendMessageDelayed(keycodeMenuTimeoutHandler.obtainMessage(MSG_MENU_LONG_PRESS),
- ViewConfiguration.getLongPressTimeout());
+ ViewConfiguration.getLongPressTimeout());
return true;
}
if (kevent.getAction() == KeyEvent.ACTION_UP) {
if (!timeout_fired)
scummvm.pushEvent(new Event(Event.EVENT_MAINMENU));
+
return true;
}
+
return false;
+
case KeyEvent.KEYCODE_CAMERA:
case KeyEvent.KEYCODE_SEARCH:
_do_right_click = (kevent.getAction() == KeyEvent.ACTION_DOWN);
return true;
+
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
@@ -299,45 +315,59 @@ public class ScummVMActivity extends Activity {
// Some other handsets lack a trackball, so the DPAD is
// the only way of moving the cursor.
int motion_action;
+
// FIXME: this logic is a mess.
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
switch (kevent.getAction()) {
case KeyEvent.ACTION_DOWN:
motion_action = MotionEvent.ACTION_DOWN;
break;
+
case KeyEvent.ACTION_UP:
motion_action = MotionEvent.ACTION_UP;
break;
- default: // ACTION_MULTIPLE
+
+ // ACTION_MULTIPLE
+ default:
return false;
}
- } else
+ } else {
motion_action = MotionEvent.ACTION_MOVE;
+ }
Event e = new Event(getEventType(motion_action));
+
e.mouse_x = 0;
e.mouse_y = 0;
e.mouse_relative = true;
+
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
e.mouse_y = -TRACKBALL_SCALE;
break;
+
case KeyEvent.KEYCODE_DPAD_DOWN:
e.mouse_y = TRACKBALL_SCALE;
break;
+
case KeyEvent.KEYCODE_DPAD_LEFT:
e.mouse_x = -TRACKBALL_SCALE;
break;
+
case KeyEvent.KEYCODE_DPAD_RIGHT:
e.mouse_x = TRACKBALL_SCALE;
break;
}
+
scummvm.pushEvent(e);
+
return true;
}
+
case KeyEvent.KEYCODE_BACK:
// skip isSystem() check and fall through to main code
break;
+
default:
if (kevent.isSystem())
return false;
@@ -352,51 +382,63 @@ public class ScummVMActivity extends Activity {
e.type = Event.EVENT_KEYDOWN;
e.synthetic = false;
break;
+
case KeyEvent.ACTION_UP:
e.type = Event.EVENT_KEYUP;
e.synthetic = false;
break;
+
case KeyEvent.ACTION_MULTIPLE:
// e.type is handled below
e.synthetic = true;
break;
+
default:
return false;
}
e.kbd_keycode = Event.androidKeyMap.containsKey(keyCode) ?
Event.androidKeyMap.get(keyCode) : Event.KEYCODE_INVALID;
+
e.kbd_ascii = kevent.getUnicodeChar();
+
if (e.kbd_ascii == 0)
e.kbd_ascii = e.kbd_keycode; // scummvm keycodes are mostly ascii
-
e.kbd_flags = 0;
+
if (kevent.isAltPressed())
e.kbd_flags |= Event.KBD_ALT;
- if (kevent.isSymPressed()) // no ctrl key in android, so use sym (?)
+
+ // no ctrl key in android, so use sym (?)
+ if (kevent.isSymPressed())
e.kbd_flags |= Event.KBD_CTRL;
+
if (kevent.isShiftPressed()) {
if (keyCode >= KeyEvent.KEYCODE_0 &&
- keyCode <= KeyEvent.KEYCODE_9) {
+ keyCode <= KeyEvent.KEYCODE_9) {
// Shift+number -> convert to F* key
int offset = keyCode == KeyEvent.KEYCODE_0 ?
10 : keyCode - KeyEvent.KEYCODE_1; // turn 0 into 10
+
e.kbd_keycode = Event.KEYCODE_F1 + offset;
e.kbd_ascii = Event.ASCII_F1 + offset;
- } else
+ } else {
e.kbd_flags |= Event.KBD_SHIFT;
+ }
}
if (kevent.getAction() == KeyEvent.ACTION_MULTIPLE) {
for (int i = 0; i <= kevent.getRepeatCount(); i++) {
e.type = Event.EVENT_KEYDOWN;
scummvm.pushEvent(e);
+
e.type = Event.EVENT_KEYUP;
scummvm.pushEvent(e);
}
- } else
+ } else {
scummvm.pushEvent(e);
+ }
return true;
}
@@ -407,11 +449,14 @@ public class ScummVMActivity extends Activity {
_last_click_was_right = _do_right_click;
return _last_click_was_right ?
Event.EVENT_RBUTTONDOWN : Event.EVENT_LBUTTONDOWN;
+
case MotionEvent.ACTION_UP:
return _last_click_was_right ?
Event.EVENT_RBUTTONUP : Event.EVENT_LBUTTONUP;
+
case MotionEvent.ACTION_MOVE:
return Event.EVENT_MOUSEMOVE;
+
default:
return Event.EVENT_INVALID;
}
@@ -429,6 +474,7 @@ public class ScummVMActivity extends Activity {
e.mouse_y =
(int)(event.getY() * event.getYPrecision()) * TRACKBALL_SCALE;
e.mouse_relative = true;
+
scummvm.pushEvent(e);
return true;
@@ -437,6 +483,7 @@ public class ScummVMActivity extends Activity {
@Override
public boolean onTouchEvent(MotionEvent event) {
int type = getEventType(event.getAction());
+
if (type == Event.EVENT_INVALID)
return false;
@@ -444,6 +491,7 @@ public class ScummVMActivity extends Activity {
e.mouse_x = (int)event.getX();
e.mouse_y = (int)event.getY();
e.mouse_relative = false;
+
scummvm.pushEvent(e);
return true;
@@ -453,6 +501,7 @@ public class ScummVMActivity extends Activity {
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
InputMethodManager imm = (InputMethodManager)
getSystemService(INPUT_METHOD_SERVICE);
+
if (show)
imm.showSoftInput(main_surface, InputMethodManager.SHOW_IMPLICIT);
else
@@ -460,3 +509,4 @@ public class ScummVMActivity extends Activity {
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
+
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
index 37a9d09e1a..80735e2c2a 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
@@ -13,11 +13,12 @@ public class ScummVMApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
+
// This is still on /data :(
cache_dir = getCacheDir();
// This is mounted noexec :(
//cache_dir = new File(Environment.getExternalStorageDirectory(),
- // "/.ScummVM.tmp");
+ // "/.ScummVM.tmp");
// This is owned by download manager and requires special
// permissions to access :(
//cache_dir = Environment.getDownloadCacheDirectory();
@@ -27,3 +28,4 @@ public class ScummVMApplication extends Application {
return cache_dir;
}
}
+