top

SmartController API

To use Samsung Product API, 

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

Should be loaded in index.html

The module defines the functionalities of getting six-axis data of smart controller that are provides as the Samsung TV for Tizen Platform Product API.

Since : 1.0

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

The interface defines what is instantiated by the WebApi object of Samsung TV for Tizen Platform Product API.
There will be a webapis.productinfo object that allows access to the functionality of the SmartController API

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

  WebApi implements SmartControllerManagerObject;

Since : 1.0

Attributes

1.2. SmartControllerManager

This interface provides methods to use the SmartController functionalities.

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

Since : 1.0

Methods

getVersion
Get the version of SmartController plugin.

  DOMString getVersion();

Since : 1.0

Return value:

DOMString return value of Plugin version

Exceptions:

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

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

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
Get connetion state of Smart Controller.

  boolean isConnected()

Since : 1.0

Return value:

boolean It returns the bool value.
  • True: connected
  • False: not connected

Exceptions:

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

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

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
Register the listener of six-axis data changed for smart controller.

  short setSixAxisListener(SmartControllerSixAxisDataCallback listener)

Since : 1.0

Parameters:

  • listener - Callback to be invoked when there is change in six axis of smart remocon.

Return value:

short listener ID

Exceptions:

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

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  var onChange = function(data) {
      console.log("samplingTime:" + data.samplingTime
           +" sensorType:" + data.sensorType
           + "touchMode:" + data.touchMode
           + " xAccel:" + data.xAccel
           + " xGyro:" + data.xGyro
           + " yAccel:" + data.yAccel
           + " yGyro:" + data.yGyro
           + " zAccel:" + data.zAccel
           + " zGyro:" + data.zGyro);
  }
  var listenerID = -1;
  try {
      var listenerID = webapis.smartcontroller.setSixAxisListener(onChange);
      if (listenerID > -1) {
          console.log("setSixAxisListener success listener ID ["+ listenerID + "] ");
      }
  } 
  catch (e) {
      console.error("setSixAxisListener exception [" + e.code+ "] name: " + e.name + " message: " + e.message);
  }
unsetSizAxisListener
Un-Register the listener of six-axis data changed for smart controller, if registered.

  void unsetSixAxisListener(short listenerId)

Since : 1.0

Parameters:

  • listenerId - Listener id to be removed

Exceptions:

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

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

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

This interface defines the data of smart contorller.

  [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;
  };

Since : 1.0

Attributes

  • readonly SmartControllerSixAxisData samplingTime
    This attribute defines the sampling time.

    Since : 1.0

  • readonly SmartControllerSixAxisData sensorType
    This attribute defines the sensor type.

    Since : 1.0

  • readonly SmartControllerSixAxisData touchMode
    This attribute defines the touch mode.

    Since : 1.0

  • readonly SmartControllerSixAxisData xAccel
    This attribute defines x-axis accelartion value.

    Since : 1.0

  • readonly SmartControllerSixAxisData xGyro
    This attribute defines x-axis gyro value.

    Since : 1.0

  • readonly SmartControllerSixAxisData yAccel
    This attribute defines y-axis accelartion value.

    Since : 1.0

  • readonly SmartControllerSixAxisData yGyro
    This attribute defines y-axis gyro value.

    Since : 1.0

  • readonly SmartControllerSixAxisData zAccel
    This attribute defines z-axis accelartion value.

    Since : 1.0

  • readonly SmartControllerSixAxisData zGyro
    This attribute defines z-axis gyro value.

    Since : 1.0

1.4. SmartControllerSixAxisDataCallback

This callback interface defines getting six-axis data of smart remocon.

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

Since : 1.0

Methods

onchange
This method is the callback function will be provided by the application.

  void onchange(SmartControllerSixAxisData eventData);

Since : 1.0

Parameters:

  • eventData: contains the six axis data

Exceptions:

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

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

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() raises(WebAPIException);
      boolean isConnected() raises(WebAPIException);
      short setSixAxisListener(SmartControllerSixAxisDataCallback listener) raises(WebAPIException);
      void unsetSixAxisListener(short listenerId) raises(WebAPIException);
  };

  [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);
      };
  };