Jump to content


[mod] Use volume up/down keys as d-pad left/right when soft keyboard is shown

- - - - -

  • Please log in to reply
8 replies to this topic

#1
azuwis

azuwis

    Newbie

  • Members
  • Pip
  • 44 posts
Htc ime mod has a very useful feature for android phones without d-pad and track ball, use volume keys to move cursor.

But unfortunately I can't take benefit of it because htc ime does not support my native language.

After looking around android source code, I figured out how to implement that myself.

With this framework.jar, when soft keyboard is shown, volume up/down will generate d-pad left/right key events, so you can move cursor in any input box, even when selecting text. It should work with any ime, and should not conflict if ime handle volume keys itself.

The framework.jar is modified for 1.100.39.EMEA.GEN1_A21E_A rom, I have no idea whether it will work with other roms(I guess not).

Unpack the zip, use the following command to flash:
adb remount
adb pull /system/framework/framework.jar framework.jar
adb push framework-mod.jar /system/framework/framework.jar
adb reboot

Here is the patch against android's base framework android-2.1_r2.1p2 branch http://android.git.k...5111dda41187332
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 5499bba..315cc01 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -1600,6 +1600,20 @@ public class InputMethodService extends AbstractInputMethodService {
			 }
			 return false;
		 }
+
+		if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+				if(isInputViewShown()) {
+						sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT);
+						return true;
+				}
+		}
+		if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+				if(isInputViewShown()) {
+						sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT);
+						return true;
+				}
+		}
+
		 return doMovementKey(keyCode, event, MOVEMENT_DOWN);
	 }
 
@@ -1645,6 +1659,12 @@ public class InputMethodService extends AbstractInputMethodService {
				 && !event.isCanceled()) {
			 return handleBack(true);
		 }
+
+		if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+				if(isInputViewShown()) {
+						return true;
+				}
+		}
		 
		 return doMovementKey(keyCode, event, MOVEMENT_UP);
	 }

The patch and modified deassemble code(smali) are also provided in the zip pack.
Attached File  framework_mod.zip   2.76MB   110 downloads

Update:

add mod for Froyo/E FRF91 framework-mod-froyo.zip

Edited by azuwis, 27 July 2010 - 09:07 AM.


#2
fantong

fantong

    Regular

  • Members
  • PipPip
  • 85 posts
Great, can it working with xian latest rom ?

Edited by fantong, 20 July 2010 - 11:34 AM.


#3
fantong

fantong

    Regular

  • Members
  • PipPip
  • 85 posts
I had tried.
It works with Xian's latest rom.
Thanks


#4
xaueious

xaueious

    Diehard

  • Members
  • PipPipPipPip
  • 318 posts
  • Gender:Male
  • Location:Canada
  • Devices:Acer Liquid E
  • Twitter:@xqz
Wait did you built this from source or did you modify the smali? Just wondering...


#5
azuwis

azuwis

    Newbie

  • Members
  • Pip
  • 44 posts

View Postxaueious, on Jul 21 2010, 11:48, said:

Wait did you built this from source or did you modify the smali? Just wondering...

build aosp framework.jar, baksmali both acer's and aosp's framework.jar, compare smali files, replace onkeydown and onkeyup function of acer's InputMethodServices.smali


#6
xaueious

xaueious

    Diehard

  • Members
  • PipPipPipPip
  • 318 posts
  • Gender:Male
  • Location:Canada
  • Devices:Acer Liquid E
  • Twitter:@xqz
I asked because I wasn't sure.

I wont be flashing this one in particular though... I'm on LCR... The feature is nice in itself though :angry:


#7
azuwis

azuwis

    Newbie

  • Members
  • Pip
  • 44 posts

View Postxaueious, on Jul 21 2010, 13:15, said:

I asked because I wasn't sure.

I wont be flashing this one in particular though... I'm on LCR... The feature is nice in itself though :angry:

Vache said next LCR release will include this.

In fact, I can provide one for LCR. But I need to test it before publish, and I don't want to flash the phone right now.

If you want, I can give you one for testing.


#8
xaueious

xaueious

    Diehard

  • Members
  • PipPipPipPip
  • 318 posts
  • Gender:Male
  • Location:Canada
  • Devices:Acer Liquid E
  • Twitter:@xqz
Actually I'm way more interested in getting the volume rockers to skip music than this feature since I'm on HTC IME all the time. But this is neat for people who are on other IMEs.


#9
azuwis

azuwis

    Newbie

  • Members
  • Pip
  • 44 posts

View Postxaueious, on Jul 21 2010, 13:41, said:

Actually I'm way more interested in getting the volume rockers to skip music than this feature since I'm on HTC IME all the time. But this is neat for people who are on other IMEs.
Maybe this can be implemented by modifying Music Mod(http://github.com/el...sic/tree/eclair)

Or make a feature request to the Music Mod author?

Edited by azuwis, 21 July 2010 - 06:15 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users