[Hero CDMA Android Development] Decad3nce:
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:

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):

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:

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.

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:

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. :D

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.

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!!!!

--------------------------------------------------------------------
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

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:

am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity

Which results in:

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:

#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

:D

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