[GUIDE] How to Remap Hardkey Actions || Custom App Launching - Hero CDMA Android Development

This is really a low-level type of hack, as it just requires editing a few files.
------------------------------------------------------------------------------------------
Sick of the Hero not having a designated "camera" button?
Well then, remap the damn thing.
How to:
MAKE A BACKUP OF THE FILE BEFORE PROCEEDING
Firstly, we'll need to pull the file that controls the heroc keypad which is entitled "heroc-keypad.kl" in "system/usr/keylayout".
To pull the file:
Code:
adb remount
adb pull system/usr/keylayout/heroc-keypad.kl heroc-keypad.kl
Now the file will appear in your Android SDK tools folder so you can edit it.
I recommend using Notepad++ but any kind of text editing tool will work.
Now open the file and it should look a little something like this(minus the "unuse" keys):
Code:
key 102 HOME
key 139 MENU WAKE_DROPPED
key 158 BACK
key 127 SEARCH
key 231 CALL
key 107 ENDCALL WAKE_DROPPED
key 191 DPAD_CENTER
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
As you can see, there are different attributes assigned to each key.
Specific application/action launchers:
Code:
HOME #Launches "Home"
MENU #Launches "Menu"
BACK #Takes you back to the last activity
SEARCH #Launches "Universal Search"
CALL #Launches the "Phone" activity and corresponding .apk or initiates a call
ENDCALL #Ends a call
CAMERA #Launches "Camera" activity and corresponding .apk
FOCUS #Initiates Auto-Focus while using the Camera
VOLUME_UP #Self explanatory
VOLUME_DOWN #^
And attributes saying if it should wake the phone at button push to complete the action, or if it should just complete the action without waking the screen.
Code:
WAKE #Completes the action without waking the screen
WAKE_DROPPED #Wakes the phone to complete the action
NOTE: "CAMERA" can't utilize the "WAKE_DROPPED" attribute since it's an attempt to launch an activity without initializing anything else.
Anyways you can assign any of these attributes to any of the keys.
Personally, I remap the Phone button to launch the Camera, and the Search button to activate Auto-Focus:
Code:
key 231 CAMERA
key 127 FOCUS
Then when I'm using the Camera, I just hold down the "SEARCH" button to focus and push the "TALK" button to take a snapshot.
After you're done with your edits, you'll need to save the file properly(NO .txt files!), and then you'll have to push it back to the phone.
Code:
adb remount
adb push heroc-keypad.kl /system/usr/keylayout
Reboot your phone, and then long press the selected button to see if your edits worked!
Enjoy!
UPDATE!!!!
Code:
--------------------------------------------------------------------
key 200 MEDIA_PLAY_PAUSE #Pauses Music
key 201 MEDIA_PLAY_PAUSE #^
key 166 MEDIA_STOP #Stops the media
key 163 MEDIA_NEXT #Plays next media
key 165 MEDIA_PREVIOUS #Plays previous media
key 168 MEDIA_REWIND #Rewinds the media
key 208 MEDIA_FAST_FORWARD #Fast Forwards the media
The second half is from the AVRCP.kl which controls media actions on our device. But as you can see the keys aren't correctly mapped as we don't have that many(or those key numbers) at our disposal.
What you can actually do is take these attributes and map them in heroc-keypad.kl
Code:
key 102 HOME
key 139 MENU WAKE_DROPPED
key 158 BACK
key 127 MEDIA_PLAY_PAUSE WAKE
key 231 CALL
key 107 ENDCALL WAKE_DROPPED
key 191 DPAD_CENTER
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
This maps the attribute "MEDIA_PLAY_PAUSE" at the "SEARCH" key. By pushing it, you can pause media with the first push and play it with a successive push. The added attribute "WAKE" allows it to complete the action without waking the phone.
__________________________________________________________________________________________________
I want to thank Geniusdog254 for the heads up regarding not having to edit AVRCP.kl
CHECK OUT HIS FREE APP: Search2Play(Hero/Evo support!)
and
CHECK OUT HIS REMAPPING MOD FOR THE G1
Big thanks!
NOTE: You can also use Root Explorer or any other Root File Manager that has Text Editing
Custom app launching
Ok, so with some inspiration from BuglessPete's How to make script run by using hardware keys. I've devised an 'idea' as to how to custom launch an activity with keypad push.
Currently, you can launch any activity from shell by just using am.
Here's an example of launching the browser using am in the shell:
Code:
am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity
Which results in:
Code:
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.browser/.BrowserActivity }
And the program launches!
But if you put this into a script, even a basic linux shell script, you can call it quickly just by running the script! So in theory if you map this script to a keycode, you can call the script by a button push.
How?
Well first, before you compile the ramdisk, you need to create a service that contains the script necessary for the intent activity you are trying to accomplish.
Second, you have to add the proper keycodes in an init script of your choice:
Code:
#example
service <activity> /path/to/yourservice
oneshot
disabled
keycodes 107 127
Which maps the activity to the search button after launching the service with the endcall button
This is currently just a theory as I haven't tested it out myself(busy with other things).
But if you would like to attempt it, I'd love feedback.
Quick Service Creation Tutorial: http://developerlife.com/tutorials/?p=356

Little error.. heroc_keypad.kl is in /system/usr/keylayout/heroc_keypad.kl.
EDIT: And it's heroc-keypad and not heroc_keypad.

HeroMeng said:
Little error.. heroc_keypad.kl is in /system/usr/keylayout/heroc_keypad.kl.
Click to expand...
Click to collapse
Nice catch, lol.
Always forget something simple.
EDIT: I really need to start posting stuff while using my laptop.

nice
thanks man this is awesome.
im just "learning" linux. how would i set up the search button for an intent(sp) like opening the browser.apk

feefeeboomboom said:
thanks man this is awesome.
im just "learning" linux. how would i set up the search button for an intent(sp) like opening the browser.apk
Click to expand...
Click to collapse
Well "SEARCH" essentially launches the browser by linking it automatically to google search.
But, in regards to assigning it to launch a different(unlisted) activity, I'm not sure. That's something I'm actually looking into myself, and I think I'm making a little bit of head way .

Haha great work [HOPE]maybe the hero development won't die[/HOPE]
I'm putting this in my sig if you don't mind?

thatguythatdid said:
Haha great work [HOPE]maybe the hero development won't die[/HOPE]
Click to expand...
Click to collapse
As long as there are people there willing to learn, development for the Hero will never die.
[RANT]
I'll make a post in the General Section with all the bookmarked dev'ing related resources that I've found over the year. Then people can just jump in and start reading/tinkering.
What I don't like about the HeroCDMA forum is that most of the community here doesn't share much of HOW they did/do things. Hopefully that will change.
=D
[/RANT] (Please don't respond to this part, haha)

almost forgot what program are you using to open the kl file? Mine always comes out in a horizontal line instead of a vertical like yours?
Edit: Nevermind wordpad does it great

notepad++ is the sh!-|-

feefeeboomboom said:
notepad++ is the sh!-|-
Click to expand...
Click to collapse
I'm a dumbass. I didn't read the entire post before I asked my question and thought that nevermind. Yes notepad is the s

Good work, thanks for putting together a very easy to read how-to.

Thanks for this, the trackball is so annoying for pictures. I made the changes just as it states to but the zoom won't work on the search button, I hold it down and it does nothing, any idea why that may be? And the search button no longer responds on the homescreen, which makes sense but why not in the camera app?

chrish03 said:
Thanks for this, the trackball is so annoying for pictures. I made the changes just as it states to but the zoom won't work on the search button, I hold it down and it does nothing, any idea why that may be? And the search button no longer responds on the homescreen, which makes sense but why not in the camera app?
Click to expand...
Click to collapse
Zoom? Do you mean auto-focus?

I want to do this but I cant get my phone to remount. I have never had a problem before.
cd c:\android-sdk-windows\tools
adb remount
doesn't remount says "no devices found"

CarbonKang said:
I want to do this but I cant get my phone to remount. I have never had a problem before.
cd c:\android-sdk-windows\tools
adb remount
doesn't remount says "no devices found"
Click to expand...
Click to collapse
Heh, is your phone plugged in? USB cable damaged? USB port damaged? Hole plugged? Bears?
If it's none of those, do this:
Code:
adb kill-server
adb start-server
then
Code:
adb remount
If that doesn't work, start from the top again.

Decad3nce said:
Zoom? Do you mean auto-focus?
Click to expand...
Click to collapse
LOL, reading comprehension FTW! I got FOCUS and ZOOM confused. Don't play with your phone late at night!

Decad3nce said:
Heh, is your phone plugged in? USB cable damaged? USB port damaged? Hole plugged? Bears?
If it's none of those, do this:
Code:
adb kill-server
adb start-server
then
Code:
adb remount
If that doesn't work, start from the top again.
Click to expand...
Click to collapse
none of that worked. And there is nothing wrong with the ports at all. I think its Darchdroid.. It has something defective every time I use it lol.

CarbonKang said:
none of that worked. And there is nothing wrong with the ports at all. I think its Darchdroid.. It has something defective every time I use it lol.
Click to expand...
Click to collapse
Do you have USB debugging enabled?
(I haven't had any problems with darchs build)

Decad3nce said:
Do you have USB debugging enabled?
(I haven't had any problems with darchs build)
Click to expand...
Click to collapse
ya, trust me I know what I'm doing.
It just doesn't work
I would love to show you a logcat... but i cant adb remount LOL

Can someone make a flashable zip so i can have a designated camera button as search? I want to be able to click it to take a snap shot of my phone with dro cap.
Thanks

Related

Re-mapping keys / Creating or re-assigning keyevent

OK, I've looked around but can't find an answer. Or at least an answer that I can understand. Basically what I'm trying to do is add the ability to quit/exit an app. I've read all about the differing opinions on quitting an app versus pressing back. However, just for my own self-teaching purposes, I want to learn how to do this. I'd like to be able to long-press or double tap a key to either immediately exit an app, or bring up an alternate pop-up menu that allows you to choose an action.
I am thinking specifically in relation to the Browser. The quit option was more necessary pre-CM6 because often times, it would take forever to load the home screen after pressing "home" in order to stop using the browser. A simple exit/quit option that some apps have, usually acts much quicker. Everyone knows that if you've been browsing through a bunch of webpages, hitting the back button repeatedly is a pain in the ass. The other option is to hit menu-->windows-->then close all the open windows-->then hitting the back button once the new window pops up because browser automatically opens a new page once all open windows have been closed.
Another annoyance is not being able to quickly get to your home page. Is there a way to remap/reassign/whatever, keys so that on long-press or double-tap of say, menu, or trackball, a menu pops up which has a "exit/quit" option and a "home page" option?
Another option is to add to the menu (when you hit menu), a "quit/exit" or "homepage" option.
Any help would be appreciated.
So much for a "supporting community". Way to help each other out.
What your trying to do should be located in the /system/usr folder. It has the key information you are trying to edit.
bubonik said:
So much for a "supporting community". Way to help each other out.
What your trying to do should be located in the /system/usr folder. It has the key information you are trying to edit.
Click to expand...
Click to collapse
Yeah, most people are probably trying to figure out a way to tell me I posted in the wrong section or that I need to use the search function. Thanks for your answer but I am familiar with the /system/usr files...I don't see anything in there relating to an action that quits/exits an app. Is there a specific action that is called when someone presses menu while using an app, and the menu brings up options including quit/exit?
Really? Nobody?
The keymap files are stored in /system/usr/keylayout, open them up and have a look at the things you can assign to keys.
Pull-edit-push the correct version for your handset hardware and reboot, changes will take effect. Obviously Magics are sapphire-keypad.kl and G1s are one of the trout files. Most G1s are trout-keypad-v3.kl though you can confirm your specific hardware version with getprop.
Have a search for "keymap" and "keylayout", you'll find there's already a bit of work been done of this, for example this auto key-changer.
I appreciate the help but I guess I'm not explaining myself properly. I have looked at the files in /system/usr/. I know how to remap a key so that, say...volume down = pause music, or change the menu key to have it end a call if I wanted...I know I'm not using the correct terminology all the time but when looking at the various .kl files, there are various "actions" that can be attributed to a particular key. For instance, keys 107 & 62 = Endcall, key 158 = Back, key 10 = the number 9.
In the column next to the numerical keycode in each of the .kl files, there is an "action" that results from pressing the particular key. The action I am looking for is a "quit" and/or "exit" action to apply to a particular key. Let's say I wanted to have key 231 in the sapphire keypad, kill the app I am using. Right now, pressing key 231 = CALL button. Is there a keyevent such as Kill_app or something to that affect that I could put in place of the CALL action so that key 231 = Kill app?

[Q] [ubuntu] How to map search key to alt?

I'm happily running Ubuntu on my TF-101 now. Thanks to lilstevie and everyone else who helped make that possible!
However I'd like to make the search key on the dock act as an alt key. I know how to remap modifier keys using xmadmap, but xev doesn't seem to report any X events when pressing the search key so I can't get its code . The home key next to it is reported as "keycode 180 (keysym 0x1008ff18, XF86HomePage)", but absolutely nothing for the search key.
When you press the search key a "search for files" window pops up, so the key press is being recognised somewhere in the system, but I guess whatever that is then suppresses the normal X KeyPress event.
Anyone have any ideas about how to fix this? I guess in the meantime I'll try using the home key instead.
Ah, just figured it out. First disable the system-wide usage of the search key:
Go to System -> Preferences -> Keyboard Shortcuts
Scroll down to the Desktop section and click on "Search"
Press backspace to disable any shortcut for that function
Then xev reports the keypress as "keycode 225 (keysym 0x1008ff1b, XF86Search)" so the following command will make it act as an Alt key:
xmodmap -e "add mod1 = XF86Search"​
Hope someone finds this as useful as I do - it's nice having the keys in the right place!

Disable wake on volume in all ICS Roms

I don't like how the screen turns on when I change the volume for music in my pocket, so here's a workaround I found:
- Use Root explorer (or similar) and browse to /system/usr/keylayout/
- Mount system as R/W
- Long press ffa-keypad.kl and open with text editor.
- Remove the words "WAKE_DROPPED" next to key
115 VOLUME_UP
114 VOLUME_DOWN
Only remove the "WAKE_DROPPED" words and save the file. Restart your phone and wake on volume button press should be disabled.
Thank you for this! Actually was just running into issues with this yesterday. When I run, I use my phone for music, and every once in awhile, it'll randomly decide to wake, and since it's in my pocket, it'll just start going crazy pressing buttons, pocket texting random people, and skipping tracks, haha.
Help please
ganja_guru said:
I don't like how the screen turns on when I change the volume for music in my pocket, so here's a workaround I found:
- Use Root explorer (or similar) and browse to /system/usr/keylayout/
- Mount system as R/W
- Long press ffa-keypad.kl and open with text editor.
- Remove the words "WAKE_DROPPED" next to key
115 VOLUME_UP
114 VOLUME_DOWN
Only remove the "WAKE_DROPPED" words and save the file. Restart your phone and wake on volume button press should be disabled.
Click to expand...
Click to collapse
Could you post the entire file because I made a mistake and disable ALL and now I can t remenber wich ones than you !
Thank you for this! Was getting really annoying before. This is perfect now. Super clear directions. Thanks again.
Old thread, but same questions I suppose. I would like to disable wake on volume up for my Droid4 running ICS 4.0.4 but I don't have ffa-keypad.kl in my folders. I found several files that contain 114 and WAKE, but I'm not sure which one needs editing. I found the key layout info:
http://source.android.com/tech/input/key-layout-files.html
That indicates that changing the wrong one will just be ignored. Any guidance on determining which the right file is? Like I said, there's ~20 files and at least 4 have 114 in them. ES File Explorer doesn't seem to let me search file contents that I can see.
bkenobi69 said:
Old thread, but same questions I suppose. I would like to disable wake on volume up for my Droid4 running ICS 4.0.4 but I don't have ffa-keypad.kl in my folders. I found several files that contain 114 and WAKE, but I'm not sure which one needs editing. I found the key layout info:
http://source.android.com/tech/input/key-layout-files.html
That indicates that changing the wrong one will just be ignored. Any guidance on determining which the right file is? Like I said, there's ~20 files and at least 4 have 114 in them. ES File Explorer doesn't seem to let me search file contents that I can see.
Click to expand...
Click to collapse
Change it in all 4, or plug ur phone into a computer, adb pull the entire folder and then search contents from there.
Then edit the files using notepad++ or notepad2 and then adb push them back
I actually solved this through searching a bunch more. The basic answer is that you need to edit whatever file ends with "-keypad.kl". For my Droid4 , that's "omap4-keypad.kl". Thanks for the response though!
bkenobi69 said:
I actually solved this through searching a bunch more. The basic answer is that you need to edit whatever file ends with "-keypad.kl". For my Droid4 , that's "omap4-keypad.kl". Thanks for the response though!
Click to expand...
Click to collapse
Nice, I like how you followed up with the needed info. Next time someone searches they'll stumble upon ur answer
Worked perfectly on my ZTE Blade III, stock rom. Thanks man!

Disable Capacitive Buttons (functions)

This is to show you how to disable the capacitive buttons so they will no do anything other then light up if you so please.
Generally this would be used with the onscreen NAV keys like that in the Galaxy Nexus.
Code:
I am not responsible if this causes your phone to
make first contact and bring forth a race of beings that kills us all.
I am also not responsible if this damages your phone in any way, at all.
I have done this on my SGSII LTE (Skyrocket) i727R and suffered NO issues.
I am using this on the AOKP Milestone 6 ROM.
I suspect that this would work with other ROMS and even other phones with no issues.
STEPS:
NANDROID/OTHER BACKUP!!
Using Root Explorer (or other file explorer) go to /system/usr/keylayout
MAKE A BACKUP OF "melfas_touchkey.kl"
Edit "melfas_touchkey.kl"
Add a # in front of each line, there should only be four.
Save the file and reboot your phone.
Code:
Original:
Key 158 BACK Virtual
Key 139 MENU Virtual
Key 172 HOME Virtual
Key 217 SEARCH Virtual
Code:
Altered:
#Key 158 BACK Virtual
#Key 139 MENU Virtual
#Key 172 HOME Virtual
#Key 217 SEARCH Virtual
Adding a # in front of the line disables that line of code and the function.
Now if you want the lights gone too, the only way I know of so far is to try an app that inst 100% compatible called "Keep the lights on".
The app will add a widget that you can disable the lights with.
For me, they just turn on again when coming out of standby.
[Edit]So this is also posted in RootzWiki, found it after posting.
http://rootzwiki.com/topic/31065-tu...acitive-buttons-lights-and-use-on-screen-nav/
Personally I don't see a reason to disable them but maybe you could alter this to change the function of certain keys?
ceasee said:
This is to show you how to disable the capacitive buttons so they will no do anything other then light up if you so please.
Generally this would be used with the onscreen NAV keys like that in the Galaxy Nexus.
Code:
I am not responsible if this causes your phone to
make first contact and bring forth a race of beings that kills us all.
I am also not responsible if this damages your phone in any way, at all.
I have done this on my SGSII LTE (Skyrocket) i727R and suffered NO issues.
I am using this on the AOKP Milestone 6 ROM.
I suspect that this would work with other ROMS and even other phones with no issues.
STEPS:
NANDROID/OTHER BACKUP!!
Using Root Explorer (or other file explorer) go to /system/usr/keylayout
MAKE A BACKUP OF "melfas_touchkey.kl"
Edit "melfas_touchkey.kl"
Add a # in front of each line, there should only be four.
Save the file and reboot your phone.
Code:
Original:
Key 158 BACK Virtual
Key 139 MENU Virtual
Key 172 HOME Virtual
Key 217 SEARCH Virtual
Code:
Altered:
#Key 158 BACK Virtual
#Key 139 MENU Virtual
#Key 172 HOME Virtual
#Key 217 SEARCH Virtual
Adding a # in front of the line disables that line of code and the function.
Now if you want the lights gone too, the only way I know of so far is to try an app that inst 100% compatible called "Keep the lights on".
The app will add a widget that you can disable the lights with.
For me, they just turn on again when coming out of standby.
[Edit]So this is also posted in RootzWiki, found it after posting.
http://rootzwiki.com/topic/31065-tu...acitive-buttons-lights-and-use-on-screen-nav/
Click to expand...
Click to collapse
Hey man i seen your method and i tried it but, it didn't work for me and i checked the file after a reboot and the buttons still work even thought I am trying to disable it.
I figured this out a couple months ago when I was only using virtual buttons. XD
CoogiMane1996 said:
Hey man i seen your method and i tried it but, it didn't work for me and i checked the file after a reboot and the buttons still work even thought I am trying to disable it.
Click to expand...
Click to collapse
Did you save the file? And as the right name?
Sent from my SAMSUNG-SGH-I727 using xda app-developers app

[HOW-TO] Remap capacitive (if you have(or any other)) buttons on any Android device

My original article on this was made for a Galaxy S3/S4/S5/S6/S7 devices because I didn't know that root directory organisation is almost the same.
This tutorial/how-to will guide you trough the process of remapping you capacitive buttons (or any other, I assure you'll figure it out!).
This however does not work on some chinese phones as I was told. Be careful when doing this, you can cause critical or even permanent damage to your device even if you do a smidge wrong.
HOW TO REMAP CAPACITIVE BUTTONS ON ANY ANDROID PHONE
If you're left handed like me, then you might wanna remap your capacitive buttons if you use the back key more often than the multitask button.
You can remap many other buttons such as volume keys and the power button, just use some logic and you'll figure it out.
As we progress on, you'll realize that there are many more things you can remap other than the physical buttons.
!!!DISCLAIMER!!!
I'm not responsible if this doesn't work for you!
I'm not responsible if your capacitive buttons don't work!
!!!DISCLAIMER!!!
1. You'll need root access for this, otherwise it won't let you edit the file
2. Go to Play Store and download any file manager app that supports root access (Best: ES File Explorer, Total Commander, Root Browser)
3. Open the file manager, and go to the root directory
4. Grant it root permissions if it doesn't ask in the begining
5. Go to the system folder, then to the usr folder and then to the keylayout folder
6. Long press on the Generic.kl file and click on Open as, then on Text and then select your prefered text editor
7. Now click on the search option if you have (otherwise you're gonna have a bad time searching)
8. Search for the word BACK, but search for the whole words
9. Change it to APP_SWITCH (make sure it's capitalized!)
10. Search again for the word MENU and change it to BACK (there may be two MENU words in the file so search twice)
11. Search for the word APP_SWITCH and change it to BACK
12. Save the fie
13. Exit and close the file manager
14. Reboot your device and enjoy!​
Nifty little guide! I'd been itching to figure out how to change the hard-mapped ExpressKeys on my Wacom Cintiq Companion Hybrid for a while now!
The only catch is that with this thing, you have to change those mappings in a file called "gpio-keys.kl" instead of "Generic.kl", which only seems to cover USB/Bluetooth keyboard and game controller mappings. At least it's a neat reference for potential key bindings, though by no means a full list.
In other words, if you can't find what you're looking for in Generic.kl, check gpio-keys.kl or even the other .kl files in that directory. You might just find your physical button mappings there.
NamelessFragger said:
Nifty little guide! I'd been itching to figure out how to change the hard-mapped ExpressKeys on my Wacom Cintiq Companion Hybrid for a while now!
The only catch is that with this thing, you have to change those mappings in a file called "gpio-keys.kl" instead of "Generic.kl", which only seems to cover USB/Bluetooth keyboard and game controller mappings. At least it's a neat reference for potential key bindings, though by no means a full list.
In other words, if you can't find what you're looking for in Generic.kl, check gpio-keys.kl or even the other .kl files in that directory. You might just find your physical button mappings there.
Click to expand...
Click to collapse
Thanks for letting me know, the same thing happened to my brother, he owns a sony xperia s or sl i can't remember
i want to add long press menu button for menu and single tap for recent apps. Help
i.e. menu key >long press > menu
---------- Post added at 04:07 PM ---------- Previous post was at 03:53 PM ----------
Hello!
I bought a EP online, but the power button its damaged,it press it self. I managed to root the device and deactivate the press power option by putting a # before the number of the key.
That worked now the phone is not pressing the key multiple times(it does but the action its null)
The problem its that the continuos Hold of the power key its making the phone to be rebooted, even after the power key its "DEACTIVATED" Is there any name for the action of reset that i can deactivate by doing the # thing?
please help!! this is driven me crazy..

Categories

Resources