Game Controller Input

Amazon Fire TV game controllers (as well as other controllers that conform to the Bluetooth HID gamepad profile) have specific buttons, Android motion, and key event constants. Use this information to capture input events in your app.

Buttons

The current version of the Fire TV Game Controller has these buttons:

The previous version of the Game Controller has these buttons:

Capturing Input

Game controllers used with Amazon Fire TV generate Android KeyEvent events for digital button presses (such as the A button), and MotionEvent events for analog control movement (such as a joystick action).

You can handle simple button input with standard Android event listener interfaces and callbacks (onClick(), onFocusChange(), and so on).

@OverridepublicbooleanonGenericMotionEvent(MotionEventevent){// get changes in value from left joystickfloatdeltaX=event.getAxisValue(MotionEvent.AXIS_X);floatdeltaY=event.getAxisValue(MotionEvent.AXIS_Y);if(deltaX>0.5&&deltaY>0.5){// do somethinghandled=true;}returnhandled||super.onGenericMotionEvent(event);}

Primary and Secondary Input Events

Some game controller actions on Amazon Fire TV devices may raise more than one input event for a single action. For example, the D-Pad on the Amazon Fire Game Controller is an analog directional control (producing motion events), but a digital control on the Fire TV remote controls (producing key events).

Similarly, the selection action is the A button on a game controller, but it is the D-Pad center button on Fire TV remotes. Some game controller actions on Amazon Fire TV first raise a primary input event (usually a motion event). Then, if those events are not handled by your app, they raise a second input event (usually a key event). Both of the primary and secondary input events are listed in the Input Event Reference table below.

Secondary input events can help you simplify the process of handling game controller input. If your app is interested only in button and D-Pad events from a game controller, the secondary events enable you to ignore motion events altogether and only deal with key events.

Similarly, because the A button generates both KEYCODE_BUTTON_A and KEYCODE_DPAD_CENTER, if your app supports the center D-Pad button on the Fire TV remotes, you do not have to also test for the A button.

Note that your app may behave as if it is receiving double input if you do not properly handle the primary input events. Make sure your input event handlers return true if you have captured and handled an event. The secondary input event is not generated if the first has been captured.

Input Event Reference

The following table describes the motion and key event constants for each game controller button, the suggested user experience behavior for those buttons, and the default behavior of those buttons in the Amazon Fire TV user interface.

Note: Do not capture or throw away input events for any buttons you do not use in your app. Allowing the system to handle unused events enables background behavior such as media playback and volume control.

The events listed in the Secondary Event column are raised in addition to the events in the MotionEvent or KeyEvent columns, if your app does not handle that primary event. See Primary and Secondary Input Events (above) for information on these secondary events.

In this table, a game is an app that was submitted to the Amazon Appstore in the games category and installed onto the device from the Amazon Appstore.

Game Controller Button

MotionEvent

KeyEvent

Secondary Event

Default Behavior

Home

none

none

none

For games, display a "Game Paused" dialog. For all other apps, return the user to Home.