This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

ControlsSixAxis Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits from: Controls

This class handles Sixaxis controller input. It provides access to the following controller properties:

  • Buttons represent digital buttons on the controller and can be either pressed or unpressed. Just like in the case of mouse/keyboard controls, they can be mapped to the specific controls states, to bind input events and programmed actions. You can either bind buttons in the code via setStateButton() or let the user assign the button for a control state via getStateEvent().
  • D-pad is represented as four directional buttons (left, right, up and down). They are handled in the same way as other buttons.
  • Thumbsticks are left and right analog directional sticks on the controller. They are queried via getLeftX() and getLeftY() for the left thumbstick and getRightX() and getRightY() for the right one. Thumbsticks also act as two digital buttons when pressed (i.e. the stick is "clicked" in). In this case, they are handled in the same way as other buttons.
  • Vibration motors allow to set vibration effects. The amount of vibration for each of the motors can be set via setLargeMotor() and setSmallMotor().
  • Controller position/G-sensor data can be obtained via getSensorX(), getSensorY(), getSensorZ(), and getSensorG().

Input data from analog controls (thumbsticks and triggers) can be additionally filtered via setFilter() to provide smooth interpolation between frames and avoid jerks.
A controller should update the physical state of all its input controls (i.e. check whether the user has pressed the button, for example) each frame using updateEvents().

ControlsSixAxis Class

Members


static ControlsSixAxis ( int num ) #

Constructor. Creates a new Sixaxis controller.

Arguments

  • int num - Sixaxis controller number.

int isAvailable ( ) #

Checks if the Sixaxis controller is available.

Return value

1 if the Sixaxis controller is available; otherwise, 0.

int getButton ( int button ) #

Returns a button state (pressed or not pressed).

Arguments

  • int button - Button number.

Return value

1 if the button is pressed; otherwise, 0.

void setFilter ( float filter ) #

Sets a filter value used to correct the current state of the analog sticks of the Sixaxis controller relative to the previous one. Axis states are interpolated for analog sticks.

Arguments

  • float filter - Filter value for interpolation between axis states. The provided value is clamped to a range [0;1].
    • Filter value of 0 means there is no interpolation and the current value is not corrected.
    • Filter value of 1 means the previous state is used instead of the current one.

float getFilter ( ) #

Returns a filter value used to correct the current state of the analog axis of the Sixaxis controller relative to the previous one:
  • Filter value of 0 means there is no interpolation and the current value is not corrected.
  • Filter value of 1 means the previous state is used instead of the current one.

Return value

Filter value for interpolation between axis states.

void setLargeMotor ( float speed ) #

Sets the amount of vibration for the large motor.

Arguments

  • float speed - Speed of motor rotation in range [0; 1]

float getLeftX ( ) #

Returns a state value of the left analog stick along the X-axis. When the stick is in the center position, this value is zero. Negative values indicate left ; positive values indicate right.

Return value

Value in range [-1; 1].

float getLeftY ( ) #

Returns a state value of the left analog stick along the Y-axis. When the stick is in the center position, this value is zero. Negative values indicate down ; positive values indicate up.

Return value

Value in range [-1; 1].

string getName ( ) #

Returns the name of the Sixaxis controller.

Return value

Name of Sixaxis controller.

int getNumber ( ) #

Returns the number of Sixaxis controllers.

Return value

Number of controllers.

float getPressCircle ( ) #

Returns a state value of the circle button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressCross ( ) #

Returns a state value of the cross button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressDown ( ) #

Returns a state value of the down button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressL1 ( ) #

Returns a state value of the L1 button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressL2 ( ) #

Returns a state value of the L2 button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressLeft ( ) #

Returns a state value of the left button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressR1 ( ) #

Returns a state value of the R1 button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressR2 ( ) #

Returns a state value of the R2 button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressRight ( ) #

Returns a state value of the right button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressSquare ( ) #

Returns a state value of the square button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressTriangle ( ) #

Returns a state value of the triangle button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getPressUp ( ) #

Returns a state value of the up button. 0 value means the button is not pressed; 1 means the button is pressed to the maximum.

Return value

Value in range [0; 1].

float getRightX ( ) #

Returns a state value of the right analog stick along the X-axis. When the stick is in the center position, this value is zero. Negative values indicate left ; positive values indicate right.

Return value

Value in range [-1; 1].

float getRightY ( ) #

Returns a state value of the right analog stick along the Y-axis. When the stick is in the center position, this value is zero. Negative values indicate down ; positive values indicate up.

Return value

Value in range [-1; 1].

float getSensorG ( ) #

Returns a state value of the G-sensor.

float getSensorX ( ) #

Returns a state value of the controller position along the X-axis.

Return value

The value along the X-axis.

float getSensorY ( ) #

Returns a state value of the controller position along the Y-axis.

Return value

The value along the Y-axis.

float getSensorZ ( ) #

Returns a state value of the controller position along the Z-axis.

Return value

The value along the Z-axis.

void setSmallMotor ( float speed ) #

Sets the amount of vibration for the small motor.

Arguments

  • float speed - Speed of motor rotation in range [0; 1]

void setStateButton ( int state, int button ) #

Sets a Sixaxis controller button that switches a given state on and off.

Arguments

int getStateButton ( int state ) #

Returns a Sixaxis controller button that switches a given state on and off.

Arguments

Return value

Button that switches the state (one of the BUTTON_* variables)

void getStateEvent ( int state ) #

Lets the user assign a Sixaxis controller button to a given state.

Arguments

  • int state - State (one of the CONTROLS_STATE_*) to which a button is going to be assigned.

int isStateEvent ( ) #

Returns a value indicating if a Sixaxis controller button is successfully assigned to a state.

Return value

1 if a button is already assigned; otherwise, 0.

String getStateName ( int state ) #

Returns the name of a given state.

Arguments

int clearButton ( int button ) #

Returns a button state and clears it to 0 (not pressed).

Arguments

  • int button - Button that switches the state (one of the BUTTON_* variables)

Return value

1 if the button is pressed, and this function was not called previously in the current frame; otherwise, 0.

int saveState ( Stream stream ) #

Saves Sixaxis controller settings into the stream.

Example using saveState() and restoreState() methods:

Source code (UnigineScript)
// initialize a node and set its state
ControlsSixAxis sixAxis = new ControlsSixAxis();
sixAxis.setStateButton(0,1);

// save state
Blob blob_state = new Blob();
sixAxis.saveState(blob_state);

// change state
sixAxis.setStateButton(2,1);

// restore state
blob_state.seekSet(0); // returning the carriage to the start of the blob
sixAxis.restoreState(blob_state);

Arguments

  • Stream stream - The stream to save controls data.

Return value

1 if the Sixaxis controller settings are saved successfully; otherwise, 0.

int restoreState ( Stream stream ) #

Restores Sixaxis controller settings from the stream.

Example using saveState() and restoreState() methods:

Source code (UnigineScript)
// initialize a node and set its state
ControlsSixAxis sixAxis = new ControlsSixAxis();
sixAxis.setStateButton(0,1);

// save state
Blob blob_state = new Blob();
sixAxis.saveState(blob_state);

// change state
sixAxis.setStateButton(2,1);

// restore state
blob_state.seekSet(0); // returning the carriage to the start of the blob
sixAxis.restoreState(blob_state);

Arguments

  • Stream stream - The stream to save controls data.

Return value

1 if the Sixaxis controller settings are restored successfully; otherwise, 0.

int updateEvents ( ) #

Scans Sixaxis controller (synchronizes states of controller buttons with the controller). Should be called each frame

Return value

0 if a game pad is not found or updateEvents() already has been called for the frame; otherwise 1.
Last update: 2021-12-13
Build: ()