This topic describes how your application can detect and receive input from a gamepad connected to the TV.
A standard gamepad has 4 axes and up to 17 buttons. Other gamepads can have different styles and layouts of axes and buttons.
All Samsung TVs since 2016 support gamepads. Gamepads are not supported on the emulator.
The following limitations apply to using gamepads with a Samsung TV:
To check that a specific gamepad model is connected to the TV when the application is launched, add the following line to the "config.xml" file:
<tizen:metadata key='http://samsung.com/tv/metadata/gamepad' value='xxx'> </tizen:metadata>
The value is the model name of the gamepad. To add multiple gamepad models, separate the model names using "::". For example:
dualshock4
usbgamepad::xxx
xxx::yyy::zzz
The following figure shows the popup that appears if the application checks for a "dualshock4" gamepad when it is launched, and one is not connected.
You can use the Web standard Gamepad interface to retrieve information about connected gamepads:
gamepadconnected
var gamepad; window.addEventListener('gamepadconnected', function(event) { gamepad = event.gamepad; console.log('event.gamepad : ' + JSON.stringify(event.gamepad)); });
gamepaddisconnected
gamepad
undefined
window.addEventListener('gamepaddisconnected', function() { gamepad = undefined; });
Gamepad
console.log(gamepad.axes[0]); // axes[0] console.log(gamepad.buttons[0]); // buttons[0]