Closed AntTheAlchemist closed 1 year ago
I don't have an Amazon Fire TV Stick, are you able to debug and see what events are happening? Does it still work with 2.010, or has the OS been upgraded to change behavior?
I see no SDL events at all from this button.
I hope to get rtrussell in here to give more details, since he managed to patch the current source to produce the keyboard event.
Does it still work with 2.010, or has the OS been upgraded to change behavior?
Yes, it still works with SDL 2.0.10. The internal KeyEvent.KEYCODE_MENU
event definitely fires because my workaround is to force this to be treated as a keyboard event rather than a gamepad event; with that change the SDLK_MENU event is received as expected.
I presume that the underlying issue is that KeyEvent.KEYCODE_MENU
can be received from either the Amazon Fire TV remote (in which case it should be treated as a keyboard event, as the other buttons are) or from the menu button on a game controller (e.g. button 6 on an Xbox controller), in which case it should be treated as a gamepad event.
If that's right SDL needs to determine which it is in order to issue the appropriate kind of event. But not knowing the first thing about game controllers I might be completely wrong!
SDL_HINT_TV_REMOTE_AS_JOYSTICK will play a part in this as well. It's enabled by default, but I disable it in my apps. I assume the remote's menu button creates a joystick menu event if this hint is enabled?
I just tested SDL3 with SDL_HINT_TV_REMOTE_AS_JOYSTICK set and "Amazon Fire TV Remote" menu key is producing Gamepad_Button "start" events. With REMOTE_AS_JOYSTICK disabled, there is no remote Gamepad and no keyboard events produced instead. So it looks like SDL is still catching remote menu presses and sending them to a virtual joystick, but no longer producing keyboard events.
If you look in handleKeyEvent(), it will look at the source of the event to figure out where to dispatch it. Is the event source a joystick in this case?
Debugging on FireTV is fun :) Amazon have made it easy for devs. Here is what I've found in handleKeyEvent() when I press the menu button:
keyCode = 82 mScanCode = 139
When SDL_HINT_TV_REMOTE_AS_JOYSTICK is enabled (default) SDLControllerManager.isDeviceSDLJoystick(deviceId)
evaluates to TRUE, so it gets processed as a game controller event as expected.
With SDL_HINT_TV_REMOTE_AS_JOYSTICK disabled, the remote still identifies as a joystick and the button (which evaluates to 6) is processed by button_to_scancode
, which doesn't handle "6", so it returns SDL_SCANCODE_UNKNOWN. That seems to be where the isssue is.
In short: the menu key on the FireTV basically evaluates to game controller start button, which isn't filtered by button_to_scancode()
Nice investigation! This should be fixed, thanks!
Posted on behalf of rtrussell from Discorse.
With SDL 2.0.10 an Android app running on the Amazon Fire TV Stick reports an SDLK_MENU event when the menu button is pressed on the remote control. However it seems that in SDL 2.26.2 that no longer happens. I’m still getting the expected events from the other buttons and the navigation wheel, but not the menu button.