[Xperia Play Android Development] farenheith:
Hi guys,

YOU CAN ONLY DO THIS IN ICS/JB ROMS because, in GB, the kcm files is compiled (kcm.bin)

I'm opening this thread to share a little found: There's a way to take photos with R1 without the need of a modded app and without screw up the keymap. To do this, you need to change this file /system/usr/keychars/keypad-zeus.kcm

You need to add this lines to the file:

type SPECIAL_FUNCTION

key BUTTON_R1 {
base: fallback CAMERA
}

key BUTTON_L1 {
base: fallback FOCUS
}

NEWS!! Map BUTTON_R1 to DPAD_CENTER in place of CAMERA Then, you'll get focus + camera in the same button. THE PROBLEM WITH IT IS: If you accidentally press R1 in the launcher, you'll enter the focused app AND hold R1 will no longer call the camera app

BE CAREFUL!l! If you already have something like this:

type SPECIAL_FUNCTION

key BUTTON_R1 {
base: none
}

key BUTTON_L1 {
base: none
}

In this case, you just need to change the none by fallback CAMERA for the R1 and fallback FOCUS for the L1

BE CAREFUL 2!![/B] If you file looks like this:

[type=QWERTY]

# keycode display number base caps fn caps_fn

DPAD_CENTER 0x2715 0x00 0x00 0x00 0x00 0x00
BACK 0x25CB 0x00 0x00 0x00 0x00 0x00
BUTTON_X 0x25A1 0x00 0x00 0x00 0x00 0x00
BUTTON_Y 0x25B3 0x00 0x00 0x00 0x00 0x00

In this case, make a backup of the old file and create a new one, with the same name and the same permissions, and put the content provided above.

If the file doesn't exists, create it and let it have the same permissions of the others files in the folder

Finally, restart the phone.

If you did all ok, you'll can take shots in the camera app using the R1, and focus using the L1. Also, if you're on the launcher or in some apps that doesn't treat the R1 key event or the camera key event, if you hold R1 you'll call the camera.

The good thing about this mod is that you're not changing the keymap. This config means that, IF the app doesn't treat the R1 and/or L1 button then the system will send a new keyevent (do a fallback) to the CAMERA/FOCUS key.

So, in theory, every app that treats the R1 and L1 buttons will not be screwed up, but every app that not, will receive a CAMERA/FOCUS key event when you press some of these buttons (what includes camera apps)

Everything is working fine to me until now and I think it can't cause much problem, so...

MAP MEDIA KEYS

You can also map some media keys, putting info like this in the keypad-zeus.kcm::

key BUTTON_X {
base: fallback MEDIA_STOP
}

key BUTTON_Y {
base: fallback MEDIA_PLAY_PAUSE
}

To go to the previous and next media, you need to edit the keypad-game-zeus.kcm, and put this map:

key BUTTON_START {
base: fallback MEDIA_NEXT
}

key BUTTON_SELECT {
base: fallback MEDIA_PREVIOUS
}

If the file doesn't exist. you need to create and make the first line be this:

type SPECIAL_FUNCTION

With this fallback, the square button will be treated like a STOP and the triangle button will be treated like a play/pause. This treatment will only happens when the first function of the button is been ignored by the current app, that is, it'll not affect games that do use this buttons.

The start is mapped to MEDIA_NEXT on the example, and the select to MEDIA_PREVIOUS, but I couldn't navigate between my musics with this config, idk why. Maybe is something with the ROM (I'm using MIUI Australia) idk, we need to test it in some other ROMs to know.

DOWNLOAD

To make the work easier, you can also just download the files attached, rename it to zeus-keypad.kcm and the zeus-game-keypad.kcm and put it into the /system/usr/keychars folder. Don't forget to remove the .txt of the end of the file names

BE CAREFUL! Make a backup of the old ones first!!

BE CAREFUL 2! If you old file already have some other fallback specified, with this procedure you'll lost it

KNOW MORE ABOUT IT!

You can read official information about kcm files here and, maybe, do your own fallback!

A full list of the possible fallbacks for our device you can see below, but many keys described may not work, so, you need to test to make sure:

{ "SOFT_LEFT", 1 },
{ "SOFT_RIGHT", 2 },
{ "HOME", 3 },
{ "BACK", 4 },
{ "CALL", 5 },
{ "ENDCALL", 6 },
{ "0", 7 },
{ "1", 8 },
{ "2", 9 },
{ "3", 10 },
{ "4", 11 },
{ "5", 12 },
{ "6", 13 },
{ "7", 14 },
{ "8", 15 },
{ "9", 16 },
{ "STAR", 17 },
{ "POUND", 18 },
{ "DPAD_UP", 19 },
{ "DPAD_DOWN", 20 },
{ "DPAD_LEFT", 21 },
{ "DPAD_RIGHT", 22 },
{ "DPAD_CENTER", 23 },
{ "VOLUME_UP", 24 },
{ "VOLUME_DOWN", 25 },
{ "POWER", 26 },
{ "CAMERA", 27 },
{ "CLEAR", 28 },
{ "A", 29 },
{ "B", 30 },
{ "C", 31 },
{ "D", 32 },
{ "E", 33 },
{ "F", 34 },
{ "G", 35 },
{ "H", 36 },
{ "I", 37 },
{ "J", 38 },
{ "K", 39 },
{ "L", 40 },
{ "M", 41 },
{ "N", 42 },
{ "O", 43 },
{ "P", 44 },
{ "Q", 45 },
{ "R", 46 },
{ "S", 47 },
{ "T", 48 },
{ "U", 49 },
{ "V", 50 },
{ "W", 51 },
{ "X", 52 },
{ "Y", 53 },
{ "Z", 54 },
{ "COMMA", 55 },
{ "PERIOD", 56 },
{ "ALT_LEFT", 57 },
{ "ALT_RIGHT", 58 },
{ "SHIFT_LEFT", 59 },
{ "SHIFT_RIGHT", 60 },
{ "TAB", 61 },
{ "SPACE", 62 },
{ "SYM", 63 },
{ "EXPLORER", 64 },
{ "ENVELOPE", 65 },
{ "ENTER", 66 },
{ "DEL", 67 },
{ "GRAVE", 68 },
{ "MINUS", 69 },
{ "EQUALS", 70 },
{ "LEFT_BRACKET", 71 },
{ "RIGHT_BRACKET", 72 },
{ "BACKSLASH", 73 },
{ "SEMICOLON", 74 },
{ "APOSTROPHE", 75 },
{ "SLASH", 76 },
{ "AT", 77 },
{ "NUM", 78 },
{ "HEADSETHOOK", 79 },
{ "FOCUS", 80 },
{ "PLUS", 81 },
{ "MENU", 82 },
{ "NOTIFICATION", 83 },
{ "SEARCH", 84 },
{ "MEDIA_PLAY_PAUSE", 85 },
{ "MEDIA_STOP", 86 },
{ "MEDIA_NEXT", 87 },
{ "MEDIA_PREVIOUS", 88 },
{ "MEDIA_REWIND", 89 },
{ "MEDIA_FAST_FORWARD", 90 },
{ "MUTE", 91 },
{ "PAGE_UP", 92 },
{ "PAGE_DOWN", 93 },
{ "PICTSYMBOLS", 94 },
{ "SWITCH_CHARSET", 95 },
{ "BUTTON_A", 96 },
{ "BUTTON_B", 97 },
{ "BUTTON_C", 98 },
{ "BUTTON_X", 99 },
{ "BUTTON_Y", 100 },
{ "BUTTON_Z", 101 },
{ "BUTTON_L1", 102 },
{ "BUTTON_R1", 103 },
{ "BUTTON_L2", 104 },
{ "BUTTON_R2", 105 },
{ "BUTTON_THUMBL", 106 },
{ "BUTTON_THUMBR", 107 },
{ "BUTTON_START", 108 },
{ "BUTTON_SELECT", 109 },
{ "BUTTON_MODE", 110 },
{ "ESCAPE", 111 },
{ "FORWARD_DEL", 112 },
{ "CTRL_LEFT", 113 },
{ "CTRL_RIGHT", 114 },
{ "CAPS_LOCK", 115 },
{ "SCROLL_LOCK", 116 },
{ "META_LEFT", 117 },
{ "META_RIGHT", 118 },
{ "FUNCTION", 119 },
{ "SYSRQ", 120 },
{ "BREAK", 121 },
{ "MOVE_HOME", 122 },
{ "MOVE_END", 123 },
{ "INSERT", 124 },
{ "FORWARD", 125 },
{ "MEDIA_PLAY", 126 },
{ "MEDIA_PAUSE", 127 },
{ "MEDIA_CLOSE", 128 },
{ "MEDIA_EJECT", 129 },
{ "MEDIA_RECORD", 130 },
{ "F1", 131 },
{ "F2", 132 },
{ "F3", 133 },
{ "F4", 134 },
{ "F5", 135 },
{ "F6", 136 },
{ "F7", 137 },
{ "F8", 138 },
{ "F9", 139 },
{ "F10", 140 },
{ "F11", 141 },
{ "F12", 142 },
{ "NUM_LOCK", 143 },
{ "NUMPAD_0", 144 },
{ "NUMPAD_1", 145 },
{ "NUMPAD_2", 146 },
{ "NUMPAD_3", 147 },
{ "NUMPAD_4", 148 },
{ "NUMPAD_5", 149 },
{ "NUMPAD_6", 150 },
{ "NUMPAD_7", 151 },
{ "NUMPAD_8", 152 },
{ "NUMPAD_9", 153 },
{ "NUMPAD_DIVIDE", 154 },
{ "NUMPAD_MULTIPLY", 155 },
{ "NUMPAD_SUBTRACT", 156 },
{ "NUMPAD_ADD", 157 },
{ "NUMPAD_DOT", 158 },
{ "NUMPAD_COMMA", 159 },
{ "NUMPAD_ENTER", 160 },
{ "NUMPAD_EQUALS", 161 },
{ "NUMPAD_LEFT_PAREN", 162 },
{ "NUMPAD_RIGHT_PAREN", 163 },
{ "VOLUME_MUTE", 164 },
{ "INFO", 165 },
{ "CHANNEL_UP", 166 },
{ "CHANNEL_DOWN", 167 },
{ "ZOOM_IN", 168 },
{ "ZOOM_OUT", 169 },
{ "TV", 170 },
{ "WINDOW", 171 },
{ "GUIDE", 172 },
{ "DVR", 173 },
{ "BOOKMARK", 174 },
{ "CAPTIONS", 175 },
{ "SETTINGS", 176 },
{ "TV_POWER", 177 },
{ "TV_INPUT", 178 },
{ "STB_POWER", 179 },
{ "STB_INPUT", 180 },
{ "AVR_POWER", 181 },
{ "AVR_INPUT", 182 },
{ "PROG_RED", 183 },
{ "PROG_GREEN", 184 },
{ "PROG_YELLOW", 185 },
{ "PROG_BLUE", 186 },
{ "APP_SWITCH", 187 },
{ "BUTTON_1", 188 },
{ "BUTTON_2", 189 },
{ "BUTTON_3", 190 },
{ "BUTTON_4", 191 },
{ "BUTTON_5", 192 },
{ "BUTTON_6", 193 },
{ "BUTTON_7", 194 },
{ "BUTTON_8", 195 },
{ "BUTTON_9", 196 },
{ "BUTTON_10", 197 },
{ "BUTTON_11", 198 },
{ "BUTTON_12", 199 },
{ "BUTTON_13", 200 },
{ "BUTTON_14", 201 },
{ "BUTTON_15", 202 },
{ "BUTTON_16", 203 },
{ "LANGUAGE_SWITCH", 204 },
{ "MANNER_MODE", 205 },
{ "3D_MODE", 206 },
{ "CONTACTS", 207 },
{ "CALENDAR", 208 },
{ "MUSIC", 209 },
{ "CALCULATOR", 210 },
{ "TOGGLE_WIFI", 211 },
{ "TOGGLE_BT", 212 },
{ "TOGGLE_TOUCHPAD", 213 },
{ "BRIGHTNESS_DOWN", 214 },
{ "BRIGHTNESS_UP", 215 },
{ "BRIGHTNESS_AUTO", 216 },
{ "SCREENSHOT", 217 },
{ "FUNC_1", 218 },
{ "FUNC_2", 219 },
{ "FUNC_3", 220 },
{ "FUNC_4", 221 },
{ "FUNC_5", 222 },
{ "FUNC_6", 223 },
{ "FUNC_7", 224 },
{ "FUNC_8", 225 },
{ "USER1", 226 },
{ "USER2", 227 },
{ "USER3", 228 },
{ "USER4", 229 },
{ "USER5", 230 },

// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.

{ NULL, 0 }

Also, don't try to do any fallback to the D-PAD directional, circle, cross and gamepad menu buttons. the problem with this ones is:

The circle is, actually, a back button with alt enabled. So you can do a fallback to the back with alt, but this fallback will never be used because every app listen to the back key, and the fallback just happens when a key is ignored by the app.

The cross buttons is a D-PAD CENTER, that is, do you remember those devices without trouchscreen with a D-PAD to navigate into the menu? And this D-PAD always have a center button to select the item? Well, yes, this is the D-PAD CENTER, so, it's very likely that the apps is listen to this button too, so, is useless to make a fallback to it. So, the D-PAD directionals is listened either...

Finally, we have a menu key on the gamepad, and the menu key is listened to almost every app either :P.

In resume: the only buttons we can play with is L, R, Square, triangle, select and start