KEYCODE for headset button press

1,932 views
Skip to first unread message

Porting beginner

unread,
Feb 18, 2010, 2:39:46 PM2/18/10
to android-d...@googlegroups.com, android...@googlegroups.com, android...@googlegroups.com
Hi,

I am trying from few days but don't get any information related to issue as below.

Which  KEYCODE to send to input dev ( /dev/input/event2 here ) on headset button press event from my
headset driver so can answer / hang-up call ?

Please let me know if I am missing something here.

--
Thanks

Chris Stratton

unread,
Feb 19, 2010, 2:07:35 PM2/19/10
to Android Linux Kernel Development
On Feb 18, 2:39 pm, Porting beginner <porting.begin...@gmail.com>
wrote:

> Hi,
>
> I am trying from few days but don't get any information related to issue as
> below.
>
> Which  KEYCODE to send to input dev ( /dev/input/event2 here ) on headset
> button press event from my
> headset driver so can answer / hang-up call ?

Please see arch/arm/mach-msm/htc_headset.c which says in part:

Button presses are interpreted as input event (KEY_MEDIA). Button
presses
are ignored if the headset is plugged in, so the buttons on 11 pin
-> 3.5mm
jack adapters do not work until a headset is plugged into the
adapter. This
is to avoid serial RX traffic causing spurious button press
events.

Also I don't think you want to inject it into the event file
yourself:

static void button_pressed(void)
{
printk(KERN_INFO "[H2W] button_pressed\n");
atomic_set(&hi->btn_state, 1);
input_report_key(hi->input, KEY_MEDIA, 1);
input_sync(hi->input);
}

You will also want to read Documentation/input/input-programming.txt

Finally you might want to learn about the -R flag to grep ;-)

Karthik Kannappan

unread,
Feb 19, 2010, 4:06:34 PM2/19/10
to android...@googlegroups.com
Look at AVRCP.kl in development/emulator/keymap:
key 164   MEDIA_PLAY_PAUSE    WAKE
key 128   MEDIA_STOP          WAKE
key 163   MEDIA_NEXT          WAKE
key 165   MEDIA_PREVIOUS      WAKE
key 168   MEDIA_REWIND        WAKE
key 159   MEDIA_FAST_FORWARD  WAKE



Porting beginner

unread,
Feb 19, 2010, 4:18:02 PM2/19/10
to android...@googlegroups.com
On Fri, Feb 19, 2010 at 1:06 PM, Karthik Kannappan <kannappa...@gmail.com> wrote:
Look at AVRCP.kl in development/emulator/keymap:
key 164   MEDIA_PLAY_PAUSE    WAKE
key 128   MEDIA_STOP          WAKE
key 163   MEDIA_NEXT          WAKE
key 165   MEDIA_PREVIOUS      WAKE
key 168   MEDIA_REWIND        WAKE
key 159   MEDIA_FAST_FORWARD  WAKE

Ok guys, I think I didn't put my question in right way, let me try again.

I have all these details and its working as below.

case 1; With KEYCODE_CALL, I can answer incoming call by pressing my headset button.
case 2: With KEYCODE_ENDCALL , i can end the call by pressing my headset button.

But as I have headset with one button, I can report only one keycode at a time , either KEYCODE_CALL or KEYCODE_ENDCALL
and not both.

My goal is that no matter whats the phone status, in-call or not, when I press button, it would take proper action, take a call or end call if already in-call.

If you have two button on headset, you can give CALL or ENDCALL for each button and it would be fix and dedicated.
i.e press button1 to receive call, press button2 to end call
But with only one button, how you do this ? Is that needed to add this toggle logic in android framework ?
is this logic already implemented in Android framework ?

Again, my goal is
Headset with one button, is that anything headset driver can do to implement above logic or its should only taken care in framework ?





 



--
Thanks

Porting beginner

unread,
Feb 20, 2010, 1:00:00 AM2/20/10
to android...@googlegroups.com, android-...@googlegroups.com, android...@googlegroups.com
On Fri, Feb 19, 2010 at 1:18 PM, Porting beginner <porting....@gmail.com> wrote:


On Fri, Feb 19, 2010 at 1:06 PM, Karthik Kannappan <kannappa...@gmail.com> wrote:
Look at AVRCP.kl in development/emulator/keymap:
key 164   MEDIA_PLAY_PAUSE    WAKE
key 128   MEDIA_STOP          WAKE
key 163   MEDIA_NEXT          WAKE
key 165   MEDIA_PREVIOUS      WAKE
key 168   MEDIA_REWIND        WAKE
key 159   MEDIA_FAST_FORWARD  WAKE

Ok guys, I think I didn't put my question in right way, let me try again.

I have all these details and its working as below.

case 1; With KEYCODE_CALL, I can answer incoming call by pressing my headset button.
case 2: With KEYCODE_ENDCALL , i can end the call by pressing my headset button.

But as I have headset with one button, I can report only one keycode at a time , either KEYCODE_CALL or KEYCODE_ENDCALL
and not both.

My goal is that no matter whats the phone status, in-call or not, when I press button, it would take proper action, take a call or end call if already in-call.

If you have two button on headset, you can give CALL or ENDCALL for each button and it would be fix and dedicated.
i.e press button1 to receive call, press button2 to end call
But with only one button, how you do this ? Is that needed to add this toggle logic in android framework ?
is this logic already implemented in Android framework ?

Again, my goal is
Headset with one button, is that anything headset driver can do to implement above logic or its should only taken care in framework ?




Hi ,

I have resolved this issue with code change in PhoneWindowManager.java in Android framework.
Here for KEYCODE_CALL, I have added condition to check, whether already in-call or not.
If already in-call, on this event, end the incoming call otherwise answer the incoming call.

This toggle logic works for me, now I can have same headset button sending one key map with KEYCODE_CALL and I can either
answer or end the incoming call my pressing same button.

I think this should be part of framework itself or someone should add this condition to make this generic feature works.
Can I submit this as a patch for Android ?

 



--
Thanks

Reply all
Reply to author
Forward
0 new messages