roligheten / AndroidMediaControlsWindows

Python script that hacks in support for Android headset media control support for Windows
GNU General Public License v3.0
45 stars 8 forks source link

Add support for B-D buttons #2

Open vmikhav opened 6 years ago

vmikhav commented 6 years ago

Headset circuit

ghost commented 3 years ago

Yup, was looking up how to have button support on pc/laptop. It worked on my bluetooth headset (although I can't do it when task manager is on for some reason), but it didn't work on my wired headset. Button is still recorded as sound, I think this has something to do with it.

PaperStrike commented 3 years ago

This is not possible by hardware. Although resistors between the buttons are different, the effect showed on waveform will be almost the same - pressing buttons cause unusually huge voltage difference compared to normal voice while our pc is designed to process normal voice only.

roligheten commented 3 years ago

Pretty sure it is indeed not possible to detect the different buttons using only the signal amplitude, but since I am not an electronics guy I am keeping this open until someone can give a good explanation why it is not. 🙂

PaperStrike commented 3 years ago

Somehow I found a distinguishable difference between normal voice and each buttons by the signal amplitudes today. 😅 What I said yesterday seems wrong.

By comparing the two channel of the mic, and draw a x-y graph: (Software I used here: Soundcard Oscilloscope)

While, each button's graph adds interference to the y = x with different amplitude. you may pay attention to the y-axis, especially values range [-0.045, -0.02].

  1. Button A's graph:

    ButtonA

  2. Button B's graph:

    ButtonB

  3. Button C's graph: (always above -0.045 on the left. I stress this to prove it is distinguishable from the normal voice.)

    ButtonC

My headset doesn't have a Button D. But I guess its graph is between Button A and B's, since its impedance is between theirs.

I'm not an expert in programming, hope these information does some help.

PaperStrike commented 3 years ago

Another finding by comparing the two channel of the mic: now we can easily tell a long press! 🎉

If we keep pressing a button, its graph would be like a ball:

ButtonPressing

We may check the the two channel continuously, counting the result of channel2 - channel1, and once the result becomes larger than a threshold, we can tell the press has start. when the absolute value of the result reach below the threshold for some time, the press has end. The largest result can tell which button is pressed, the duration can tell if it's a long press!

roligheten commented 3 years ago

@PaperFlu That's really cool! I haven't had time to look into this in detail but I will try to investigate it myself when I have time.