Android TV / FireTV, reading input from remote

I’ve been implementing support for android tv / firetv lately and have run into some problems reading input. Has anyone got any experience building games for these platforms?

Getting the game up and running was easy enough but reading input seems a bit messy. On firetv it reads input from the keyboard when using the remote control, where on the cheap android tv box we have it is reading from the gamepad input.

I’ve encountered a few strange things on firetv, for one I cannot prevent back button closing the app (I’ve overridden OnBackPressed in the android activity), which I want to block entirely unless the user is on the title screen. It also seems to fire more than once when using the back button. Also I cannot work out what key the menu button is, GetPressedKeys() simply returns an empty array, although I am taking input from the keyboard.

Then on the android TV I can read the arrow keys as dpad keys on gamepad, and also it detects the back button as being the gamepad back button, all good. But then it doesn’t give any input for the central enter button on the remote control.

I realise its pretty tough supporting so many platforms. Is there a way I can hook into this myself and see what is going on aside from doing a custom MG build?