KeyMapper icon indicating copy to clipboard operation
KeyMapper copied to clipboard

Create option to detect trigger by the device name rather than descriptor

Open Generator opened this issue 4 years ago • 15 comments

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

Screenshot_20210825-175244

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"

Generator avatar Sep 29 '21 20:09 Generator

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

sds100 avatar Sep 30 '21 10:09 sds100

I've created an example key map with Keycode_Search with automatic key captured with the remote. mappings_20210930-114931.zip

Generator avatar Sep 30 '21 12:09 Generator

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.

sds100 avatar Sep 30 '21 12:09 sds100

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.

Generator avatar Sep 30 '21 15:09 Generator

Oh okay, so the "descriptor" (id) of the devices actually changes after some reboots? 🤔 They should be universally unique.

sds100 avatar Sep 30 '21 15:09 sds100

Can you

  1. back up your key maps
  2. install the 2.3.0 release from github (you'll have to uninstall the google play version)
  3. restore your key maps
  4. turn on "extra logging" in the key mapper settings.
  5. trigger your key maps
  6. send me the log. there is a button to share the log at the bottom of the key mapper settings

sds100 avatar Sep 30 '21 15:09 sds100

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.

Generator avatar Sep 30 '21 20:09 Generator

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.

sds100 avatar Oct 01 '21 08:10 sds100

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

Generator avatar Oct 01 '21 11:10 Generator

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?

sds100 avatar Oct 01 '21 11:10 sds100

Think so, before noticing this, all mapped keys some times worked or times don't. But now i set them to "any device"

Generator avatar Oct 01 '21 11:10 Generator

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. 😀

sds100 avatar Oct 01 '21 11:10 sds100

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.

Generator avatar Oct 01 '21 12:10 Generator

Yeah, I will add it to the known issues. I will close this now. :)

sds100 avatar Oct 01 '21 14:10 sds100

I will actually implement a proper fix for this. See the developer checklist for what I'm going to do.

sds100 avatar Oct 02 '21 09:10 sds100