05-21-2013 12:53 AM
43 12
tools
  1. sblood86's Avatar
    I see a lot of posts of people asking how to change which buttons wake their phone or asking if they can remap voice search to contacts or in the case of reborn rom remap contacts back to voice search. (Looking for the Optimus V thread? Click here.)

    I'm sure someone has posted a walk through on this somewhere but I've yet to find it; so I decided to find the answers myself.

    Just to get one bit out of the way:
    Myself, the devs and other users are in no way responsible for your device or data. We will not be held accountable for any damage to your device or lost data resulting from following this thread or any other.
    Thread Rules:
    -Your phone must be rooted before attempting to follow this guide.
    If you have the ZVD baseband see gingersnap for one click root - Thanks Drew!
    Otherwise if you have ZVH baseband check out How to root LS670ZVH for a great walkthrough - Thanks sfhub!
    -Before doing anything remember to make a nandroid backup.
    -This guide assumes you have a basic understanding of ADB, please do not post questions regarding setup of ADB in this thread
    -Please do not use this thread for 'first posts' if you need to do a first post before downloading something please do so in the 'Introductions' thread.

    I am still researching this matter and learning more daily, if anyone has any information to add to the following please post it and I will gladly update.

    The keypad files are a text file of sorts and therefore relatively easy to edit, the easiest way is to pull the file using adb.


    From your platform-tools directory (or wherever your adb is located) go ahead and mount your phone (note that if you have not been using adb on this boot of your computer it's going to start the server in a mount mode anyway so the following isn't always required)
    Code:
    adb remount
    (By default the optimus phones do not have a remount command included, this is added sometimes with the rooting method or by flashing a rom. If the above remount command does not work, try the following)
    Code:
    adb kill-server
    adb start server
    The only real difference between the keypads in ZVD and ZVH OS versions is the file name. ZVH they added the c in thunderc instead of just having it marked as thunder_keypad other than that the only difference is a set of comments around the voice button, being comments I've decided not to add them to my example.

    Pull the keypad file:
    For ZVD baseband.
    Code:
    adb pull /system/usr/keylayout/thunder_keypad.kl
    For ZVH baseband.
    Code:
    adb pull /system/usr/keylayout/thunderc_keypad.kl
    This is a simple text document and can be edited in most text editors, I would not recommend notepad.
    If you are in need of a text editor I would recommend searching for gedit or notepad++ both should be free to download and can be found with your search engine of choice.

    Stock Keypad:
    Code:
    #
    key 2     1
    key 3     2
    key 4     3
    key 5     4
    key 6     5
    key 7     6
    key 8     7
    key 9     8
    key 10    9
    key 11    0
    key 158   BACK              WAKE_DROPPED
    key 230   HOME              WAKE
    key 60    SOFT_RIGHT        WAKE
    key 62    ENDCALL           WAKE_DROPPED
    key 229   MENU         WAKE_DROPPED
    key 59    MENU         WAKE_DROPPED
    key 139   MENU              WAKE_DROPPED
    key 228   POUND
    key 227   STAR
    key 231   CALL              WAKE_DROPPED
    key 61    CALL              WAKE_DROPPED
    key 232   DPAD_CENTER       WAKE_DROPPED
    key 108   DPAD_DOWN         WAKE_DROPPED
    key 103   DPAD_UP           WAKE_DROPPED
    #key 102   ENDCALL           WAKE_DROPPED
    key 102   HOME              WAKE
    key 105   DPAD_LEFT         WAKE_DROPPED
    key 106   DPAD_RIGHT        WAKE_DROPPED
    key 115   VOLUME_UP         WAKE
    key 114   VOLUME_DOWN       WAKE
    key 213   DEL               WAKE_DROPPED
    key 355   DEL               WAKE_DROPPED
    key 212   CAMERA
    key 247   FOCUS
    key 217   SEARCH            WAKE_DROPPED
    key 216   VOICE
    
    key 226   HEADSETHOOK       WAKE
    key 116   POWER             WAKE
    key 107   ENDCALL           WAKE_DROPPED
    
    key 16    Q
    key 17    W
    key 18    E
    key 19    R
    key 20    T
    key 21    Y
    key 22    U
    key 23    I
    key 24    O
    key 25    P
    
    key 30    A
    key 31    S
    key 32    D
    key 33    F
    key 34    G
    key 35    H
    key 36    J
    key 37    K
    key 38    L
    key 14    DEL
            
    key 44    Z
    key 45    X
    key 46    C
    key 47    V
    key 48    B
    key 49    N
    key 50    M
    key 51    COMMA
    key 52    PERIOD
    key 28    ENTER
            
    key 56    ALT_LEFT
    key 42    SHIFT_LEFT
    key 215   AT
    key 57    SPACE
    key 53    SLASH
    key 127   SYM
    key 100   ALT_RIGHT
    
    key 399   GRAVE
    The primary keys in question for the Optimus S are:
    Code:
    key 139 MENU
    key 102 HOME
    key 115 VOLUME_UP
    key 114 VOLUME_DOWN
    key 212 CAMERA
    key 247 FOCUS
    key 217 SEARCH
    key 216 VOICE
    key 116 POWER
    For example if you wanted to change your camera and voice search buttons to control music like I have done you could change the following keys:
    Code:
    key 212   MEDIA_NEXT
    key 216   MEDIA_PLAY_PAUSE
    The above would change your camera button to auto change to the next track when listening to music with the stock music player (or music mod if you are on reborn) and your voice search button to play/pause.

    I use the above layout for my phone, I have found on occasion I have to reload my playlist after pausing my music but other than that I have music controls without waking my screen.

    For a list of more possible events to map your hardware keys check out 'KeyEvent | Android Developers'

    Make sure the filter at the top is set to API level 10 (for froyo) or API level 11 (for gingerbread) and remove the KEYCODE_ from the front of the key change.

    I have not tested all of these functions but I can confirm NOTIFICATION works as I have successfully mapped it to the search key using the following change:
    Code:
    key 217   NOTIFICATION
    Interestingly enough it turns out that the key even NOTIFICATION doesn't seem to work when mapped in ZVH, at least not to search, I havn't tried it with any other key.

    Key events have three possible status' for NONE, WAKE or WAKE_DROPPED.

    In the case of NONE the key will do nothing while the phone is asleep.
    WAKE means that when the key is pressed the phone will wake and the command will be sent to the designated app.
    WAKE_DROPPED will wake the phone but the command will not be passed to the designated app.
    --Thanks to Overthinkingme for finding this information in button remapper and posting in in post #7.

    Once you have made any changes to your .kl file you will need to push it back to the phone (if your computer has restarted or you experience issues pushing the file try remounting the system again using the commands outlined earlier), assuming the file is still in your adb directory you can:
    For ZVD baseband.
    Code:
    adb push thunder_keypad.kl /system/usr/keylayout/
    For ZVH baseband.
    Code:
    adb push thunderc_keypad.kl /system/usr/keylayout/
    Reboot your phone and enjoy.

    This method will also work with a text editor locally on your phone: remapped my search key earlier in a failed attempt to figure something out.
    On the plus side I can confirm local text editors do work
    06-01-2011 12:35 AM
  2. sblood86's Avatar
    Flashable zips with keypad changes:

    Stock Keylayout

    Shell Rom Keylayout - Voice search remapped to call.

    Standard Reborn Keylayout - No wake on front buttons, voice search remapped to call

    Music Controls - No wake on front buttons, voice search has been mapped to play/pause (long press with screen awake to launch music app), camera is changed to media skip.

    Thanks to Nick for both the Shell and Reborn Keymaps.

    Updated all zips to use Edify scripts, should be CM7/Gingerbread friendly now, let me know if there are any issues.

    The above listed zips have not been updated to accommodate the new ZVH changes. I will update them when able.
    06-01-2011 12:35 AM
  3. jstntp's Avatar
    Great job with this! Should be very helpful.
    sblood86 likes this.
    06-01-2011 12:14 PM
  4. jondevere's Avatar
    Thanks sounds pretty straight forward
    06-01-2011 03:21 PM
  5. sonicbluemustang's Avatar
    Forgive my old age but whats the difference in Wake and Wake_Dropped?
    06-02-2011 09:46 PM
  6. sblood86's Avatar
    Forgive my old age but whats the difference in Wake and Wake_Dropped?
    That's a good question, still trying to work it out entirely but as far as I can tell wake is for a full wake and wake dropped is for the partial wake, like if the screen has just gone out but the phone has not gone to sleep yet.

    I haven't tested that in full but that is my theory at least, if someone could confirm that I would update the OP.

    Sorry for my lack of certainty still learning myself

    Edit: Main problem with that theory is the volume keys use wake but to not wake the screen.

    Edit 2: Mind if I ask what you are trying to do specifically I may be able to help further.
    06-02-2011 10:23 PM
  7. overthinkingme's Avatar
    Button remapper explains it

    Any way we can map the voice button to something useful like an app? I know I can map it to search but binding something to one search button will bind it for both..

    Sent from my VM670 using Tapatalk
    Thraeryn and sblood86 like this.
    06-03-2011 01:26 AM
  8. sblood86's Avatar
    Button remapper explains it

    Any way we can map the voice button to something useful like an app? I know I can map it to search but binding something to one search button will bind it for both..

    Sent from my VM670 using Tapatalk
    I'll give you the info that I have but again I havn't been able to fully figure this part out either. As near as I can tell the standard key events don't support mapping to things that are not predefined. If my research is correct this can be changed by somehow editing the .kcm.bin files found under keychars, unfortunatey this appears to be an undocumented format and every method I've tried to edit these has not worked. I am still working on this matter as well, I will of course update if/when I figure this out.

    Edit: Updated the OP with that information for easy reference, thanks again.
    06-03-2011 01:33 AM
  9. overthinkingme's Avatar
    I'm going to read up on how t-mobile implemented their "genius" button but I believe it might just be like our voice button, unfortunately.

    Looking forward to developments

    Sent from my VM670 using Tapatalk
    06-04-2011 03:34 AM
  10. sblood86's Avatar
    Updated all zips to use Edify scripts, should be CM7/Gingerbread friendly now, let me know if there are any issues.
    06-26-2011 12:24 AM
  11. Masterjakeway's Avatar
    So, along the media play lines...
    Can I map the menu as previous, back as play/pause, and search as next. Only when sleeping? I have successfully changed home to wake already.

    thanks for any input...
    06-28-2011 10:50 PM
  12. sblood86's Avatar
    So, along the media play lines...
    Can I map the menu as previous, back as play/pause, and search as next. Only when sleeping? I have successfully changed home to wake already.

    thanks for any input...
    Unfortunately any changing of the keys from screen wake to screen off would require a major work around not apply-able simply with an edit in the .kl files. Would require an app of some sort to change the mapping on the fly when the screen is woken and vice versa. Anything done in the kl files requires a reboot. In short, it's all or nothing when you change it here.

    You could look into button remapper, and I beleive there are a few others that have been mentioned on this thread, if not they are on the V version of the same thread, linked in the OP. One of them may do what you are wanting otherwise it's beyond my current abilities and very much beyond a simple edit of a single file.
    06-29-2011 12:23 AM
  13. Masterjakeway's Avatar
    Ohhh.. Thanks for the info!
    I'll look into it further...
    06-29-2011 02:12 AM
  14. basketthis's Avatar
    My power button running the cm7 port is causing me to hang up on people when in a call. Lol. Anyway to make it behave like in reborn rom? It will cause the screen to blackout instead of hang up the call?
    07-19-2011 02:49 AM
  15. sblood86's Avatar
    My power button running the cm7 port is causing me to hang up on people when in a call. Lol. Anyway to make it behave like in reborn rom? It will cause the screen to blackout instead of hang up the call?
    Hmm I think there's a setting in CM7 to apply that specific option so you may want to make sure you havn't enabled that in the rom. However having taken a look at the .kl file from the Ath3nos rom which is actually Zefie's old .kl file I notice one thing that's a little odd

    key 107 POWER WAKE_DROPPED

    not only do I find it odd that it's in there twice but if you check the stock keylayout in the OP you will see 107 is mapped to end call. Could be as simple as remapping that.

    However if you are feeling lazy or just want an easy button I have tested the zips in post number 2; they do work with the Ath3nos rom; I am still using my music controls .kl file that I did (which is a slightly modified reborn keymap) otherwise there is also the .kl for stock, reborn and shell roms, you should be able to simply pick which one you want and flash it from recovery.

    I know you already know this but I'm going to say it anyway: please make a nandroid before flashing any of the zips in post 2 while I have confirmed they work if you need to go back that's the easiest way

    PS. Sorry for the slow reply.
    basketthis likes this.
    07-19-2011 01:37 PM
  16. kingdavidbaker's Avatar
    Also for anyone who just wants to edit their key layout from their phone you can use an app like Root Explorer. You will have to browse to /system/usr/keylayout/thunder_keypad.kl then click the "mount as R/W" button at the top before long pressing the file and choosing "open in text editor". Then simply change the buttons you want to map and then save and exit. A backup of the original file will automatically be created.
    sblood86 likes this.
    07-21-2011 10:35 AM
  17. sblood86's Avatar
    Also for anyone who just wants to edit their key layout from their phone you can use an app like Root Explorer. You will have to browse to /system/usr/keylayout/thunder_keypad.kl then click the "mount as R/W" button at the top before long pressing the file and choosing "open in text editor". Then simply change the buttons you want to map and then save and exit. A backup of the original file will automatically be created.
    Yep that works, used the method a few times myself. Just remember to reboot for the change to apply
    07-21-2011 01:52 PM
  18. theBIG's Avatar
    Thank you for this very useful guide! I posted this question in the Reborn ROM discussion, but I am not certain it's related to the ROM, so I'm asking here as well.

    I wanted to change the WAKE function for the hard keys on my dad's Optimus S (rooted, Reborn 2.2.4) I get how the process works after reading this thread, and am doing everything properly via adb (push, reboot, etc.) However, I can't get the Voice Search and Camera buttons to do anything--no matter what I change them to, the buttons have no function--the only thing I could do was disable Reborn's call log function mapped to the voice search key, but I can't change it to anything else. So I decided to push the stock thunder_keypad.kl to the phone--I can mod the WAKE function for the home/menu/back/search keys, but again, can't get the voice or camera buttons to function. I'd like to get them back to their native functions, and ideally, have them set to WAKE for instant access.

    Can anyone tell if I'm missing something, or is it possibly a limitation of Reborn? (sorry, I can follow instructions and figure things out, but I'm not a dev/programmer.) Thanks!
    08-28-2011 12:24 PM
  19. epeereboom's Avatar
    If you did a nandroid backup when you first flashed reborn, I would restore that to reset your buttons. Then some where in the reborn rom thread there is a wake button zip you can flash from recovery that should do what you are looking for, if I understand correctly. The zip is the third page in. Hope that is what you were looking for.
    08-28-2011 01:06 PM
  20. theBIG's Avatar
    If you did a nandroid backup when you first flashed reborn, I would restore that to reset your buttons. Then some where in the reborn rom thread there is a wake button zip you can flash from recovery that should do what you are looking for, if I understand correctly. The zip is the third page in. Hope that is what you were looking for.
    Thanks for your reply, epeereboom. I did find the ZIP packages to flash, but unless I'm mistaken, all those do is update the thunder_keypad.kl by flashing, whereas I did it manually via adb. Net result should be exactly the same, unless I'm wrong.

    As a matter of fact, when I mentioned pushing the stock thunder_keypad.kl to the phone, I got that file from the stock rom ZIP on pg3--just extracted and pushed instead of flashing.

    edit: and to clarify, hard buttons (except for the camera and voice search) are working, I just can't seem to get those two to mod (uh, or come back to life...)
    08-28-2011 02:17 PM
  21. sblood86's Avatar
    Thanks for your reply, epeereboom. I did find the ZIP packages to flash, but unless I'm mistaken, all those do is update the thunder_keypad.kl by flashing, whereas I did it manually via adb. Net result should be exactly the same, unless I'm wrong.

    As a matter of fact, when I mentioned pushing the stock thunder_keypad.kl to the phone, I got that file from the stock rom ZIP on pg3--just extracted and pushed instead of flashing.

    edit: and to clarify, hard buttons (except for the camera and voice search) are working, I just can't seem to get those two to mod (uh, or come back to life...)
    Interesting...

    Camera should work with the stock keymap assuming your camera apk is functioning properly.
    The stock .kl file remaps the voice key but without the sprint voice search apk it doesn't function, nick7 has it somewhere in his public mediafire folders otherwise it's not included in reborn rom (this is why it doesn't work if mapped to voice).
    Does the voice button work by default in reborn rom? As in it should pull up your phone apk.
    theBIG likes this.
    08-28-2011 02:37 PM
  22. theBIG's Avatar
    Interesting...

    Camera should work with the stock keymap assuming your camera apk is functioning properly.
    The stock .kl file remaps the voice key but without the sprint voice search apk it doesn't function, nick7 has it somewhere in his public mediafire folders otherwise it's not included in reborn rom (this is why it doesn't work if mapped to voice).
    Does the voice button work by default in reborn rom? As in it should pull up your phone apk.

    Hi sblood86, thanks for your reply. Yes, the voice button worked as Reborn ROM intended before remapping it.

    Thanks for cluing me in about the requiring the Sprint APK, I'll search that one out. Must have missed that when I searched... I assumed having the current Google Voice Search apk was sufficient.

    The Reborn camera apk is working fine, just can't seem to get the button to motivate it to do anything.

    EDIT: pardon my ignorance... I found Nick7's mediafire page, and checked his folders--do I want voice_dialer.zip? (I also see SprintApp.zip, which includes the same apk as the voice_dialer.zip in addition to all the Sprint bloat.) I don't see anything specifically indicating voice search, and a quick search of Nick7's forum posts didn't turn up what I was looking for.

    EDIT2: Apologies, apparently I'm a moron--the camera button IS working, if held down for a couple seconds. This is my dad's phone, so I'm not accustomed... however, mapping it to WAKE does not seem to be effective. I'd like to set it for instant access to the camera--can this be done?
    08-28-2011 05:07 PM
  23. sblood86's Avatar
    Hi sblood86, thanks for your reply. Yes, the voice button worked as Reborn ROM intended before remapping it.

    Thanks for cluing me in about the requiring the Sprint APK, I'll search that one out. Must have missed that when I searched... I assumed having the current Google Voice Search apk was sufficient.

    The Reborn camera apk is working fine, just can't seem to get the button to motivate it to do anything.

    EDIT: pardon my ignorance... I found Nick7's mediafire page, and checked his folders--do I want voice_dialer.zip? (I also see SprintApp.zip, which includes the same apk as the voice_dialer.zip in addition to all the Sprint bloat.) I don't see anything specifically indicating voice search, and a quick search of Nick7's forum posts didn't turn up what I was looking for.

    EDIT2: Apologies, apparently I'm a moron--the camera button IS working, if held down for a couple seconds. This is my dad's phone, so I'm not accustomed... however, mapping it to WAKE does not seem to be effective. I'd like to set it for instant access to the camera--can this be done?
    Voice app is here.

    rather than flashing the zip though I would probably recommend just taking the apk itself out and either install it from sd (which will put it in data) or push it to /system/app using adb and reboot.

    Either case should install the app for you, if you flash the zip it's going to change all the key settings to stock and you may not want to redo everything.

    As for waking and going directly to the camera I doubt it would work very well not particularly sure.
    theBIG likes this.
    08-28-2011 10:14 PM
  24. theBIG's Avatar
    Voice app is here.

    rather than flashing the zip though I would probably recommend just taking the apk itself out and either install it from sd (which will put it in data) or push it to /system/app using adb and reboot.

    Either case should install the app for you, if you flash the zip it's going to change all the key settings to stock and you may not want to redo everything.

    As for waking and going directly to the camera I doubt it would work very well not particularly sure.
    Thanks, sblood86... I'll push it via adb--quick and clean.

    At the risk of going too far off-topic, that leads to another question--and then I'll leave you be, I promise! Is there a good resource you'd recommend for learning about things like installing apps to /system/app vs /data/app, dos & don'ts, drawbacks, etc? For example, it looks like updates for /system/apps go to the /data/apps folder, can I save memory by pushing them over, is there potential for breaking something by doing that, etc. I guess I need to learn the basics of Android's file system--I see all these tutorials and guides for rooting and ROMs and whatnot, but not much about the underpinnings. If you might point me in the right direction to educate myself a bit, I'd appreciate it.

    Thanks again for taking the time.
    08-28-2011 10:33 PM
  25. sblood86's Avatar
    Thanks, sblood86... I'll push it via adb--quick and clean.

    At the risk of going too far off-topic, that leads to another question--and then I'll leave you be, I promise! Is there a good resource you'd recommend for learning about things like installing apps to /system/app vs /data/app, dos & don'ts, drawbacks, etc? For example, it looks like updates for /system/apps go to the /data/apps folder, can I save memory by pushing them over, is there potential for breaking something by doing that, etc. I guess I need to learn the basics of Android's file system--I see all these tutorials and guides for rooting and ROMs and whatnot, but not much about the underpinnings. If you might point me in the right direction to educate myself a bit, I'd appreciate it.

    Thanks again for taking the time.
    No one source comes to mind, the AC community is awesome though so you should be able to find an answer to most of your questions.

    A good rule of thumb with data vs system is to remember that anything you install in system cannot be updated via the market so if you install an app to system and it's updated the update will be installed to data. You can always manually update them later by pulling the apk from data and pushing it to system and rebooting. Otherwise yes you can get away with moving apps from data to system to free up some space on the data partition you just have to be mindful of which apps you are moving that way. I personally remove all other launchers and push golauncher to system so I don't have to worry about defaults (I have it in system cause I use data2ext and don't want my launcher running off the sd card), this does mean I have to manually update the launcher.
    08-30-2011 11:24 PM
43 12
LINK TO POST COPIED TO CLIPBOARD