top

GAMEPAD.GAMEPAD

This class can receive an input key value of gamepad by connecting to gamepad device. It also includes available methods of forcefeedback.

Add the following line for gamepad.Gamepad class into a html file your own :

  script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/deviceapis.js">/script>

You can declare gamepad.Gamepad class like this :

  ex) var gamepad = deviceapis.gamepad;


Methods

getABSValueRange

Description
get ABS value range from the gamepad
Parameters
■code
  - Unsigned short 
  - ABS Event Code to get the range
Return■GamepadABSValueRange
  - ABS value range structure from the gamepad.
    * Returns null if value is not available
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

GamepadABSValueRange range = device1.getABSValueRange(gamepad.ABS_HAT3Y);

getDeviceID

Description
get device ID of the device.
Parameters
none
Return■DOMString
  - device ID
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

string strDeviceID = device1.getDeviceID();

getInputEvent

Description
get input event from the gamepad
Parameters
none
Return■GamepadEvent
  - input event from the gamepad. 
    * Returns null if event is not available.
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}


GamepadEvent event = device1.getInputEvent();

getName

Description
get name of the device.
Parameters
none
Return■DOMString
  - name of the device
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

string strName = device1.getName();

getUniqueID

Description
get unique ID of the device.
Parameters
none
Return■DOMString 
  - address/uniqueID of the device
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

string strUniqueID = device1.getUniqueID();

isForceFeedbackSupported

Description
check forcefeedback supportability of the gamepad
Parameters
none
Return■Boolean
  - true : forcefeedback is supported, 
  - false : forcefeedback is not supported
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

bool fResult = device1.isForceFeedbackSupported();

playForceFeedback

Description
request to play forcefeedback effect of the the gamepad
Parameters
■duration 
  - Unsigned short 
  - duration of forcefeedback effect. 
  - [default : set to 1] 
■gain 
  - Unsigned short 
  - gain of forcefeedback effect. 
  - [default : set to 100]
Return■Boolean
  - true : forcefeedback is successful, 
  - false : forcefeedback is fail
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

bool fResult = device1.playForceFeedback(1, 100);

stopForceFeedback

Description
quest to stop forcefeedback effect of the gamepad
Parameters
none
Return■Boolean
  - true : forcefeedback stops properly,
  - false : forcefeedback stops failed
Emulator SupportYes
SDK ConstraintNone
Example
var gamepad = window.webapis.gamepad || {};
var device1 = null;

Main.keyDown = function()
{
    gamepad.getGamepads(Main.onGamepadObtained);
    ....
}

Main.onGamepadObtained = function(gamepads)
{
    device1 = gamepads[0];
}

bool fResult = device1.stopForceFeedback();