Headphone button API/hardware question - Nexus One General

It seems as though the buttons on the cord of the stock headphones register as keyboard presses to some applications. Are the trrs headphones a feature of all android phones or just the nexus one?
I've searched for any API reference to hardware input via the headphone jack but am coming up dry. Would this be something that would have to be custom-brewed or am I using improper terminology in my searches?
Any help would be appreciated.

i got the apple iphone headphones.
3 buttons - vol+, vol-, play/pause
and just like with the iphone3g, vol+/i do not work, but play/pause does (double-clicking for next song as well).
seems to be industry standard, maybe you can find more information with this

jsoverson said:
It seems as though the buttons on the cord of the stock headphones register as keyboard presses to some applications. Are the trrs headphones a feature of all android phones or just the nexus one?
I've searched for any API reference to hardware input via the headphone jack but am coming up dry. Would this be something that would have to be custom-brewed or am I using improper terminology in my searches?
Any help would be appreciated.
Click to expand...
Click to collapse
Most input event in android is converted to so called keyevents that can be read. This includes AVRCP and headset button.
The mappings can be found in your phone in the directory /system/usr/keylayout
Example: h2w_headset.kl
Code:
key 107 ENDCALL WAKE_DROPPED
key 113 MUTE WAKE
key 114 VOLUME_DOWN WAKE
key 115 VOLUME_UP WAKE
key 163 MEDIA_NEXT WAKE
key 164 MEDIA_PLAY_PAUSE WAKE
key 165 MEDIA_PREVIOUS WAKE
key 226 HEADSETHOOK WAKE
key 231 CALL WAKE_DROPPED
So in the above the "linux key" that the driver provide when I press my headset play/pause button is 226 which Android then maps to the HEADSETHOOK android keyevent. See http://developer.android.com/reference/android/view/KeyEvent.html for info on KeyEvents.
You can also check the event yourself with the builtin getevent command, like below
Code:
# getevent
add device 1: /dev/input/event6
name: "compass"
add device 2: /dev/input/event5
name: "proximity"
add device 3: /dev/input/event4
name: "mahimahi-nav"
add device 4: /dev/input/event3
name: "mahimahi-keypad"
add device 5: /dev/input/event2
name: "synaptics-rmi-touchscreen"
add device 6: /dev/input/event1
name: "h2w headset"
add device 7: /dev/input/event0
name: "lightsensor-level"
/dev/input/event1: 0001 00e2 00000001 (this two lines are keydown for the headset button)
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 00e2 00000000 (and these two are keyup)
/dev/input/event1: 0000 0000 00000000

ok thats what i get too...
sadly there are no events showing up at all for vol+/- ... too bad...

I'm actually having issues with my jack, I'm quite sure that its a manufacture defect. No matter what 3.5mm cable I use, any type of movement of the cable produces a 'keypress', either changing the song or pausing the song. Is there some way of using this information to change the ability of my rooted, and un-warrantied, phone to fix my issue?

Hello Guys,
i'm very interested in those things.
So you mean that the iphone headset has a small processing unit inside that recognises a double-click ??
Tomorrow i'm getting my new headset from AKG which are iphone comatible. Do you think a double press will actually forward to the next song?
If it doesn't work, would it be hard to modify the HTC Hero drivers to an extent that the phone recognises doubleclick actions?
thx!

The double click action indeed goes to the next song (in tunewiki, not in the stock player) but at the same time it starts a call to the last person in my call list.
I reckon it's to hard to modify the phone-app structure without loosing all the other abilitys like endcall and pickupcall....

Hello
I am trying to get these nexus one headphones working with my g2x. Thanks to this thread I found out that headsethook is the event for play/pause. However I cannot get the next/previous track buttons to work. I want to try the listening to event thing above but I'm a noob when it comes to these things. I was wondering if someone could try it and see what event and keys the track control buttons are. Thanks

Related

cable headset button

Is it possible to catch pushing of headset button placed on cable?
It works somehow like green/red buttons, you can for example end phone talk.
i would like to change it's behavoiur. When you are not talking, i would like to make:
-one button press - start/stop mediaplayer or TCPMP
-two button press - previous mp3
-three button press - next mp3
-press and hold - voice tells you what time is it
any idea?
Marx2 said:
Is it possible to catch pushing of headset button placed on cable?
It works somehow like green/red buttons, you can for example end phone talk.
i would like to change it's behavoiur. When you are not talking, i would like to make:
-one button press - start/stop mediaplayer or TCPMP
-two button press - previous mp3
-three button press - next mp3
-press and hold - voice tells you what time is it
Click to expand...
Click to collapse
I doubt this button is able to be remapped and I will tell you why. I have a Sprint PPC6600 aka Blue Angel on this site. It came with a stereo headset with mic and push button. A close look at the 2.5 mm plug shows 4 conductors. Checking with a multimeter I found 1 = Left Ear, 2 = Right Ear, 3 = Mic and 4 = Common. So where does the button connect? As far as I can tell it is directly across the Mic, making it a part of the analog circuit and not a remappable input to PC.
http://forum.xda-developers.com/showthread.php?t=264308&highlight=talk+button
V

Adjust volume with the headset's hardware keys?

Most of the times i use the hd2 as an mp3 player when im travelling via the subway station. I keep my phone in my bag and use the headset that came with the device to listen to the music. If i want to skip a song or repeat it, i just use the little hardware keys on the headset. The problem is that if i want to lower the volume, i have to get the phone out of the bag and press the hardware keys on the device to do so.
Back to the headset now, I noticed that if you press and hold the "Pause/Play" button, nothing happens. So i was wondering... Is it possible to make the volume go up and down by pressing the "Pause/Play" button on the headset, with the combination of "Next"(to get the volume up) and "Previous" (to get the volume down)?
(holding "Pause/Play"+"Next" = volume up)
(holding "Pause/Play"+"previous" = volume down)
Also interested
get a bluetooth and everything done, same problem on my iPhone but no more.
Constructive answer Already got a bluetooth but always forget to charge it. Soundquality is slightly worse, reaction time when skipping songs sucks etc.
I have a program for that. Headset Button.
Headset Button recognizes five different types of presses: single, double, triple, long (press & hold) and double long (the second press is long)
Click to expand...
Click to collapse
doesnt say anything about combination but i guess that works as well. thx for the sharing!
runningdap said:
doesnt say anything about combination but i guess that works as well. thx for the sharing!
Click to expand...
Click to collapse
Combinations are not supported. Default assignments are:
Single press "Next" = next track
Long press "Next" = fast forward
Double long press "Next" = volume up
Single press "Prev" = previous track
Long press "Prev" = rewind
Double long press "Prev" = volume down

[Q] remap keys - volume u/d stopped working

I've remap my power key to work as my camera key because my power button has issues. Everything works fine, but then I realize, my volume up n down doesn't work.
Below are two pics that shows my current key settings, and my backup. What did I do wrong here?
And to ask why I did this:
http://forum.xda-developers.com/showthread.php?p=17358757#post17358757
That looks messed up.. here's the original, because your original is off.
Code:
key 102 HOME
key 139 MENU
key 158 BACK
key 231 CALL
key 211 FOCUS
key 212 CAMERA
key 217 SEARCH
key 183 FUNC_4
key 107 ENDCALL WAKE_DROPPED
key 116 POWER WAKE_DROPPED
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
Remove wake dropped from power if you want to stop the power button from waking up the phone. be warn this might bork volume, but try it first.
put WAKE_DROPPED next to menu so you can wake your phone while its locked using the menu button. I don't know if it'll stop the power button from locking the phone though... but hey, trial and error = success eventually.
Also, keep them aligned.
Code:
key 107 ENDCALL WAKE_DROPPED
is different from
Code:
key 107 ENDCALL WAKE_DROPPED
Thanks. Removing "WAKE_DROPPED" from the power seems to do the trick. I was over analyzing the whole thing. My power button is still a little glitchy though, but everything else is working. Thanks again.
er, the power options is still popping up whenever i'm using the phone

Joying 4.4.4 android HU keymap question.

I have the unit fully installed and working except for the "next" button on my steering wheel. The volume buttons work fine. I am able to map the button to "next track" but the music apps don't respond. I made sure the option to respond to hardware buttons is enabled in the app (dsub).
The same app on my phone will let me use the skip button on BT headphones.
I also remapped the button to "home" to verify its not a vehicle side problem and it worked fine. Hitting "next" on the steering wheel took me to the home screen. I still get the confirmation beep no matter what it is mapped to.
The button input is a varying resistance type if that matters. '09 lincoln towncar using the crux SWC adapter. Only 3 buttons; vol+, vol-, and next.
Any ideas? I was toying with remapping the button to some other function and setting a tasker event to skip track. End call? That should do nothing unless I'm on a call.

How to edit/upload/ CANBUS settings?

I have Junsun V1 head unit with LTE and canbox.
CAN settings is selected as "VW RZC".
Steering wheel buttons working good.
I have not connected KEY 1 and KEY 2. It`s not working. SWC is not working and that is ok, because CAN is working.
The problem is:
When I press volume UP on the wheel, volume down, next, prev - works good
When I press phone button on the steering wheel, the head unit open by default Bluetooth app.
So, when someone is calling to me, I can`t pick up the phone from the steering wheel, because Bluetooth app is opening.
Everything is coded in by CAN (VW RZC).
How to edit can settings? or how to upload new setting? How to change bluetooth for “pick up”?
Once again, please forget about key 1, key 2 and SWC.
Pure CAN recoding.
I would like to know the answer to how to recode CANBUS settings. My volume up and down keys work as expected, but my phone key opens the Bluetooth app also and I want to turn it into a "next track" button and the hang up button into a "previous track" button.
For your problem, there is a submenu in 8878. I think it is in "Other" but possibly in CAN that reverse volume up and down. That should fix that problem. If you can't figure it out I will check next time I'm in my van.

Categories

Resources