UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Call for help: Testing headset buttons

    Scheduled Pinned Locked Moved OS
    28 Posts 9 Posters 4.7k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • flohackF Offline
        flohack
        last edited by flohack

        Hi there,

        currently it seems we are not supporting headset buttons for wired and BT headsets. In a first spike I want to gather informations from different headset and phones.

        If you own a wired or BT headset with buttons, plz do the following:

        • Open a shell on your device
        • sudo mount / -o remount,rw
        • sudo apt update && sudo apt install evtest

        EDIT: It seems Bluetooth headsets might eventually already trigger the dialer and start doing something. Reports still welcome!

        This will install the evtest cmdline tool which will report various installed input devices. First, execute just that: evtest. You will get a list of potential input devices and a prompt to select one for testing.

        Now, go through that list and try the one that most likely sounds like it could be related to that buttons. Bluetooth devices will appear with their MAC address. Like this:

        Available devices:
        /dev/input/event0:      qpnp_pon
        /dev/input/event1:      sec_touchscreen
        /dev/input/event2:      proximity_sensor
        /dev/input/event3:      light_sensor
        /dev/input/event4:      accelerometer_sensor
        /dev/input/event5:      gyro_sensor
        /dev/input/event6:      magnetic_sensor
        /dev/input/event7:      gpio-keys
        /dev/input/event8:      msm8226-tapan-snd-card Ear Jack
        /dev/input/event9:      sec_jack
        

        Select the number corresponding to the entry, and then try to press the button and see if anything happens.

        In my case, I selected first event8, but that did not give any results, event9 was the right one.

        The result would look like this:

        Event: time 631.196568, -------------- SYN_REPORT ------------
        Event: time 631.207360, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 1
        Event: time 631.207524, -------------- SYN_REPORT ------------
        Event: time 631.335180, -------------- SYN_REPORT ------------
        Event: time 631.335239, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 0
        

        So that gives us the info that this key will trigger a KEY_MEDIA keypress event. Thats a useful information to later bind Lomiri, dialer etc to react on such a keypress properly. With this we could establish picking up the phone or ending a call properly.

        Plz answer to this thread with your test results, thanks!

        BR Florian

        My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

        mardyM 1 Reply Last reply Reply Quote 2
        • flohackF Offline
          flohack
          last edited by flohack

          Device: S3 Neo+ (s3ve3g), wired headset: Found working KEY_MEDIA event
          Device: Nexus 6P (angler), wired headset: Found working KEY_MEDIA event
          Device: Oneplus One (bacon), wired headset: Found working KEY_MEDIA event
          Device: Oneplus 5T (dumpling), wired headset: Found working KEY_MEDIA event
          Device: Fairphone 2 (FP2), wired headset: Did not send any event on any input driver

          My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

          1 Reply Last reply Reply Quote 0
          • flohackF Offline
            flohack
            last edited by

            Seems like many devices have a taiko-mtp-snd-card Button Jack which would be the right one to test...

            My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

            1 Reply Last reply Reply Quote 0
            • poVoqP Offline
              poVoq
              last edited by poVoq

              OnePlus3 wired headset:
              event7, three buttons:
              Pause button: code 226 (KEY_MEDIA)
              Vol up: code 115 (KEY_VOLUMEUP)
              Vol down: code 114 (KEY_VOLUMEDOWN)

              Tried some cheap bluetooth speakers, the call button triggers and in evtest a 8th event is added, but none of the buttons show any effect in evtest. I'll try with my car bluetooth later today.

              Fairphone 5 (waiting for port)

              1 Reply Last reply Reply Quote 0
              • CiberSheepC Offline
                CiberSheep
                last edited by CiberSheep

                Tested on: E5, Mx4
                SPORT-BT headphones (3 buttons)

                Event: time 1619297943.459023, type 1 (EV_KEY), code 165 (KEY_PREVIOUSSONG), value 1
                Event: time 1619297951.530449, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 1
                Event: time 1619298113.371200, type 1 (EV_KEY), code 200 (KEY_PLAYCD), value 1
                

                Tested on: E5, Mx4
                Netway Sport (3 buttons), i20 (car)
                None 😞

                Another planet, another time, another universe!

                1 Reply Last reply Reply Quote 0
                • K Offline
                  kugiigi
                  last edited by

                  I tried this on a Nexus 5 with wired and BT headsets, I don't get anything. Not sure if I'm doing it right πŸ˜… I just see Testing....interrupt to stop

                  rikR 1 Reply Last reply Reply Quote 0
                  • poVoqP Offline
                    poVoq
                    last edited by

                    On my car bluetooth kit with OnePlus3 I get:
                    code 163 (KEY_NEXTSONG)
                    code 165 (KEY_PREVIOUSSONG)

                    Fairphone 5 (waiting for port)

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      kugiigi
                      last edited by

                      This is on Lenovo M10 Plus FHD with Sony SBH24 BT headset. The system froze for a few moments when I pressed the first time but it registered them fine after that πŸ™‚
                      Lots of supported events but it only has one button - play/pause πŸ˜„
                      evtest.jpg

                      1 Reply Last reply Reply Quote 0
                      • poVoqP Offline
                        poVoq
                        last edited by poVoq

                        Any chance we will see working bluetooth buttons in the music player on the dev channel soon? Really looking forward to finally be able to fast forward songs in my car again πŸ˜‰

                        Fairphone 5 (waiting for port)

                        1 Reply Last reply Reply Quote 0
                        • mardyM Offline
                          mardy @flohack
                          last edited by mardy

                          Thanks @flohack for working on this! My test:

                          Wired headset with a single button, plugged into the BQ E4.5: the device appears as /dev/input/event1: ACCDET and reacts like this on button presses:

                          Event: time 1619503503.379042, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1
                          Event: time 1619503503.379054, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0
                          Event: time 1619503503.379059, -------------- SYN_REPORT ------------
                          

                          The same headset is seen on the Xiaomi Note 7 Pro as /dev/input/event4: sm6150-idp-snd-card Button Jack and sends these two events on button press:

                          Event: time 1619504074.039626, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 1
                          Event: time 1619504074.039626, -------------- SYN_REPORT ------------
                          Event: time 1619504074.039777, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 0
                          Event: time 1619504074.039777, -------------- SYN_REPORT ------------
                          
                          1 Reply Last reply Reply Quote 0
                          • flohackF Offline
                            flohack
                            last edited by

                            Thanks guys!
                            Already a lot of good information. So the wired buttons it seems a bit easier, not so many variants:

                            1. KEY_MEDIA and KEY_PLAYPAUSE need to be handled for media playback and calls
                            2. we can agree that the meaning is PLAY or PAUSE, also for the MEDIA event
                            3. In case Music is playing it will pause the music, or continue playback if state is PAUSE
                            4. In case a call is signalled, the button should only pick up the call. Media playback will already be stopped by the telephony framework.
                            5. In case a call is active, the button should only end the call. Media playback will already be started again by the telephony framework.

                            My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                            poVoqP 1 Reply Last reply Reply Quote 2
                            • poVoqP Offline
                              poVoq @flohack
                              last edited by

                              @flohack Cool, although bluetooth seems not too different either.

                              On my wired headset and the Oneplus3 I also noticed evtest events on a different device for plugging in the headset and removing it from the headset socket. I guess that would also be useful to support in the music player?

                              Fairphone 5 (waiting for port)

                              flohackF 1 Reply Last reply Reply Quote 0
                              • flohackF Offline
                                flohack @poVoq
                                last edited by

                                @povoq That should be the events that switch the audio sink to the headset. That should already be handled properly otherwise you would not hear anything πŸ˜‰

                                My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                                poVoqP 1 Reply Last reply Reply Quote 0
                                • poVoqP Offline
                                  poVoq @flohack
                                  last edited by

                                  Ah, I guess. Sometimes it seems to get confused though switching away from bluetooth devices etc.

                                  Fairphone 5 (waiting for port)

                                  1 Reply Last reply Reply Quote 0
                                  • Mario.CHM Offline
                                    Mario.CH
                                    last edited by

                                    Device Sony Xperia X (F5121)
                                    When plugging in the original Inears headset <MHA750>, the volume control changes from speaker to earphone, then drops right back to speaker after about 1.5 seconds.

                                    I tried the evtest anyway with the following 2 results, not sure if they are helpful. Because nothing really happened during the test run, not until I opened the <write to file> file to see what happened.

                                    Available devices:
                                    /dev/input/event0:	qpnp_pon
                                    /dev/input/event1:	bu520x1nvx
                                    /dev/input/event2:	somc_chg_unplug_key
                                    /dev/input/event3:	gpio-keys
                                    /dev/input/event4:	clearpad
                                    /dev/input/event5:	msm8976-tasha-snd-card Headset Jack
                                    /dev/input/event6:	msm8976-tasha-snd-card Button Jack
                                    Select the device event number  [0-6]: 6
                                    Input driver version is 1.0.1
                                    Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
                                    Input device name: "msm8976-tasha-snd-card Button Jack"
                                    Supported events:
                                      Event type 0 (EV_SYN)
                                      Event type 1 (EV_KEY)
                                        Event code 114 (KEY_VOLUMEDOWN)
                                        Event code 115 (KEY_VOLUMEUP)
                                        Event code 226 (KEY_MEDIA)
                                        Event code 260 (BTN_4)
                                        Event code 261 (BTN_5)
                                        Event code 582 (KEY_VOICECOMMAND)
                                    Properties:
                                      Property type 6 (?)
                                    Testing ... (interrupt to exit)
                                    
                                    second test
                                    <dito>
                                    Select the device event number  [0-6]: 5
                                    Input driver version is 1.0.1
                                    Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
                                    Input device name: "msm8976-tasha-snd-card Headset Jack"
                                    Supported events:
                                      Event type 0 (EV_SYN)
                                      Event type 5 (EV_SW)
                                        Event code 2 (SW_HEADPHONE_INSERT) state 0
                                        Event code 4 (SW_MICROPHONE_INSERT) state 0
                                        Event code 6 (SW_LINEOUT_INSERT) state 0
                                        Event code 7 (SW_JACK_PHYSICAL_INSERT) state 0
                                        Event code 15 (?) state 0
                                        Event code 16 (?) state 0
                                        Event code 17 (?) state 0
                                        Event code 18 (?) state 0
                                    Properties:
                                    Testing ... (interrupt to exit)
                                    
                                    Event: time 1619464909.762451, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 1
                                    Event: time 1619464909.762451, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 1
                                    Event: time 1619464909.762451, type 5 (EV_SW), code 7 (SW_JACK_PHYSICAL_INSERT), value 1
                                    Event: time 1619464909.762451, type 5 (EV_SW), code 17 (?), value 1
                                    Event: time 1619464909.762451, -------------- SYN_REPORT ------------
                                    Event: time 1619464910.860134, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 0
                                    Event: time 1619464910.860134, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 0
                                    Event: time 1619464910.860134, type 5 (EV_SW), code 7 (SW_JACK_PHYSICAL_INSERT), value 0
                                    Event: time 1619464910.860134, type 5 (EV_SW), code 17 (?), value 0
                                    Event: time 1619464910.860134, -------------- SYN_REPORT ------------
                                    Event: time 1619464946.781515, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 1
                                    Event: time 1619464946.781515, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 1
                                    Event: time 1619464946.781515, type 5 (EV_SW), code 7 (SW_JACK_PHYSICAL_INSERT), value 1
                                    Event: time 1619464946.781515, type 5 (EV_SW), code 17 (?), value 1
                                    Event: time 1619464946.781515, -------------- SYN_REPORT ------------
                                    Event: time 1619464952.772939, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 0
                                    Event: time 1619464952.772939, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 0
                                    Event: time 1619464952.772939, type 5 (EV_SW), code 7 (SW_JACK_PHYSICAL_INSERT), value 0
                                    Event: time 1619464952.772939, type 5 (EV_SW), code 17 (?), value 0
                                    
                                    

                                    Is this helpful ?

                                    πŸ“± Oneplus Nord N100 UT20.40 (OTA5); then Xperia X (since 2020) at last UT 20.04(OTA5), now out of service due to defective camera
                                    🐎 When you realize you are riding a dead horse, get off!
                                    My languages skill: πŸ‡¨πŸ‡­πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ, and only orally: πŸ‡¬πŸ‡§ πŸ‡ΉπŸ‡­

                                    flohackF 1 Reply Last reply Reply Quote 1
                                    • flohackF Offline
                                      flohack @Mario.CH
                                      last edited by

                                      @mario-ch Well partially, but normally the evdev for inserting and removing headsets is different from the button control. So with the button device nothing happened? I guess that would be the right one...

                                      My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                                      Mario.CHM 1 Reply Last reply Reply Quote 0
                                      • Mario.CHM Offline
                                        Mario.CH @flohack
                                        last edited by

                                        @flohack So, I now played a song as a comparison and plugged in the Inears headset.
                                        The Jack has switched from speaker to earphone and I could hear the music, but the volume buttons did not work.
                                        In addition, the Evtest with <6>; with the same result as above (first test), namely nothing.

                                        πŸ“± Oneplus Nord N100 UT20.40 (OTA5); then Xperia X (since 2020) at last UT 20.04(OTA5), now out of service due to defective camera
                                        🐎 When you realize you are riding a dead horse, get off!
                                        My languages skill: πŸ‡¨πŸ‡­πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ, and only orally: πŸ‡¬πŸ‡§ πŸ‡ΉπŸ‡­

                                        1 Reply Last reply Reply Quote 0
                                        • ? Offline
                                          A Former User
                                          last edited by

                                          I'm a bit late, but here's my version of events:

                                          Devices:
                                          Cosmo Communicator
                                          PinePhone Rev1.2b

                                          Headsets:
                                          3 different sets of wired headsets, one with 3 buttons, one with 2 buttons, one with 1 button

                                          On the Cosmo, selecting:
                                          '/dev/input/event0: ACCDET'

                                          For all buttons on all headsets I get:
                                          type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0
                                          -------------- SYN_REPORT ------------
                                          type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1
                                          -------------- SYN_REPORT ------------

                                          There were 'Event code 114 (KEY_VOLUMEDOWN)' and 'Event code 115 (KEY_VOLUMEUP)' amongst other things listed in the 'Supported events' list, but I didn't see them on any button press.

                                          On the PinePhone, after entering 'evtest' I got no 'Available devices', after entering 'sudo evtest' I got some choices, but none gave any response.

                                          1 Reply Last reply Reply Quote 0
                                          • c4pp4C Offline
                                            c4pp4
                                            last edited by

                                            Device: Xiaomi Mi A2
                                            Wired USB earphones with three buttons: Mi Dual Driver Earphones (Type-C) (https://www.amazon.de/XIAOMI-Kopfhârer-Weiß-Audio-Stecker/dp/B07MLRXJBC)

                                            Available devices:
                                            /dev/input/event0:      qpnp_pon
                                            /dev/input/event1:      NVTCapacitiveTouchScreen
                                            /dev/input/event2:      uinput-goodix
                                            /dev/input/event3:      hall-switch-input
                                            /dev/input/event4:      gpio-keys
                                            /dev/input/event5:      sdm660-snd-card Headset Jack
                                            /dev/input/event6:      sdm660-snd-card Button Jack
                                            /dev/input/event7:      uinput-fpc
                                            Select the device event number [0-7]: 6
                                            Input driver version is 1.0.1
                                            Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
                                            Input device name: "sdm660-snd-card Button Jack"
                                            Supported events:
                                              Event type 0 (EV_SYN)
                                              Event type 1 (EV_KEY)
                                                Event code 114 (KEY_VOLUMEDOWN)
                                                Event code 115 (KEY_VOLUMEUP)
                                                Event code 226 (KEY_MEDIA)
                                                Event code 260 (BTN_4)
                                                Event code 261 (BTN_5)
                                                Event code 582 (KEY_VOICECOMMAND)
                                            Properties:
                                              Property type 6 (?)
                                            Testing ... (interrupt to exit)
                                            Event: time 1620770065.854970, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
                                            Event: time 1620770065.854970, -------------- SYN_REPORT ------------
                                            Event: time 1620770065.855140, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
                                            Event: time 1620770065.855140, -------------- SYN_REPORT ------------
                                            Event: time 1620770067.377695, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 1
                                            Event: time 1620770067.377695, -------------- SYN_REPORT ------------
                                            Event: time 1620770067.377772, type 1 (EV_KEY), code 226 (KEY_MEDIA), value 0
                                            Event: time 1620770067.377772, -------------- SYN_REPORT ------------
                                            Event: time 1620770068.851389, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
                                            Event: time 1620770068.851389, -------------- SYN_REPORT ------------
                                            Event: time 1620770068.851508, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
                                            Event: time 1620770068.851508, -------------- SYN_REPORT ------------
                                            
                                            poVoqP 1 Reply Last reply Reply Quote 0
                                            • poVoqP Offline
                                              poVoq @c4pp4
                                              last edited by

                                              @c4pp4 Ah, cool, so USB headset audio is already supported? That would be nice to add to the button support as well.

                                              Fairphone 5 (waiting for port)

                                              flohackF 1 Reply Last reply Reply Quote 0
                                              • First post
                                                Last post