[APP] Button Mapper - Customize your hardware buttons

Search This thread

flar2

Recognized Developer
Jun 11, 2012
18,897
87,868
Southwestern Ontario
elementalx.org
Hello @flar2 . Is the Broadcast intent feature can broadcast intents in all android app or just system apps?

I have tried to broadcast intent Setting (Action: android.settings.SETTINGS) with ButtonMapper and it seem to work. Wondering if this can work on all android app by specifying the package name?

So I currently have an app/android service that need an intent to run. Here's the Service Intent log:

ServiceRecord{2b0461 u0 com.necra.aswitch/.SwitchService}
intent={act=com.necra.aswitch.SWITCH cmp=com.necra.aswitch/.SwitchService}
packageName=com.necra.aswitch
processName=com.necra.aswitch

and I tried to start that same Intent using ButtonMapper with
Action: com.necra.aswitch.SWITCH
Package name: com.necra.aswitch
Componen: com.necra.aswitch/.SwitchService

and I tried with other combinations as well but doesnt seem working
When I try Start as activity, it says Not Available
Maybe other apps aren't allowed to send that intent, it has to be labelled public. There are a lot of restrictions on this in the past couple versions of Android. Try sending the intent in adb shell and see if it works that way.
 

dnecra

New member
Mar 21, 2024
3
0
Maybe other apps aren't allowed to send that intent, it has to be labelled public. There are a lot of restrictions on this in the past couple versions of Android. Try sending the intent in adb shell and see if it works that way.
That makes sense. I'll try to do it in adb shell way, and maybe find another workarounds.
Thanks for the reply. The app is great by the way!
 

dnecra

New member
Mar 21, 2024
3
0
Just a reminder that you can use Shizuku to enable lots of things in Button Mapper without connecting to a PC. I'm still getting tons of complaints about adb, please use Shizuku.
Yes. I have Shizuku running and also did the First Setup on PC (hopefully using this both method doesnt conflict) but so far I got everything I need working great. I figured how to send HTTP Request (so good to know this feature is working on my Android 14). But the Shell command turns out to be toybox command, I have no idea what it is. But is it possible to run adb shell command with this? I have unrooted Android 14 + Shizuku

Also would love an example of how to use Broadcast intent, that would be very nice.

Again, great app!
 

fcallmade

New member
Mar 27, 2024
1
0
Hi, first time user here!

The application is great, but I need help for a very specific problem: I bought a Bluetooth Remote Shutter with a button that I intend to remap to activate smart home functions through Tasker.

I manage to setup everything as intended, and used the Button Mapper Pro to remap the button to "D-pad center". However, the signal emitted by the shutter is the command "VolumeUp (24)", and that is the only command Tasker recognizes.

Functions for Tasker provided by the app such as buttonmapper.VOLUP_SINGLE_TAP, buttonmapper.VOLUP_DOUBLE_TAP, and buttonmapper.VOLUP_LONG_PRESS don't work - I tried adding the long press or the double tap, but Tasker only understands it as a single tap.

The goal is to not let accidental taps in the button turn on my TV.

Can you please point me to a direction where I long press the shutter and properly activate the right task?
 

DwightTwiss

New member
Mar 28, 2024
1
0
Hi. I'm using a eink reader which only have a captive return button.
I wonder if I can remap it to simulate dpad input for flipping pages?
I looked up and found dpad left and right is coded as "keyevent 21&22" as adb input command, how to register that? The "shell" option in button mapper didn't recognize the code.
Would you please instruct me?
With regard.
 

Andrew Lin

Senior Member
Jan 19, 2013
186
36
Sony Xperia 1 III
Sony Xperia 5 IV
The desired behavior could
Probably not, as remapping is not possible while the screen is off. An action can be triggered, but the original function can't be overridden.

I would suggest using the dedicated skip track options, single and double press are available.
The desired long press to skip can be achieved by macrodroid without any issue. Maybe you could look into it 😉 thanks
 

flar2

Recognized Developer
Jun 11, 2012
18,897
87,868
Southwestern Ontario
elementalx.org
The desired behavior could

The desired long press to skip can be achieved by macrodroid without any issue. Maybe you could look into it 😉 thanks


Button Mapper does in fact offer complete remapping while the screen is off, I just disabled it on certain Samsung devices because the button presses are only detected while music is playing and not while the phone is in deep sleep. This was confusing to users, as skipping tracks is only one of many possible actions, leading to negative reviews, so I dropped it. On non-Samsung devices you can do anything with the screen off, even in deep sleep, and Button Mapper is the only app out there that can do that. I added those dedicated skip track options as a convenience using another very simple method. I could technically expand them to handle long press too, but it would just add a lot of complexity. I mean I could just keep adding stuff until Button Mapper is essentially Tasker, but then Button Mapper would no longer be the simple and light app that has been successful.
 
  • Like
Reactions: coolhof

Evillkittie

New member
Apr 3, 2024
3
0
I ran into a minor annoyance
I have a Samsung S10e
Using black media player (free version)
Phone seems to kill player when paused
Player can not be launched using mapper while screen is off
Player shortcuts does not include a play option... i just want to hit play, i do not want a playlist, the library is my playlist

Workaround:
short press is set to toggle media
double press is set to open app, only works if screen must be on
Hitting play takes 4 button presses (power button, double click, single click)

I know the mapper is working while the screen is off as long press is set to flash light

Well i bet a shell script would make it one click...
So I make and test a shell script and it works over adb, maybe i will need a line to turn the screen on

Now here is my issue with the app, all 4 buttons on the unblock all features screen do not work, no error message, no nothing *Me pressing buttons*
BTW this is NOT a issues in appdash or devcheck

Bash:
#!/system/bin/sh

# Black Player media playback toggle script
# Tested on Samsung S10e SM-970U
# Phone kills player when paused
#  1. To work around this check if media playback state
#  2. Start player if needed and allow time for it to open
#  3. Toggle media play state

# Get a line of text that can be used to identy if media is playing
media_state="$(dumpsys media_session|grep 'state=PlaybackState')"

# -z = null
# -n = not null

if [ -z "$media_state" ];then
    # Player not running

    #input keyevent KEYCODE_WAKEUP # may need this, maybe i will need to use event 26

    # Free version
    am start -n com.musicplayer.blackplayerfree/com.kodarkooperativet.blackplayerfree.activities.ViewPagerActivity

    # Paid version
    #am start -n com.kodarkooperativet.blackplayerex/com.kodarkooperativet.blackplayerex.activities.ViewPagerActivity

    sleep 0.5 # It would technically be better to get the media state again and retest, but this is easier
    input keyevent 126 # Play media
elif [ -n "$(echo \"$media_state\" | grep 'state=2')" ];then
    # Player paused
    input keyevent 126 # Play media
elif [ -n "$(echo \"$media_state\" | grep 'state=3')" ];then
    # Player playing
    input keyevent 127 # Pause media
else
    # Debug - Unknown state:
    echo "$media_state"
fi
exit 0

BTW would it be possible to detect input from the finger print sensor on the power button as if it were a button, the app does not detect it as a option
 

Attachments

  • Screenshot_20240403-120045_Button Mapper.png
    Screenshot_20240403-120045_Button Mapper.png
    98.7 KB · Views: 4
Last edited:

Evillkittie

New member
Apr 3, 2024
3
0
flar2 did you read the bold part in the middle of my post [2,789]? hopefully you can get that bug fixed... you know cause a paywall that will not accept money is a bit of a problem...
 

flar2

Recognized Developer
Jun 11, 2012
18,897
87,868
Southwestern Ontario
elementalx.org
flar2 did you read the bold part in the middle of my post [2,789]? hopefully you can get that bug fixed... you know cause a paywall that will not accept money is a bit of a problem...
Do you have the latest version 3.22?

Old versions do not work for payment due to changes in the billing library

Otherwise it's a Google problem because I have the same billing implementation in all my apps, and it works as well as it can. Google forces me to use their payment and licensing system and it's complete garbage.
 

Evillkittie

New member
Apr 3, 2024
3
0
3.22, just got the device on 3/30, so it is a recent install, again all your other apps it works and the buttons bring up the payment card list

know a way i can get console debug output info via adb?

Screenshot_20240408-125937_Button Mapper.png
 
Last edited:

121GWJolt

New member
Apr 19, 2024
1
0
Hello! Love the app; I've made extensive use of it.

I have a Samsung Galaxy XCover6 Pro and I was trying to map its buttons, but was unable to do so with the app using the "Add Buttons" feature. Using DevCheck, I've confirmed that the "XCover Button" (the side button) just comes in as KeyCode 1015, and the "Top Button" comes in as KeyCode 1079. Is there any way for these buttons to be available to map in the program? I've confirmed that they fire off keycodes even if no functions are assigned to them in system settings at a given time.

If there's any further information I can provide to enable this to happen, please let me know.

Thank you again for making such a great app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    The desired behavior could

    The desired long press to skip can be achieved by macrodroid without any issue. Maybe you could look into it 😉 thanks


    Button Mapper does in fact offer complete remapping while the screen is off, I just disabled it on certain Samsung devices because the button presses are only detected while music is playing and not while the phone is in deep sleep. This was confusing to users, as skipping tracks is only one of many possible actions, leading to negative reviews, so I dropped it. On non-Samsung devices you can do anything with the screen off, even in deep sleep, and Button Mapper is the only app out there that can do that. I added those dedicated skip track options as a convenience using another very simple method. I could technically expand them to handle long press too, but it would just add a lot of complexity. I mean I could just keep adding stuff until Button Mapper is essentially Tasker, but then Button Mapper would no longer be the simple and light app that has been successful.
  • 148
    p2142635636.jpg



    Button Mapper allows you to remap any action you want to physical or capacitive hardware buttons. This includes volume buttons, camera button, home button on Samsung devices and capacitive home, back and recents, Bixby, Active Edge, LG assistant button and many buttons on game controllers and other hardware. It does NOT work with onscreen home, back and recents buttons (i.e. soft keys or the navigation bar).

    You can launch shortcuts, apps or actions to single press, double tap and long press for hardware buttons.





    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    Limitations:
    -does not work when the screen is off (unless rooted)
    -only works with hardware buttons, not onscreen buttons (i.e. navigation bar)
    -power button cannot be modified
    -there can be quirks with some devices due to non-standard hardware and software implementations by various manufacturers. I try to fix them, but sometimes it's difficult if I don't have the device to test.




    .
    32
    Examples of things you can do with this app:

    -Lockscreen peek: press and hold the home button to quickly check your lockscreen messages, release to turn off the screen (requires PRO VERSION)
    -Launch an app by long pressing the home button
    -Swap the back and recents buttons (capacitive buttons only, like on Samsung Galaxy or Asus Zenfone or One Plus One)
    -Use the home button to the turn the screen off from the homescreen on your Samsung Galaxy (requires PRO VERSION)
    -Control the button lights on your Samsung Galaxy. Turn them on or off, or change the length of time they light up
    18
    Big update!


    After many weeks of work, I've released an update that adds many new features and improvements, and fixes some longstanding bugs.

    The new version is rolling out to a small number of users on the Google Play Store.
    You can download the new version now on XDA Labs.



    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    Pixel 2 Active Edge
    The Pixel 2 battery drain was caused by remapping Active Edge with root and not enabling screen off actions. It has nothing to do with the method that I use to remap the Edge squeeze, it was caused by a typo in the options logic. There are a lot of myths about how this app handles Active Edge. First of all, it does not consume battery and does not slow down your system. Such claims are false (notwithstanding the bug, which is now fixed). The method for remapping Active Edge does not scan through every logcat message. With root, it's 100% reliable and you will never see the Assistant and will remain in your current app. Without root, you will occasionally see the Assistant and it may bring you to the homescreen. The only limitation is you need to use English language until Google enables the Assistant for other languages.

    Root Command
    You can now remap buttons to a root command. This offers unlimited possibilities for power users. Obviously this requires root! It's available in the Pro version only

    Custom Key Codes
    You can also remap buttons to custom key codes. This means you can fully remap game controllers, tv remotes and other hardware attached to your device. I've compiled a list of key codes that are recognized by Android here. This requires root, unfortunately. It's available in the Pro version only.

    MIUI
    MIUI does some really stupid things to Android. In order for Button Mapper to work correctly, you need to grant the "Autostart" permission and disable battery optimization. If you do not grant the autostart permission, swiping Button Mapper away in recents will kill the service. If you do not set battery optimization to "No restrictions", then Button Mapper's service will be killed every 10 minutes or so.

    To grant these permissions, in go to the menu at upper right in Button Mapper and select "Introduction." Swipe to the screen title Permissions and follow the instructions.

    Samsung volume bug
    I tracked down a few obscure bugs on Samsung phones, including the volume scaling bug that I could never reproduce. This occurred when the volume buttons were remapped and then later the "Bixby only" option was selected without rebooting.

    Pirating this app
    Don't install pirated versions of this app (or any app that uses Accessibility or root), even just to try for a few minutes. Because it uses Accessibility Service and root, you must fully trust the developer. Using a pirated version of any root app gives hackers carte blanche on your device.



    • New actions:
      -toggle BlueTooth
      -headset key press
      -change keyboard
      -root command (requres root and PRO)
      -custom keycodes (requires root and PRO)
    • Android TV support
    • Screen off only option (requires root and PRO)
    • Fix battery drain on rooted Pixel 2
    • Update translations
    • Fix volume change for screen off actions
    • Improve Bixby handling
    • Fix volume bug on S8/Note8
    • Improve UI
    • Add 180 rotation to swap volume orientation setting
    • Improve root handling
    • Improve MIUI behaviour
    • New intro
    • Add feedback form
    • Speed and memory optimizations
    • Many other bug fixes and improvements



    .
    15
    Button Mapper update!

    There is an awesome new update for Button Mapper rolling out. You can get it on XDA Labs now, and on the Play Store in the coming days. This update improves volume button behavior, has fixes for Android Pie, improves Bixby remapping, lots of updates for Blackberry devices and adds a bunch of new actions, such as fullscreen mode, invert colors, toggles for NFC, airplane mode and mobile data, broadcast intents, Greek and Arabic languages, plus the usual bugfixes.

    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    I want to highlight two important new features.

    First, the broadcast intent action (pro version only!). With this action, you can use a button press to broadcast an intent, which is Android's way of communicating between apps. This opens up literally endless possibilities. For example, if you have my High Brightness Mode app installed, you could enter flar2.hbmwidget.TOGGLE_HBM for long-press of volume button to toggle high brightness mode.

    The second feature is a new option to disable volume button remapping when the volume panel is showing. For example, if you have long press volume down mapped to toggle the flashlight, when the volume panel is showing, holding down volume will turn the volume down rather than turning on the flashlight. Once the volume panel disappears, holding the volume button will once again toggle the flashlight. I think this makes the volume button behavior more intuitive, so it's enabled by default. This can be turned off if you don't like it, the option is in Advanced options->Volume panel bypass.

    Please enjoy, and don't forget to leave a positive review if you find Button Mapper useful.
    12
    Version 0.66 is now released. It will roll out slowly on the Play Store, if you want it now, get it from XDA Labs
    https://labs.xda-developers.com/store/app/flar2.homebutton

    This version has tons of small fixups: volume button behavior is vastly improved, activities open right away after pressing home, everything is faster, and there are more options. Also quite a few UI improvements. New actions include toggle mobile data (root only), toggle wifi hotspot (Nougat and lower only), toggle autobrightness and clearn notifications. There is a new option to enable pocket detection, so actions won't occur while the phone is in your pocket (requires pro version).

    For Android P users, I've fixed the volume buttons to default to media and added an option to force them to control ring volume like older versions of Android.

    There is now an option to lock the screen in a way that allows you to unlock with the fingerprint. Rooted users could always do that, now unrooted users can too.

    I've also added an option to force audio routing through the speaker while Pressy, MiKey or other headphone jack buttons are plugged in. I don't have one of these devices, but it should all work.


    Changes:
    Pocket detection (pro)
    Toggle auto brightness
    Toggle Wifi hotspot (Android 7 and lower)
    Toggle mobile data (root)
    Clear notifications
    Compatibility with Android P
    Option to use speaker with Pressy, MiKey, etc
    Global bypass option
    More long press duration options
    Receive incoming phone calls with home button (Samsung)
    Add Spanish
    Update translations
    UI improvements
    Optional lock method that allows fingerprint unlocking
    Fix AOD crash with screenshot action (Samsung)
    Optimizations and bugfixes