I know that some devices headphone ports (maybe all of them? any reference here would be good) have 3 channels, for stereo sound and microphone. So I was wondering if it's possible to detect something like this pedal on these devices.
If it's possible, using the audio recorder would be enough? I'm studying possibilities for an app here, and this sounds promising if possible.
Thanks
EDIT
I was searching more about it and I was wondering if the pedal would have the same effect as those headsets with buttons. It's deadly easy to override their effects, I created a simple app that does it and now I'm waiting for my pedal to try. Any thoughts about it ?
UPDATE
I just tried it in the pedal and it doesn't work. Although we managed to use the pedal to pause a music app. The device was running Cyanogen though. The voice recorder also didn't detect anything on the key press. Need suggestions on how to detect it :).
UPDATE
AS the bounty is about to expire, a minor update. The last link provided by @Nick.T got some helpful info but I'm still not able to create a sample to detect the pedal. So I made a small change on the title question, and any guidance on that direction would be very much appreciated!
It's not clear if this will work without having the actual hardware in my hands, but... Don't plug the jack all the way into the socket. The tip of the jack should then connect to pin 2, left audio out, of this diagram: http://pinoutsguide.com/CellularPhones-P-W/samsung_galaxy_headset_pinout.shtml and the ring should connect to pin 3, microphone in. If you push the jack all the way in, the ground pin on the jack shorts out the microphone input and you won't detect anything - pictures at https://en.wikipedia.org/wiki/File:Photo-audiojacks.jpg show how the connections will mate.
Play some audio out the Left channel, record it on the mic channel, and measure the amplitude. That may - if it's all wired up right - tell you the pedal position. If the far end of the potentiometer is connected to the ring of the jack, that's not going to work.
That all sounds rather Heath Robinson. You could buy an inline 3-pin female jack socket and a 4-pin male jack plug and wire the two together to get whatever pinout you need. No electronics; just connectors and bits of wire! Or use a cable like this one: http://www.ebay.co.uk/itm/1mt-3-5mm-4-Pin-Jack-Male-Plug-4-Pole-Jack-female-Socket-Extension-Lead-Cable-/251172651017?pt=UK_Computing_Sound_Vision_Audio_Cables_Adapters&hash=item3a7b0e8009&_uhb=1 and a sharp knife and some stickytape.
The other problem would come if the phone refuses to send audio to the jack when the jack isn't plugged fully home - there's an extra contact in the socket that detects that mechanically. But it would work if you made 3-pin to 4-pin adapter.
Or, just cut the 3.5mm jack off your (shiny new) expression pedal. Replace it with the 4-pin connector off one of those broken phone headsets you have lying around.