Have you checked if an issue already exists for this feature request?
What feature would you like added?
Sorry if this is terse, I lost a long earlier draft of this:
Expert mode has access to adb shell, and thus builtin tools such as logcat and grep. There should be a special Key Mapper trigger type (similar to floating buttons) that can utilize these tools.
This would allow for responding to headset buttons such as KEYCODE_[PLAY/PAUSE/NEXT/PREVIOUS]. For example:
adb shell 'logcat -T "$(date +"%s.%N")" MediaSessionService:D' | adb shell grep 'callingPackage:com.android.bluetooth.*KEYCODE_MEDIA'| grep -vi com.termux
This runs in Termux, but could be converted to Key Mapper by removing the instances of adb shell and the extra quoting needed for the subshell. Some notes:
logcat -T streams new events starting at a specific time.
$(date +"%s.%N") gets the time that it is right now and outputs it in a format that logcat -T can use (though it's not the only format it can use)
MediaSessionService:D is the log component that contains KEYCODE_MEDIA* events. D is the debug priority which I've found is the least verbose priority that still contains the events
grep 'callingPackage:com.android.bluetooth.*KEYCODE_MEDIA allows us to filter KEYCODE_MEDIA events that originate from a bluetooth device, as opposed to software media buttons of media app, e.g. VLC. USB devices would probably need a different regex.
grep -vi com.termux remove lines originating from Termux itself, which would get reported by logcat from previous executionof this command.
Using adb shell in a trigger would also probably solve another cool idea: #1696
App version
4.0.5 247
Device model and manufacturer
Galaxy S22
Extra info
Have you checked if an issue already exists for this feature request?
What feature would you like added?
Sorry if this is terse, I lost a long earlier draft of this:
Expert mode has access to adb shell, and thus builtin tools such as logcat and grep. There should be a special Key Mapper trigger type (similar to floating buttons) that can utilize these tools.
This would allow for responding to headset buttons such as KEYCODE_[PLAY/PAUSE/NEXT/PREVIOUS]. For example:
This runs in Termux, but could be converted to Key Mapper by removing the instances of
adb shelland the extra quoting needed for the subshell. Some notes:logcat -Tstreams new events starting at a specific time.$(date +"%s.%N")gets the time that it is right now and outputs it in a format that logcat -T can use (though it's not the only format it can use)MediaSessionService:Dis the log component that contains KEYCODE_MEDIA* events. D is the debug priority which I've found is the least verbose priority that still contains the eventsgrep 'callingPackage:com.android.bluetooth.*KEYCODE_MEDIAallows us to filter KEYCODE_MEDIA events that originate from a bluetooth device, as opposed to software media buttons of media app, e.g. VLC. USB devices would probably need a different regex.grep -vi com.termuxremove lines originating from Termux itself, which would get reported by logcat from previous executionof this command.Using adb shell in a trigger would also probably solve another cool idea: #1696
App version
4.0.5 247
Device model and manufacturer
Galaxy S22
Extra info