yashsingh1/xdaforums huggingface dataset:
[Nexus 4 General] slimshouki:
I do have the same problem for answering calls or rejecting. It seems that the headset buttons stop working soon after the phone app starts. However, if you restored headsethook to default value, it will answer and reject normally. My rom is HD revolution 17.1 on stock kernel. Also there is no such file named hs_delect.kl
[Nexus 4 General] ZedeN:
Thanks for this, now I am able to configure headset controls for short presses using Headset Controller but long presses still force start !@#$ing Google now. Anyone know a way to stop Google Now hijacking long presses on headset? I am using a 3 Button headset but only the centre one works since it wasn't designed for Android.

Key Test shows that short pressing or long pressing the headset key is identified as same button but repeatCount= keeps increasing the longer I press. For repeatCount=1 the flags=0x8 changes to flags=0x88 and then back to 0x8 for all further repeats. Not sure if this helps.

Edit, added screenshots:

For repeatCount=1 (holding for split second longer than short press) : http://dl.dropbox.com/u/19381987/Screenshot_2013-01-10-04-39-04.png

For repeatCount=0 : http://dl.dropbox.com/u/19381987/Screenshot_2013-01-10-04-39-12.png

For holding button for couple sec : http://dl.dropbox.com/u/19381987/Screenshot_2013-01-10-04-39-22.png
[Nexus 4 General] MattSkeet:
My other gripe is that you cannot use Google now if screen is locked or off. E.g walking down the street, want to make a call by holding button and asking Google to call such and such person won't work. I have to turn on and unlock the screen to do it which is pointless :(
[Nexus 4 General] spinal2k:
So...

I have this weird Android 4.0.4 ( Lenovo A789 ) and here is my problem:

* On ANY "one button headset" that i plug, sound comes low on vocals and whenever i press the button i get the full sound. Tried with Skullcandys and Jays One Plus. Both these headsets are working correctly on iDevices and i saw them working correctly on a samsung galaxy s2.

Ok, now i'm going to share what i've tried (my problem might be a rom issue):

1) Followed the tutorial in the first post ( had to create hs_detect.kl as it wasn't there ). Rebooted, still no activity on the button.

2) tried all apps described in this forum (keytest, headsetcontrol,Jays official app, headset droid, headset button controller, ). None of them detect the button being pressed and some of these apps can detect conflicts and no conflicts were found.

The original headset got broken (button still should work, but does nothing on keytest). It has worked before to answer calls.

Suggestions on what can i try more
[Nexus 4 General] estallings15:
It says very clearly under requirements in the OP that you need Android 4.1+
[Nexus 4 General] spinal2k:
nevermind then... my bad, thank you!
[Nexus 4 General] jan.ringas:
Your problem sounds like the 3,5mm-jack of your Lenovo A789 is using the OMTP-standard instead of the now more common CTIA-standard.

The difference lies in the order in which the signals (R, L, Ground, Mic) are set on the plug of the headset (see http://talk.sonymobile.com/thread/31455), therefore you can hear the sound correctly when pressing the button. There are adapters to use OMTP-headsets on CTIA-devices and vice-versa, but I didn't try one yet (as I didn't have to), so I can't say how good they are. But if you do some research with the terms OMTP, CTIA and adaptor you should find some useful information.
[Nexus 4 General] kirdroid:
After making the changes in the op, does the one button earphones configured to control the volume up/down using an app like headset control? Has it worked for anyone, specifically volume control.
[Nexus 4 General] IAmAN00bie:
It worked for me when I used a single button headset, but I don't use one anymore so I don't know if the latest updates broke it.
[Nexus 4 General] fingerella:
just one question, does it work when screen is off? Thanks.
[Nexus 4 General] IAmAN00bie:
It did for me.
[Nexus 4 General] ehabage:
hey guys i tried this tweaking and it worked for music players but neither headset button controller nor headset droid can control phone calls. what can i do??

am using Galaxy Note II 4.1.2
[Nexus 4 General] Kazliux:
same here: music controls work, but cannot answer or end calls :( any solution?
[Nexus 4 General] IAmAN00bie:
That might be a side-effect of this, though I don't know why that happens. The headset controller app SHOULD handle that, but apparently it isn't.
[Nexus 4 General] privatesam:
Should've thanked you guys for this a few weeks ago. So thanks! However struggling massively in that Headset Droid is not seeing the Next Button click to answer the call whilst the phone is ringing. I can only think that something in android overrides Headset Droid when the phone is ringing. Need to find a way round this. Toying with trying to use Tasker to rewrite and write the codes back but this is CLUNKY and probably wont work.

Any ideas?
[Nexus 4 General] IAmAN00bie:
I honestly don't know about the phone call issue. Headset Button Controller SHOULD be able to control it (it's an option in the app after all!) but it just isn't.
[Nexus 4 General] privatesam:
It feels like when the phone is ringing Android grabs control of any inputs from hardware buttons and resolutely refuses to recognise anything other than a HEADSETHOOK as a way of answering. I've tried a load of hack arounds last night - namely trying to get Tasker to listen for a phone call and then grab control changing stuff in the Generic.kl and the other file but to no avail.

A couple of plans of attack:

1.) Contact the makes of Headset Button Controller as they will understand and no doubt be able to debug why Android won't let it send the intent to answer while calling.

2.) Contact a member on XDA to see if they can identify why Google Search is hijacking the long press in the first place and hack that as opposed to this workaround.

3.) When I get some time later today I'm going to see if I can remap the volume up key to answer a call while ringing which might suffice for now.

So annoying that this hack was almost, so close, to the solution!!!!!
[Nexus 4 General] privatesam:
call issue workaround

Ok so spent last night finding a costly workaround!

First of all tried changing the key reassignment to MEDIA_PREVIOUS just to see if that works. Nope.

The I decided to head back to the standard google set up and just use Headset Button Controller to control double clicks and sing clicks and forget the long press. However even this google's vicious button controller messes up. Every time you attempt a click Headset Button controller tries its best to do as you've asked but then Google's default action kicks in. Its like android's listening for the clicks like a hawk and beats headset button controller to it.

So back to the drawing board. I went back to the original hack and did everything as outlined in the first post. Great set up - just no way to answer calls with headset in without touching the screen. After trawling the Play Store and testing a load of different answering call apps I found EZbutton. Its annoyingly a paid for app, but its cheap. Its not pretty, not intuitive but it does one vital thing for us - answers calls with the volume button! So if like me you do this setup you can get this app and when a call comes in with your headset on you only need to fumble around in your pocket enough to find the volume button to answer the call. Not ideal but it works.

On an interesting note. The EZButton app chucks up a toast notification during the call ringing saying;

'Button (hardware)' mode

This seems to me the action its taking to grab control of the buttons off Android during a call ringing - this is something to go off for developers.

Also I was thinking but didn't have the will to test (especially after spending money on EZButton) to get a call replacement app from the staore - like Simple Call or something like that and see if it responds to Headset Button Controller attempting to answer the call.
[Nexus 4 General] IAmAN00bie:
Great work! Glad you found a workaround that can work for you!
[Nexus 4 General] Alex_GP:
Headset button controller offers the auto answer after x seconds option. This works without problems. Combine it with the announce caller (it announces the name of the contact calling you) and you get a pretty good workaround.

I listen to the name of the caller, if I don't want to answer, I just take out my phone and reject it. If I want to answer, I just let it ring for 10 seconds and then it will auto answer. Not perfect, but it's better than nothing.
[Nexus 4 General] privatesam:
Yeah the auto answer is fine but my set up is bicycle-centric - i.e. if I'm riding along and listening to a podcast and a call comes in and I don't want to take it its not possible to get phone out of my pocket to reject the call.

To be honest I have some fandroid hope that the Key Lime Pie will show such an improvement in Google Now that the fact it hijacks the long press will not matter because it will be able to do things like increase volume and skip tracks with voice commands effectively (somewhat like utter). But we'll see!
[Nexus 4 General] gennesys:
Unable to modify the files

Hello people. I am trying to modify the files but since they only have read permissions, I am unable to save the changes. I also tried to modify a copy and then to replace the originals but it did not work.

I am using ES File explorer... Any help will be appreciated!
[Nexus 4 General] IAmAN00bie:
I think there is an option in ES to set /system to read/write permissions.
[Nexus 4 General] austin1227:
What if key test is showing the press as an unknown button?
[Nexus 4 General] IAmAN00bie:
Hmmm, maybe you can see what number the app is seeing and look in the files yourself to see what action it corresponds to? What should it be intuitively?
[Nexus 4 General] austin1227:
It says 0... Probably cause it's unknown. But I don't have a nexus. I have a Verizon S3. And i don't have that second file, only the generic.

Would I try changing key 0?
[Nexus 4 General] Alex_GP:
Sorry for the late reply, but yes, the auto answer is not practical for a lot of people.

S2 on jelly bean is even more annoying : you can't start the music (single headset click) unless the screen is on. So if you pause the music to talk with someone for a few seconds or whatever, you have to power on the screen, press the headset button and then close the screen (or wait for the auto close).
[Nexus 4 General] Csapi007:
MW600 volume control

Hy

Finally I managed to hack my MW600 the way i've wated: I don't like the touch volume control that originally is on the MW600. Moreover that it uses a different volume scale, so that if your phone (BT media) volume set to very low from the last night when you went to bed, you can't max it out with just the MW600, because on your phone it will still be low, this sucks on the morning subway for example.

So I wanted to hack the prev/next button for volume control, using Android's scale.

So starting from IAmAN00bie's OP, through brotbuexe's post (#30) I managed to make it work.

I had to modify AVRCP.kl file, which is located in the usual /system/usr/keylayout folder, this file is responsible for the keylayout of BT devices.

Through the KeyTest app, I've learned that the MEDIA_PREVIOUS and MEDIA_NEXT buttons codes are 163 and 165. Not a big suprise the code of volume control is VOLUME_UP and VOLUME_DOWN. The last thing to do was editing the file, this is the final state:

Of course this disables the prev/next functionality, but I can still acces that through long press of the volume buttons on the phone.

However propably you could hack the middle button too, for example make it KEYCODE_HEATSETHOOK then you could customize it through some headset control app.
[Nexus 4 General] the_dark_destructor:
Answer/reject calls is still missing?

So there is not a solution/fix yet to enable answer/reject using this fix? :crying:

There is any way to get in touch with the HeadsetButton Controller developer to try to solve this issue?

Any good news is more than appreciated.
[Nexus 4 General] PrimozR:
I restored my backup, but i get a keycode_unknown message. Though the scan code is 226 for me, as it should be...

I was trying to hack together the double click skip functionaliy, that just wouldn't work with the Nexus headphones and Paranoid Android (any ideas why that would happen? I turned off the long press volume to skip, no difference...)
[Nexus 4 General] jsuarezcasana:
Hi Spinal

I'm having the exact same problem with another chinese phone, and also on 4.2.1

Sound comes low and full sound happens when pressing the button

Did you manage to fix the issue?
[Nexus 4 General] spinal2k:
Yep

But not with software... Get a ctia/omtp adapter and problem solved...

You can either get online, or check nokias and sony ericssons earpiece... They usually come with the adapter..
[Nexus 4 General] 530farm:
Thanks for the info
[Nexus 4 General] jsuarezcasana:
Thanks,

too bad I'm having a hard time find it on Ebay

will keep on looking

Cheers

Edit: Extra question, the adaptor lets the mic/button work? or it justs fixes the sound?

There a bunch of NO-INPUT adaptors and nobody bothers to say which standard they are

Thanks again
[Nexus 4 General] FeintDoxx:
This is awesome thanks man! Using my single button skullcandy headphones everything working fine:)
[Nexus 4 General] AndroidKills:
Stoked to try this, I was just wondering how I could make my singled-button headphones to change tracks. (SkullCandy too )

Sent from my Nexus⁴
[Nexus 4 General] FeintDoxx:
Its simple and using Headset Button Controller to map what the button does is perfect. Let us know how it goes
[Nexus 4 General] AndroidKills:
Results: so for sure I can skip tracks now, but the catch is either one click or two click it will skips tracks. I lost the ability to pause tracks

Sent from my Nexus⁴
[Nexus 4 General] FeintDoxx:
Just download Headset Button Controller and then you can map what the button does like so.

The problem posted in OP and my recommendation was also in the OP.
[Nexus 4 General] spinal2k:
I got mine on ecrater website

Fixes the sound ... On my Lenovo A789 the button worked to answer calls and pause the music but there are reports about other android phones where the button does nothing...

If you made changes on the button configration file on the mobile phome on attempts to make it work without the adapter, you need to have those changes reverted back to default (or factory reset the phone)
[Nexus 4 General] AndroidKills:
Woop Thanks! Turns out I was tuning the left button settings, but it was the right button settings.

This is awesome.

Sent from my Nexus⁴
[Nexus 4 General] FeintDoxx:
Yep. Ikr! Controlled is back in our hands. Well thumbs technically: p
[Nexus 4 General] Sld_Ultra:
Sorry for bumping old post.

Thank you for this, was wondering why the controls was never working with headset control apps. I edited both the Generic.kl and hs_detect.kl, it seems to work for the right settings controller in headset button controller app, but when using Smart key app I get no response. So I restored the files and just edited hs_detect.kl by adding these lines:

key 113 MUTE

key 114 VOLUME_DOWN

key 115 VOLUME_UP

key 163 MEDIA_NEXT

key 164 MEDIA_PLAY_PAUSE

key 165 MEDIA_PREVIOUS

I took a look at my htc sensation headset files and the h2w_headset.kl seemed to be the hs_detect.kl, so I added the extra lines and now seems I can use other headset control apps and the answer call works, but don't know how to end call so don't know if that work.
[Nexus 4 General] FeintDoxx:
Try headset controller. Its better. I think there's a lite version of it.
[Nexus 4 General] Dan Law 001:
Cannot find hs_detect.kl
[Nexus 4 General] Deathmehr:
Great guide! For a long time JB's greed over headphones was a dealbreaker for me. Up until this thread. For those of you who end up with 'keycode_unknown', check privileges of the two files. They must be 644 i.e consecutively [ rw, r, r ]
[Nexus 4 General] PJzzz:
Still a little confused. How do I get rid of google search comming up when long pressing my wired headset button?

I would like it to start Cyberon Voicespeed dial with a long press because it supports my language.

I don't wanna use any headset button control app to catch clicks.

Any suggestions on howto achieve this?
[Nexus 4 General] c9801120:
You have to give root permissions to ES File Explorer in superuser program and then, in ES File Explorer, you must hit "ROOT Explorer" continuously until It opens a menu, where you change his permissions to write the system files.
[Nexus 4 General] mymeatb18:
Tapping the words "root explorer" will open the menu after hitting the the switch to on
[Nexus 4 General] bhanumagotra:
is there any way of increasing the headset mic gain ?? when i use my SkullCandy Ink'2 with mic during a call , the person on other end hardly hears what i m saying.. ?? is there any value that can be increased or decreased ..

sorry if this seems as Off topic
[Nexus 4 General] pedro1977:
Updated: see below.
[Nexus 4 General] asciutto:
Thanks for the awesome guide! It worked out perfectly. I can now use Google Now as my voice search when my screen is locked instead of the annoying voice dialer.

Headset Button Control is the app I'm using and configuring it was a breeze! I'm using the generic 3-button iPod earbuds too. Sound quality isn't the best, but they're cheap and they work! That and I can't use those in-ear headphones.
[Nexus 4 General] pedro1977:
After further tweaking the best combo I could find was:

1. Install xposed framework.

2 - Change the key mapping manually.

3 - use headset button controller for track control, volume, dialler (voice command) and even Google now (launch app: Google) appears to be working too - screen will wake though temporarily - being in my pocket wasn't a problem though. When asked do not set either to wake (this sometimes unlocks the device ). Instead install the secure Google voice search xposed module and activate it.

3 - Install xposed additions modules for call answering and ending via mapping click and setting option.

I also tried the app open mic+ for Google now but there was too much clicking so this isn't ready for primetime yet. This opens Google now anytime via voice control somewhat similar to the Nexus 5.

Note: with headset controller you can have options to open both dialler and Google now by setting two different clicks.

KitKat 4.4.2
[Nexus 4 General] T-rex166:
HELP!!

It didn't work to me so I copy back the original files and now the headset button doesn't work at all.

someone please can give me a solution???
[Nexus 4 General] badbob001:
I was hoping this mod would return button control to me during a call but it doesn't. I'm looking for a wall to quickly mute/unmute the mic during a call but during a call, the button doesn't do anything! Outside of a call, it responds, but not during a call. Perhaps I need to hack my dialer/phone app somehow to return the button controls to me?

Galaxy s3, jelly bean / touchwiz.
[Nexus 4 General] player911:
Anyone have any suggestions on how to make those little Headphone Jack buttons work better:

I've been using Klick from the Play Store and it works but just really slow and not up to my expectations. Seems like a timings are just really slow.
[Nexus 4 General] mefistofelis:
any ideas?
[Nexus 4 General] marucchi:
i tried 2 different rom (lenovo A516)

first it shown as keycode_headsethook and scancode 358

second rom shows keycode_unknown and scancode 358 too

but in generic.kl key 358 said as key_info,but i can't using any headset control at all in second rom

how is this
[Nexus 4 General] joelstitch:
I was messing around with the Generic.kl file on my Samsung Galaxy Note 3 and now my Power, menu anc back button are not working. I changed the Generic.kl back to the original and restarted and still the same problem.

I ended up going back to a Nandroid and eventually tried it again and once again if I try to change back to the original Generic.kl file the Power, Back and Menu buttons stop working even if I restore the original Generic.kl file. How can I fix this?
[Nexus 4 General] HomerZZ:
can you re-upload the screenshot of the secon part of Generic.kl edited? (http://i.imgur.com/PPAZk.png)
[Nexus 4 General] jobrima:
Hi, I have a bluetooth device with three buttons (play, previous, next) and I can not reassign the buttons with any app, nor with this mod. What I want is to assign Google Voice Search any button. any ideas?
[Nexus 4 General] Deathmehr:
Up until Android 5 the guide has been working on every ROM on my N4 and N5.

Unfortunately, now that I'm on CM12 Nexus 5, modyfing the two files results in completely no button presses recognized.

Original files let me use click, double click and so on but NOT longpresses.

Any solution?
[Nexus 4 General] omar300:
Download link not working

If someone has this APK. Can you please make a mirror link and forward? Thanks
[Nexus 4 General] hkpgho:
my headset control worked well until i play a youtube video, so does this work?

btw your http://i.imgur.com/PPAZk.png link is broken
[Nexus 4 General] anil rajput:
hs_detect.kl not found in moto x play 7.1.1
[Nexus 4 General] sumitpanchal:
REPLY:-

"

my redmi 3s prime doesnot have the "hs_detect.kl" file.and the button test app gives me this result while i press the headphone button

keyCode=KEYCODE_UNKNOWN

scanCode=226

"
[Sony Xperia P, U, Sola, Go] madaimer:
Hey Guys

It seems that stupidity causes a lot of problems and that's what caused this one, so apologies in advance.

I recently got a Xperia S and flashed stable Cyanogen Mod 9.1

However due to a few small issues I was having I stupidly booted into CWM Recovery.

From here, not only did I wipe data and cache, but for some unknown reason I formatted the system partition.

Since this, I have been stuck at the Free Xperia Project logo.

I am able to boot into recovery, however when I try to flash the CM9 zip I get a Status 7 error..

I am also able boot into both fastboot and flashmode.

However when I try to use flashtool to flash a stock firmware I receive an error...

Furthermore, Flashtool does not recognise my device on either of my two PCs, even though I have installed all drivers from the flashtool foler, SUS, SPC and PdaNet. This requires me to select which device I just plugged into the PC manually in flashtool.

Sorry to be a massive pain (noob)

Any ideas and help would be greatly appreciated, thanks guys :)
[Sony Xperia P, U, Sola, Go] doctor_droid:
Use flashtool properly

Let flashtool prepare ftf press thunder icon etc etc....

When it asks u to connect ur phone

Then connect ur xs to usb wid volume down button pressed

---------- Post added at 12:00 PM ---------- Previous post was at 11:55 AM ----------

Dun connect ur phone to flashtool till it says so :D

I think u r trying to start phone in flashmode by holding the vol down key and power button

That's wrong

All u have to do is go tp flashtool

Click on thunder icon

select ftf

Flash

Flashtool will now ask u to connect ur phone

So

Simply connect ur Xperia s to usb with volume down button pressed

Flashtool will recognize it and start flashing in a second or two

Now leave the volume down button

And let flashing b complete
[Sony Xperia P, U, Sola, Go] madaimer:
I am using flashtool as you described.

The issue is that the firmware does not flash as seen by the error message I quoted.

Thanks for the help anyway, but im pretty sure im using the program correctly..
[Sony Xperia P, U, Sola, Go] doctor_droid:
I once got the same error when I tried to flash my phone

At that time I tried to enter flashmode first then connect it to pc

Bt the fact is u need to need to connect ur switched off xperia s only by keeping the volume down button pressed

I think I cant convey properly what I mean
[HTC Wildfire S] Khris40Anime:
I flashed a different ROM onto my phone it was cm9 and my data was working good and everything but I need to go back to stock rooted and when I went back on stock data wasent working anymore I have already tried restoring it with the latest MetroPCS RUU and no luck. Does anyone have a solution ? Or something that can help me out I'll appreciate it thanks