Hi all, hopefully someone can help me, I tried to do the change on my rooted phone from key 226 HEADSETHOOK to "key 226 MEDIA_PLAY_PAUSE"
Question is, my original line for key 226 HEADSETHOOK is formatted weird, it has no number sign and a few extra spaces stock. Do i replace it with key 226 MEDIA_PLAY_PAUSE, no number sign and no quotations? Do I mimic the spacing? Currently, this is what my headsethook looks like with the line before it and after it as well:
-------------------------------------------------------
# key 225 "KEY_BRIGHTNESSUP"
key 226 HEADSETHOOK
key 256 BUTTON_1
-------------------------------------------------------
Note how mine has 3 spaces between 226 and headsethook....should I make the new code replacing it like this?:
key 226 MEDIA_PLAY_PAUSE (there are 3 spaces between 226 and media)
And should I still skip a line after it?
ash0074 said:
Hi all, hopefully someone can help me, I tried to do the change on my rooted phone from key 226 HEADSETHOOK to "key 226 MEDIA_PLAY_PAUSE"
Question is, my original line for key 226 HEADSETHOOK is formatted weird, it has no number sign and a few extra spaces stock. Do i replace it with key 226 MEDIA_PLAY_PAUSE, no number sign and no quotations? Do I mimic the spacing? Currently, this is what my headsethook looks like with the line before it and after it as well:
-------------------------------------------------------
# key 225 "KEY_BRIGHTNESSUP"
key 226 HEADSETHOOK
key 256 BUTTON_1
-------------------------------------------------------
Note how mine has 3 spaces between 226 and headsethook....should I make the new code replacing it like this?:
key 226 MEDIA_PLAY_PAUSE (there are 3 spaces between 226 and media)
And should I still skip a line after it?
Click to expand...
Click to collapse
Another note, this post is removing my spaces, so they arent showing here but the spaces are on my phone.
Ok, I got it to work, I switched 164 and 226 and i was able to pause and start my music, but now i can't answer calls with that button. Is it one or the other, is there no way to make a single button headset control calls and music?
ash0074 said:
Ok, I got it to work, I switched 164 and 226 and i was able to pause and start my music, but now i can't answer calls with that button. Is it one or the other, is there no way to make a single button headset control calls and music?
Click to expand...
Click to collapse
Anyone know anything on this?
Volume?
That was most helpful. Note for everyone, it was the qwerty.kl file (info on finding it and such here http://forum.xda-developers.com/showthread.php?t=1229066)
Any thoughts on the volume up and down buttons maybe?
try gonemad player
Related
We all know that the physical keys mapped for Android are less than ideal--so let's work together to build a better Vogue key map, that we can ultimately customize the layout to our individual likings.
Here is an excellent link detailing information regarding Key Input and the Key Map--if nothing else, glaze over this quickly: http://www.kandroid.org/android_pdk/keymaps_keyboard_input.html
Android KeyMaps are stored in /system/usr/keylayout. On your particular build, you'll probably see a number of .kl files: AVRCP.kl, h2w_headset.kl, qwerty.kl, sapphire-keypad.kl, trout-keypad.kl, etc. For our purposes, disregard all of them except qwerty.kl. If Android can find no other .kl file, it will default to qwerty.kl. You can (for example) delete all of the other .kl files, and your phone will function exactly the same based on qwerty.kl.
If you examine your qwerty.kl, it will look very similar to the KeyMap from the link above. It follows this format:
SCANCODE KEYCODE [FLAGS]
Here is, for example, my qwerty.kl as pulled from Plemen's 1.6 AOSP build:
key 399 GRAVE
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 SOFT_RIGHT WAKE
key 60 SOFT_RIGHT WAKE
key 107 ENDCALL WAKE_DROPPED
key 62 ENDCALL WAKE_DROPPED
key 229 MENU WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 59 MENU WAKE_DROPPED
key 127 SEARCH WAKE_DROPPED
key 217 SEARCH 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 HOME WAKE
key 105 DPAD_LEFT WAKE_DROPPED
key 106 DPAD_RIGHT WAKE_DROPPED
key 115 VOLUME_UP
key 114 VOLUME_DOWN
key 116 POWER WAKE
key 212 CAMERA
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 26 LEFT_BRACKET
key 27 RIGHT_BRACKET
key 43 BACKSLASH
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 39 SEMICOLON
key 40 APOSTROPHE
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 53 SLASH
key 28 ENTER
key 56 ALT_LEFT
key 100 ALT_RIGHT
key 42 SHIFT_LEFT
key 54 SHIFT_RIGHT
key 15 TAB
key 57 SPACE
key 150 EXPLORER
key 155 ENVELOPE
key 12 MINUS
key 13 EQUALS
key 215 AT
Click to expand...
Click to collapse
When a button is pressed, it sends a SCANCODE to Android, which is interpretted and this file defines the corresponding action--back, volume up, end, camera, etc.--as well as the FLAGS that code may have, such as "WAKE", which means that button can then wake the device from sleep.
What we need is to map the button single-press and long-presses on our Vogue and identify the SCANCODES. With them, we can write our own .kl file, completely customized for us.
Currently, getting the SCANCODES seems to be the roadblock. I've tried "GetKeys" from the terminal without any luck. In the research I've done so far, it appears it may require some native C code to interpret system input and print it back out.
Please contribute and feel free to dig away in an effort to accelerate this project. Once this is done, it's one more item checked off for Android development--and it should be portable to all versions (1.5, 1.6, 2.0, 2.1, etc.)
Lastly, while I believe everything I've cited to be true, I may be incorrect--please correct me if I am.
this is something we've addressed before a few times, and have already changed the default keymap to what it is now.
Currently the keymap is set by the kernel, not by the userspace. check the kernel git and you should be able to find what you're looking for.
In case someone's still trying to find out which key does which scancode (or rather key number in the .kl files): Just use "getevent" in the terminal or ADB.
Second column of numbers is "key number" in hex.
Hi,
I'm looking to something like this to a bluetooth keyboard. How to implement deadkeys?
hi
i would like to use the Sony Play keypad to send key codes, like sending "Enter" with the "X" pad, "F" with the "O" pad, etc...
is it possible to remap the keypad to use it in another android application like a game or notepad application or something like that ? perhaps there an application for this ?
is it possible to change the orientation of the screen when i open the keypad, i would like to stay in portrait instead of landscape.
thanks a lot
up up up !
Code:
Key code constant scancode
X 23 KEYCODE_DPAD_CENTER 304
circle 4 KEYCODE_BACK 305
square 99 KEYCODE_BUTTON_X 307
triangle 100 KEYCODE_BUTTON_Y 308
up 19 KEYCODE_DPAD_UP 106
down 20 KEYCODE_DPAD_DOWN 105
left 21 KEYCODE_DPAD_LEFT 103
right 22 KEYCODE_DPAD_RIGHT 108
select 109 KEYCODE_BUTTON_SELECT 314
start 108 KEYCODE_BUTTON_START 28
L trigger 102 KEYCODE_BUTTON_L1 310
R trigger 103 KEYCODE_BUTTON_R1 311
In addition, if you want to differentiate the circle from the regular back button, you have to check to see if the "alt" key is being pressed. (If so, it's really the circle button. If not, it's the regular android back button.)
Use the RE Explorer (remember change the folder read-only permissions to read and write) into the / system / usr / keylayout folder, in qwerty.kl file, add a few lines of code:
key 113 MUTE
key 163 MEDIA_NEXT
key 164 MEDIA_PLAY_PAUSE
key 165 MEDIA_PREVIOUS
key 226 HEADSETHOOK WAKE
key 231 CALL WAKE_DROPPED
Now it can control music playing!
One click- play, pause music, answer/ end the call
long press- play the next music
double click- play the previous music
Doesn't work on Oxygen how can check what button code a button have?
Sent from my Ideos x5
Sorry, I have no idea about Oxygen rom. Try to fetch offcial conduction from the Oxygen group.
Okay thanks!
Sent from my Ideos x5
这个可以有!~~up!~~
excelwang said:
Use the RE Explorer (remember change the folder read-only permissions to read and write) into the / system / usr / keylayout folder, in qwerty.kl file, add a few lines of code:
key 113 MUTE
key 163 MEDIA_NEXT
key 164 MEDIA_PLAY_PAUSE
key 165 MEDIA_PREVIOUS
key 226 HEADSETHOO K WAKE
key 231 CALL WAKE_DROPPED
Now it can control music playing!
One click- play, pause music, answer/ end the call
long press- play the next music
double click- play the previous music
Click to expand...
Click to collapse
Are you sure it isn't key 226 HEADSETHOOK WAKE without a space between oo and k?
Code:
key 113 MUTE
key 163 MEDIA_NEXT
key 164 MEDIA_PLAY_PAUSE
key 165 MEDIA_PREVIOUS
key 226 HEADSETHOOK WAKE
key 231 CALL WAKE_DROPPED
This works on Oxygen too, thanks dude! =D
Play/pause music
Answer call/mute mic/long press to end call
andreasha said:
Are you sure it isn't key 226 HEADSETHOOK WAKE without a space between oo and k?
Click to expand...
Click to collapse
Ur, I'm sorry. There is no space between oo and K.
have anyone tried them on stock rom ?
My headset button worked fine on stock atleast on 136. But this may add some functionality like mute mic (I dont remember that function on stock). Anyway you should find a .kl file in that folder on stock too.
Sent from my Ideos x5
Hi,
In conjunction with what I was trying to do here - http://forum.xda-developers.com/showthread.php?t=1333674 ,
I modified the keylayout in /system/usr/keylayout/AVRCP.kl so that the keycode that was earlier assigned to MEDIA_NEXT is now assigned to MEDIA_PLAY_PAUSE.
From
Code:
key 200 MEDIA_PLAY_PAUSE WAKE
key 201 MEDIA_PLAY_PAUSE WAKE
key 166 MEDIA_STOP WAKE
key 163 MEDIA_NEXT WAKE
key 165 MEDIA_PREVIOUS WAKE
key 168 MEDIA_REWIND WAKE
key 208 MEDIA_FAST_FORWARD WAKE
to
Code:
key 200 MEDIA_PLAY_PAUSE WAKE
key 201 MEDIA_PLAY_PAUSE WAKE
key 166 MEDIA_STOP WAKE
key 163 MEDIA_PLAY_PAUSE WAKE
key 165 MEDIA_PLAY_PAUSE WAKE
key 168 MEDIA_REWIND WAKE
key 208 MEDIA_FAST_FORWARD WAKE
For good measure, I also changed the MEDIA_PREVIOUS to MEDIA_PLAY_PAUSE.
Trouble is, this fix isnt working. Am I doing something wrong? Is it reading the configuration from elsewhere?
Meanwhile, the default headset is working fine with these settings as well. I could really use some help here
Soumen
I've taken the liberty of rooking a Nook Glowlight 3 and changing the keymap as follows:
Code:
$ cat /system/usr/keylayout/imx-keypad.kl
key 158 BACK
key 116 POWER WAKE
key 139 MENU
key 412 BACK
key 102 HOME WAKE
key 353 DPAD_CENTER
key 103 DPAD_UP
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 108 DPAD_DOWN
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 90 BUTTON_B
key 191 3
key 192 1
key 193 2
key 194 4
However, when I press the hardware buttons I do not get the expected numeral keypresses. I had based the idea that this would work off this forum post which states:
Renate NST said:
The six hard buttons are mapped in /system/usr/keylayout/imx-keypad.kl
LowerLeft 191 F9
UpperLeft 192 F10
UpperRight 193 F11
LowerRight 194 F12
Power 116 Power
Home 102 Home
Click to expand...
Click to collapse
Of course, I did reset the device after changing the file, and the output seen here is from running cat after the reset so I know that the file was changed properly. Why might the buttons not present the keypresses expected?
For keys to work, you've got:
/system/usr/idc/*.idc - provides links to the other two files
/system/usr/keylayout/*.kl - maps hardware inputs to keys
/system/usr/keychars/*.kcm - maps keys to characters
The first thing to note is that B&N (NTX) just sloppily edited example files.
The imx-keypad.kl has a lot of cruft for things that don't exist.
Ok, they don't do any harm unless there is something wrong with them, then the file reading aborts at that line.
If this were the case, you might have seen a line in the dmesg log.
Get UsbMode.apk out of the signature.
Then you can see where the chain of conversion from hardware input to character fails.
(1, 2, 3, 4 is really not a useful usage of the side keys.
It won't do anything reasonable with any non-custom app.
Page up/page down elicits a response from most things.)
Renate NST said:
For keys to work, you've got:
/system/usr/idc/*.idc - provides links to the other two files
/system/usr/keylayout/*.kl - maps hardware inputs to keys
/system/usr/keychars/*.kcm - maps keys to characters
The first thing to note is that B&N (NTX) just sloppily edited example files.
The imx-keypad.kl has a lot of cruft for things that don't exist.
Ok, they don't do any harm unless there is something wrong with them, then the file reading aborts at that line.
If this were the case, you might have seen a line in the dmesg log.
Get UsbMode.apk out of the signature.
Then you can see where the chain of conversion from hardware input to character fails.
(1, 2, 3, 4 is really not a useful usage of the side keys.
It won't do anything reasonable with any non-custom app.
Page up/page down elicits a response from most things.)
Click to expand...
Click to collapse
Thank you so much Renate. I was wondering what all that cruft was, I will remove it to see if that is preventing further parsing of the file.
In fact, I use the Nook almost exclusively for AnkiDroid, so the 1,2,3,4 are for that app.
Actually, it's more likely that you edited that text file on a Windows CR/LF text editor.
The system will abort as soon as it sees a CR, 0x0d
You can do a hex dump "hd imx-keypad.kl" right on your Nook.
(Use Notepad++ instead.)
Renate NST said:
Actually, it's more likely that you edited that text file on a Windows CR/LF text editor.
Click to expand...
Click to collapse
Very unlikely that VIM on Debian would use CRLF line endings!
dotancohen said:
However, when I press the hardware buttons I do not get the expected numeral keypresses.
Click to expand...
Click to collapse
Well, you're not very explicit on what you do get.
Do you get any response? What?
Did you break your Home key?
Use the UsbMode.apk