diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-08-16 20:12:06 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-08-16 20:12:06 +0000 |
commit | 934a5a5808c7a0b0dff469ad2c3a523e78a4ef4b (patch) | |
tree | 0aec8be568bea16b68ac87086387ba73089d931f /android/src/org | |
parent | e726e53da68d3ff53a79023d5dc5cfcc020fb864 (diff) | |
download | rockbox-934a5a5808c7a0b0dff469ad2c3a523e78a4ef4b.tar.gz rockbox-934a5a5808c7a0b0dff469ad2c3a523e78a4ef4b.zip |
Android port: add support for hardware keys
* Forward Java KeyEvents to C layer and translate them to Rockbox BUTTON_*.
* Add a basic Android keymap
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27832 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org')
-rw-r--r-- | android/src/org/rockbox/RockboxFramebuffer.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java index 32fbfef111..1734b4fab1 100644 --- a/android/src/org/rockbox/RockboxFramebuffer.java +++ b/android/src/org/rockbox/RockboxFramebuffer.java @@ -22,23 +22,28 @@ package org.rockbox; import java.nio.ByteBuffer; + import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.util.Log; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -public class RockboxFramebuffer extends View +public class RockboxFramebuffer extends View { private Bitmap btm; private ByteBuffer native_buf; - public RockboxFramebuffer(Context c) { super(c); btm = null; + + /* Needed so we can catch KeyEvents */ + setFocusable(true); + requestFocus(); } public void onDraw(Canvas c) @@ -55,7 +60,6 @@ public class RockboxFramebuffer extends View public void java_lcd_update() { - btm.copyPixelsFromBuffer(native_buf); postInvalidate(); } @@ -64,6 +68,7 @@ public class RockboxFramebuffer extends View { /* can't copy a partial buffer */ btm.copyPixelsFromBuffer(native_buf); + postInvalidate(x, y, x+w, y+h); } @@ -90,7 +95,17 @@ public class RockboxFramebuffer extends View pixelHandler((int)me.getX(), (int)me.getY()); return true; } - + + public boolean onKeyDown(int keyCode, KeyEvent event) + { + return buttonHandler(keyCode, true); + } + + public boolean onKeyUp(int keyCode, KeyEvent event) + { + return buttonHandler(keyCode, false); + } + /* the two below should only be called from the activity thread */ public void suspend() { /* suspend, Rockbox will not make any lcd updates */ @@ -105,4 +120,5 @@ public class RockboxFramebuffer extends View public native void set_lcd_active(int active); public native void pixelHandler(int x, int y); public native void touchHandler(int down); + public native boolean buttonHandler(int keycode, boolean state); } |