Jump to content

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


Recommended Posts

Guest azuwis
Posted (edited)

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.kernel.org/?p=platform/...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.

framework_mod.zip

Update:

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

Edited by azuwis
Guest fantong
Posted (edited)

Great, can it working with xian latest rom ?

Edited by fantong
Guest fantong
Posted

I had tried.

It works with Xian's latest rom.

Thanks

Guest xaueious
Posted

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

Guest azuwis
Posted
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

Guest xaueious
Posted

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:

Guest azuwis
Posted
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.

Guest xaueious
Posted

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.

Guest azuwis
Posted (edited)
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/eliotstocker/android_packages_apps_Music/tree/eclair)

Or make a feature request to the Music Mod author?

Edited by azuwis

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.