Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,769,355 Members 39,841 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][UPDATED] Modified keymap files for G2

Tip us?
 
teferi
Old
(Last edited by teferi; 18th November 2010 at 05:18 PM.) Reason: new version
#1  
Junior Member - OP
Thanks Meter 6
Posts: 28
Join Date: Oct 2010
Default [MOD][UPDATED] Modified keymap files for G2

After some quality time with the AOSP source and a hex editor today, I've come up with modified keymap files for the G2 that make the keyboard a bit more useful. It's gone through three iterations now, and I think it covers every key you can type on a normal keyboard now. Here it is.


Changes in version 0.3 (relative to the keymap in 0.1 below):

- left softkey is now "\"/"|"/"`"
- right softkeys are now "["/"{"/"<" and "]"/"}"/">"
- alt-z is now "^", since .com is tab now

Changes in version 0.2:
- modifications to the tools used in dumping keymaps and regenerating them

Changes in version 0.1:

- make ".com" a TAB key, as it ought to be
- make first right soft key "\" (shifted is "|")
- make second right soft key "<" (shifted is ">")

Installation instructions:

NOTE: I have not tested this on the Desire Z. I have no idea what its keycharmap and keylayout files look like.
FURTHER NOTE: Use at your own risk, etc, etc. I've included the original keymap files in the .zip as (filename).orig, but it can't hurt to take your own backups
FURTHER FURTHER NOTE: I've only tested version 0.3 on Cyanogenmod 6.1-RC1 on my G2, but there's no reason it shouldn't work on stock or an alternate ROM, since the keycodes I'm actually using should be the same.


PREREQUISITES: S-OFF G2, /system mounted read-write, root, busybox for 'cp'

- download file
- unzip g2-keymap-0.3.zip
- $ adb push vision-keypad.kl /sdcard
- $ adb push vision-keypad.kcm.bin /sdcard
- $ adb shell
- $ su # (if you don't have ro.secure turned off)
- # cp -f /sdcard/vision-keypad.kl /system/usr/keylayout/
- # cp -f /sdcard/vision-keypad.kcm.bin /system/usr/keychars/
- # reboot

To uninstall, just copy the .orig files back into place (so, copy vision-keypad.kl.orig to /system/usr/keylayout/vision-keypad.kl and vision-keypad.kcm.bin.orig to /system/usr/keychars/vision-keypad.kcm.bin

Hope you find this useful!

You can find the tools I used for dumping keymaps and the keymap files themselves with history on my github at https://github.com/aglasgall/g2-keymap
Attached Files
File Type: zip g2-keymap-0.3.zip - [Click for QR Code] (2.9 KB, 1218 views)
The Following 6 Users Say Thank You to teferi For This Useful Post: [ Click to Expand ]
 
mikeybot
Old
#2  
Member
Thanks Meter 7
Posts: 85
Join Date: Nov 2008
Location: philly
Just out of fear of screwing my phone up, on the cp I'm getting:
cp: can't create '/system/usr/keylayout/vision-keypad.kl': File exists

How should I proceed from here?
Phone 1: Galaxy S Relay 4G
ROM: Cyanogenmod 10.1
Recovery: Clockwork

Phone 2: G2
ROM: Cyanogen 9.1.0
Recovery: Clockwork 3.0.2.4

Phone 3: Busted ass Blackberry Pearl
(emergencies only)
 
teferi
Old
#3  
Junior Member - OP
Thanks Meter 6
Posts: 28
Join Date: Oct 2010
Should have remembered that busybox cp refuses to overwrite files without -f. Use 'cp -f'; I'll update the instructions.

Thanks for the catch!
 
funkeee
Old
#4  
funkeee's Avatar
Senior Member
Thanks Meter 13
Posts: 292
Join Date: May 2010
So the soft keys are quick keys? I thought the Home, Menu, etc are soft keys.

I really felt like remapping the left-most quick key to alt, because that's where I'm used to having it.

I think each person may feel differently about the quick keys. Is it possible you could make a customizable version of your keymap? That would be superb. In the meantime I'll check this out, because I don't use those quick keys. Thanks.
 
teferi
Old
#5  
Junior Member - OP
Thanks Meter 6
Posts: 28
Join Date: Oct 2010
Yes, by "soft keys" I meant the shortcut keys. I could conceivably write a tool to generate customized keychar maps and keylayout maps, and maybe I will this weekend considering the long train rides I have ahead of me, but frankly it would be a lot of work and this particular itch is scratched for me, so I wouldn't get my hopes up were I you

If you're interested in editing these yourself, you'll need the following:

1) the tool 'evtest' to get keyboard scancodes
2) the Input Devices section of the Android porting guide at http://source.android.com/porting/index.html (though n.b. that a distressing amount of it is inaccurate)
3) base keylayout and keycharmap files (pull 'em off your device)
4) a keycode to keycode label translation table (there's one in the AOSP tree at frameworks/base/include/ui/KeycodeLabels.h; n.b. that it is INCOMPLETE and doesn't cover all the keycodes the G2's keylayout map generates!

Keyboard input on Android works like this:

scancodes from Linux input core (on the G2, the keyboard is /dev/input/event5) -> scancode to keycode translation (via the .kl keylayout map) -> keycode to character translation modified by any active modifiers (alt/shift/alt+shift)

You'll find the KeyLayoutMap and KeyCharacterMap classes in frameworks/base/libs/ui/ very helpful. I have a tool knocked up out of KCM to generate dumps of the compiled .kcm.bin files which I'm happy to share.

Happy hacking!
 
misteropinion
Old
#6  
Member
Thanks Meter 5
Posts: 85
Join Date: Jun 2009
Quote:
Originally Posted by teferi View Post
Yes, by "soft keys" I meant the shortcut keys. I could conceivably write a tool to generate customized keychar maps and keylayout maps, and maybe I will this weekend considering the long train rides I have ahead of me, but frankly it would be a lot of work and this particular itch is scratched for me, so I wouldn't get my hopes up were I you
This also scratched my itch. I mean, how can you do anything without | ?

Thanks bunches, man!
Mister Opinion
T-Mobile Samsung Galaxy S Relay 4G [Started with a G1, then a G2]
CM 10.1 beta
 
EMERYfan1988
Old
#7  
Member
Thanks Meter 1
Posts: 47
Join Date: May 2008
what we need is when you long press the number key on the physical keyboard it gives you the option for the number. Kinda like HTC_IME keyboard. I keep getting confused when i switch between the two.
 
tornado9015
Old
#8  
Junior Member
Thanks Meter 1
Posts: 24
Join Date: Oct 2010
Quote:
Originally Posted by EMERYfan1988 View Post
what we need is when you long press the number key on the physical keyboard it gives you the option for the number. Kinda like HTC_IME keyboard. I keep getting confused when i switch between the two.
That would be a lot more complicated than a simple remapping. But I agree, if you use both the touch and physical keyboard, it is easy to get annoyed at the need to press alt key for numbers. They really should have had a number row, I used to love my sidekick's keyboard so much. Crappy phone though.
 
oldsk00lz
Old
#9  
Senior Member
Thanks Meter 14
Posts: 232
Join Date: Nov 2008
Quote:
Originally Posted by teferi View Post
After some quality time with the AOSP source and a hex editor today, I've come up with modified keymap files for the G2 that make the keyboard a bit more useful. Here it is.
...
Hope you find this useful!
Nice! I saw you on #g2root digging for this info, so I'm glad you pulled it together.

Will have to check out since the long presses don't work in a terminal, and slow the process down anyway. We really needed |, <, and >. Also dedicated tab versus alt-z is nice.

Hahaha, just hit my quick keys to see what I had programmed in (telnet, Notes Everywhere, and Shazam) since it had been so long. I seldom open the keyboard to actually use these.

-oldsk00lz
Nexus 5 & 7 (2013) - CM 11, AOSP, CM 10.2
.......... ....... ...... ....
 
aeidian
Old
#10  
Senior Member
Thanks Meter 24
Posts: 139
Join Date: Oct 2010
What's the likelyhood of getting some kind of graphical remake of the virtual qwerty? I really just want the spacebar to be a tad bit bigger height wise. I keep hitting the damn b key when I want to space because of the wrap around case. Is this even possible to do?

Tags
keylayout, patch
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes