top

SmartController API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

This module defines the Smart Controller 6-axis functionalities provided by the Tizen Samsung TV Product API.

Since : 2.3

Deprecated : 2.4

Product : TV

Table of Contents

  1. 1. Interfaces
    1. 1.1. SmartControllerManagerObject
    2. 1.2. SmartControllerManager
    3. 1.3. SmartControllerSixAxisData
    4. 1.4. SmartControllerSixAxisDataCallback
  2. 2. Full WebIDL

Summary of Interfaces and Methods

Interface Method
SmartControllerManagerObject  
SmartControllerManager DOMString getVersion ()
boolean isConnected ()
short setSixAxisListener (SmartControllerSixAxisDataCallback listener)
void unsetSixAxisListener (short listenerId)
SmartControllerSixAxisData  
SmartControllerSixAxisDataCallback void onchange (SmartControllerSixAxisData eventData)

1. Interfaces

1.1. SmartControllerManagerObject

Defines the SmartController interface of the Tizen Samsung TV Product API.

[NoInterfaceObject]interface SmartControllerManagerObject {
  readonly attribute SmartControllerManager smartcontroller;
};

  WebApi implements SmartControllerManagerObject;

Attributes

1.2. SmartControllerManager

Provides methods for SmartController functionalities.

[NoInterfaceObject]interface SmartControllerManager {
  DOMString getVersion();
  boolean isConnected();
  short setSixAxisListener(SmartControllerSixAxisDataCallback listener);
  void unsetSixAxisListener(short listenerId);
};

Methods

getVersion
Retrieves the plugin version number.

DOMString getVersion();

Since : 2.3

Deprecated : 2.4

Return value:

Plugin version

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type UnknownError, for any other error.

Code example:


var version = null;
try {
  version = webapis.smartcontroller.getVersion();
} catch (e) {
  console.error("getVersion exception [" + e.code + "] name: " + e.name  + " message: " + e.message);
}

if (null != version) {
  console.log("[getVersion] version: " + version);
}
isConnected
Gets the Smart Controller connection state.

boolean isConnected();

Since : 2.3

Deprecated : 2.4

Return value:

Boolean value:
  • true: Connected
  • false: Not connected

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type UnknownError, for any other error.

Code example:


var bConnected = null;
try {
  bConnected = webapis.smartcontroller.isConnected();
} catch (e) {
  console.error("isConnected exception [" + e.code + "] name: " + e.name
   + " message: " + e.message);
}
if (null != bConnected) {
  console.log("[isConnected] result: " + res);
}
setSixAxisListener
Registers a Smart Controller 6-axis data changed event listener.

short setSixAxisListener(SmartControllerSixAxisDataCallback listener);

Since : 2.3

Deprecated : 2.4

Parameters:

  • listener : Callback method invoked when the 6-axis data change occurs.

Return value:

Listener ID

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type UnknownError, for any other error.

Code example:


var bConnected = null;
try {
  bConnected = webapis.smartcontroller.isConnected();
} catch (e) {
  console.error("isConnected exception [" + e.code + "] name: " + e.name
   + " message: " + e.message);
}
if (null != bConnected) {
  console.log("[isConnected] result: " + res);
}
unsetSizAxisListener
Unregisters a Smart Controller 6-axis data changed event listener.

void unsetSixAxisListener(short listenerId);

Since : 2.3

Deprecated : 2.4

Parameters:

  • listenerId : Listener ID

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type UnknownError, for any other error.

Code example:


try {
  console.log("begin unsetSixAxisListener listenerID: " + listenerID);
  if(listenerID == -1) {
    console.log("First register before you deregister");
  }
  else {
    webapis.smartcontroller.unsetSixAxisListener(listenerID);
    listenerID = -1;
  }
}
catch (e) {
  console.error("unsetSixAxisListener exception [" + e.code+ "] name: " + e.name + " message: " + e.message);
}

1.3. SmartControllerSixAxisData

Defines the Smart Controller 6-axis data.

[NoInterfaceObject]interface SmartControllerSixAxisData {
  readonly attribute long samplingTime;
  readonly attribute long sensorType;
  readonly attribute long touchMode;
  readonly attribute long xAccel;
  readonly attribute long xGyro;
  readonly attribute long yAccel;
  readonly attribute long yGyro;
  readonly attribute long zAccel;
  readonly attribute long zGyro;
};

Attributes

  • readonly SmartControllerSixAxisData samplingTime
    Sampling time
  • readonly SmartControllerSixAxisData sensorType
    Sensor type
  • readonly SmartControllerSixAxisData touchMode
    Touch mode
  • readonly SmartControllerSixAxisData xAccel
    X-axis acceleration
  • readonly SmartControllerSixAxisData xGyro
    X-axis gyro value
  • readonly SmartControllerSixAxisData yAccel
    Y-axis acceleration
  • readonly SmartControllerSixAxisData yGyro
    Y-axis gyro value
  • readonly SmartControllerSixAxisData zAccel
    Z-axis acceleration
  • readonly SmartControllerSixAxisData zGyro
    Z-axis gyro value

1.4. SmartControllerSixAxisDataCallback

Defines the callback invoked when the Smart Controller 6-axis data changes.

[Callback = FunctionOnly, NoInterfaceObject]interface SmartControllerSixAxisDataCallback {
  void onchange(SmartControllerSixAxisData eventData);
};

Methods

onchange
Callback invoked when the Smart Controller 6-axis data changes.

  void onchange(SmartControllerSixAxisData eventData);

Since : 2.3

Deprecated : 2.4

Parameters:

  • eventData: 6-axis data

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type UnknownError, for any other error.

Code example:


var onChange = function (eventData) {
  console.log("samplingTime: " + eventData.samplingTime);
  console.log("sensorType: " + eventData.sensorType);
  console.log("touchMode: " + eventData.touchMode);
  console.log("xAccel: " + eventData.xAccel);
  console.log("xGyro: " + eventData.xGyro);
  console.log("yAccela: " + eventData.yAccel);
  console.log("yGyro: " + eventData.yGyro);
  console.log("zAccel: " + eventData.zAccel);
  console.log("zGyro: " + eventData.zGyro);
};

2. Full WebIDL


module SmartController {
  [NoInterfaceObject]interface SmartControllerManagerObject {
    readonly attribute SmartControllerManager smartcontroller;
  };

  WebApi implements SmartControllerManagerObject;

  [NoInterfaceObject]interface SmartControllerManager {
    DOMString getVersion();
    boolean isConnected();
    short setSixAxisListener(SmartControllerSixAxisDataCallback listener);
    void unsetSixAxisListener(short listenerId);
  };

  [NoInterfaceObject]interface SmartControllerSixAxisData {
    readonly attribute long samplingTime;
    readonly attribute long sensorType;
    readonly attribute long touchMode;
    readonly attribute long xAccel;
    readonly attribute long xGyro;
    readonly attribute long yAccel;
    readonly attribute long yGyro;
    readonly attribute long zAccel;
    readonly attribute long zGyro;
  };

  [Callback = FunctionOnly, NoInterfaceObject]interface SmartControllerSixAxisDataCallback {
    void onchange(SmartControllerSixAxisData eventData);
  };
};