Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[MOD][UPDATED] Modified keymap files for G2

OP teferi

12th November 2010, 01:32 AM   |  #1  
OP Junior Member
Thanks Meter: 6
 
28 posts
Join Date:Joined: Oct 2010
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, 1226 views)
Last edited by teferi; 18th November 2010 at 06:18 PM. Reason: new version
The Following 6 Users Say Thank You to teferi For This Useful Post: [ View ]
12th November 2010, 01:49 AM   |  #2  
Member
Flag philly
Thanks Meter: 7
 
85 posts
Join Date:Joined: Nov 2008
More
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?
12th November 2010, 01:55 AM   |  #3  
OP Junior Member
Thanks Meter: 6
 
28 posts
Join Date:Joined: 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!
12th November 2010, 05:16 AM   |  #4  
funkeee's Avatar
Senior Member
Thanks Meter: 13
 
292 posts
Join Date:Joined: 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.
12th November 2010, 06:41 AM   |  #5  
OP Junior Member
Thanks Meter: 6
 
28 posts
Join Date:Joined: 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!
12th November 2010, 07:14 AM   |  #6  
Member
Thanks Meter: 5
 
85 posts
Join Date:Joined: Jun 2009
Quote:
Originally Posted by teferi

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!
12th November 2010, 08:04 AM   |  #7  
Member
Thanks Meter: 2
 
47 posts
Join Date:Joined: 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.
12th November 2010, 09:09 AM   |  #8  
Junior Member
Thanks Meter: 1
 
24 posts
Join Date:Joined: Oct 2010
Quote:
Originally Posted by EMERYfan1988

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.
12th November 2010, 09:24 AM   |  #9  
Senior Member
Thanks Meter: 14
 
232 posts
Join Date:Joined: Nov 2008
Quote:
Originally Posted by teferi

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
12th November 2010, 10:34 AM   |  #10  
Senior Member
Thanks Meter: 24
 
139 posts
Join Date:Joined: 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?

Post Reply Subscribe to Thread

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

Advanced Search
Display Modes