KeyMapper
KeyMapper copied to clipboard
Create option to detect trigger by the device name rather than descriptor
Developer TODO (don't remove)
- [ ] First implement #761
- [ ] create new branch. put issue number at start of name if not a very quick fix.
- [ ] write tests. put issue number in comment
- [ ] create a trigger key option that will use the name of the device rather than the id to detect the trigger key.
- [ ] update documentation.
- [ ] update known issues to prompt the user to enable the extra compatibility options if on 2.4.0+.
- [ ] in the compatibility options section describe why this issue happens and how to find the option to fix this.
- [ ] squash and merge
- [ ] delete branch
Describe the bug
I have a Android TV with a USB wireless remote (Air Mouse MX3), and set some keys to execute some actions, but after some reboots those key mappers stop working.
The app show another device with same name, the remote is always at same USB port and didn't any system update.
Tried the same settings with Button Mapper, didn't have this issue.
Workaround is to set Tigger to "Any Device"
To Reproduce Steps to reproduce the behavior:
- Use a USB remote or keyboard
- set some actions
- Try it after some reboots
Expected behavior Always use the same device with same name/ID
Screenshots

Smartphone (please complete the following information):
- Device: X96 Max+
- Android version: Android (9) TV (Slimbox ATV)
Additional context
List input devices cat /proc/bus/input/devices inputs.txt
The remote is an Air Mouse (mouse+keyboard) Name="123 COM Smart Control"
Hello, Interesting issue and will definitely be fixed in 2.3.1. Can you also send a backup of your key maps. follow this guide to do this https://docs.keymapper.club/user-guide/backup-restore
I've created an example key map with Keycode_Search with automatic key captured with the remote.
mappings_20210930-114931.zip
So does the key map work straight after you create the trigger? I'm not sure how this issue can happen because if a trigger can be recorded then it should still be detected.
Yes, after creating works for some time, but after 2 or 3 reboots a new device with same name shows on created key map, if i change the device works.
Just yesterday after creating two new key maps for Automate, stopped working after some reboots.
Oh okay, so the "descriptor" (id) of the devices actually changes after some reboots? 🤔 They should be universally unique.
Can you
- back up your key maps
- install the 2.3.0 release from github (you'll have to uninstall the google play version)
- restore your key maps
- turn on "extra logging" in the key mapper settings.
- trigger your key maps
- send me the log. there is a button to share the log at the bottom of the key mapper settings
install the 2.3.0 release from github (you'll have to uninstall the google play version)
I already had 2.3.0 from F-Droid, but installed the Github version anyway.
Enabled "extra logging" and pressed some mapped keys
key_mapper_log_20210930-195142.txt
I'll leave "KEYCODE_SEARCH" mapped, and keep trying till stop working then send another log, also create logs from /proc/bus/input/devices with working and not working, to see if there's any difference.
Since both keyboard and mouse share the same name and VID/PID, if the app looks for those and they got swap on boot the app will wait for the wrong device for key event.
Cool, thanks. Your key maps were working in that log since the device descriptor matched the one in the trigger. I'll wait for your 2nd log.
Here it is, after rebooting "KEYCODE_SEARCH" stopped working, then changed mapped key to the other device with same name, then works.
key_mapper_log_20211001-120717.txt Oops something went wrong with log, will recreate it.
Also the /proc/bus/input/devices didn't change, made one with working (after creating key map)
and after (after not working)
inputs-working.txt
inputs-not-working.txt
inputs.diff.txt
EDIT: Fixed key_mapper_log_20211001-122910.txt
Okay, interesting. Yeah, the device descriptor does change. Do you have any idea why it changes? Does it ever change back to the one stored in the trigger?
Think so, before noticing this, all mapped keys some times worked or times don't. But now i set them to "any device"
Okay, really strange that it always changes the descriptors. Is using "any device" a solution for you? I would prefer to not have to add a UI setting for one person that has an issue that shouldn't be happening anyway. 😀
Yes "any device" works all the time. Its device related, but there's more similar devices for Android Boxes. But don't think this is a priority if only affects certain devices. Maybe a notice on app site "known issues" or in the app itself.
Yeah, I will add it to the known issues. I will close this now. :)
I will actually implement a proper fix for this. See the developer checklist for what I'm going to do.