MappingObject

Available in: Interface Scripts Client Entity Scripts

A Controller mapping object that can contain a set of routes that map:

Create by one of the following methods:

Enable the mapping using enable or Controller.enableMapping for it to take effect.

Mappings and their routes are applied according to the following rules:

  • One read per output: after a controller output has been read, it can't be read again. Exception: You can use RouteObject#peek to read a value without marking that output as having been read.
  • Existing mapping routes take precedence over new mapping routes: within a mapping, if a route is added for a control output that already has a route the new route is ignored.
  • New mappings override previous mappings: each output is processed using the route in the most recently enabled mapping that contains that output.
Methods

Methods

disable() → {MappingObject}
Disable the mapping. When disabled, the routes in the mapping have no effect.
Synonymous with Controller.disableMapping.
Returns:
The mapping object, so that further routes can be added.
Type: MappingObject
enable(enable) → {MappingObject}
Enable or disable the mapping. When enabled, the routes in the mapping take effect.
Synonymous with Controller.enableMapping.
Parameters:
Name Type Default Description
enable boolean true If true then the mapping is enabled, otherwise it is disabled.
Returns:
The mapping object, so that further routes can be added.
Type: MappingObject
from(source) → {RouteObject}
Create a new RouteObject from a controller output, ready to be mapped to a standard control, action, or function.
Parameters:
Name Type Description
source Controller.Standard | Controller.Hardware | function The controller output or function that is the source of the route data. If a function, it must return a number or a Pose value as the route data.
Returns:
A route ready for mapping to an action or function using RouteObject methods.
Type: RouteObject
fromQml(source) → {RouteObject}
Create a new RouteObject from a controller output, ready to be mapped to a standard control, action, or function.
This is a QML-specific version of from: use this version in QML files.
Parameters:
Name Type Description
source Controller.Standard | Controller.Hardware | function The controller output or function that is the source of the route data. If a function, it must return a number or a Pose value as the route data.
Returns:
A route ready for mapping to an action or function using RouteObject methods.
Type: RouteObject
makeAxis(source1, source2) → {RouteObject}
Create a new RouteObject from two numeric Controller.Hardware outputs, one applied in the negative direction and the other in the positive direction, ready to be mapped to a standard control, action, or function.
Parameters:
Name Type Description
source1 Controller.Hardware The first, negative-direction controller output.
source2 Controller.Hardware The second, positive-direction controller output.
Returns:
A route ready for mapping to an action or function using RouteObject methods. The data value passed to the route is the combined value of source2 - source1.
Type: RouteObject
Example

Make the Oculus Touch triggers move your avatar up and down.

var MAPPING_NAME = "com.highfidelity.controllers.example.newMapping";
var mapping = Controller.newMapping(MAPPING_NAME);
mapping
  .makeAxis(Controller.Hardware.OculusTouch.LT, Controller.Hardware.OculusTouch.RT)
  .to(Controller.Actions.Up);
Controller.enableMapping(MAPPING_NAME);

Script.scriptEnding.connect(function () {
  Controller.disableMapping(MAPPING_NAME);
});
makeAxisQml(source1, source2) → {RouteObject}
Create a new RouteObject from two numeric Controller.Hardware outputs, one applied in the negative direction and the other in the positive direction, ready to be mapped to a standard control, action, or function.
This is a QML-specific version of makeAxis: use this version in QML files.
Parameters:
Name Type Description
source1 Controller.Hardware The first, negative-direction controller output.
source2 Controller.Hardware The second, positive-direction controller output.
Returns:
A route ready for mapping to an action or function using RouteObject methods. The data value passed to the route is the combined value of source2 - source1.
Type: RouteObject