This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::ControlsXPad360 Class

Header: #include <UnigineControls.h>
Inherits: Controls

ControlsXPad360 Class

Members


static ControlsXPad360Ptr create ( int num ) #

Constructor. Creates a new XBox 360 game pad.

Arguments

  • int num - Game pad number (up to four game pads are supported).

int isAvailable ( ) #

Checks if the game pad is available.

Return value

1 if the game pad is available; otherwise, 0.

int getButton ( int button ) #

Returns a button state (pressed or not pressed).

Arguments

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 axis relative to the previous one. Axis states are interpolated for thumbsticks and triggers.

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 (thumbsticks and triggers) 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 setLeftMotor ( float speed ) #

Sets the amount of vibration for the left motor (a low-frequency motor).

Arguments

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

float getLeftTrigger ( ) #

Returns an axis state value (the position) of the left trigger. Zero means the trigger is not pressed; 1 means the trigger is pressed to the maximum.

Return value

Value in range [0; 1].

float getLeftX ( ) #

Returns a state value of the left thumbstick along the X axis. When a thumbstick 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 thumbstick along the Y axis. When a thumbstick is in the center position, this value is zero. Negative values indicate down; positive values indicate up.

Return value

Value in range [-1; 1].

const char * getName ( ) #

Returns the name of the game pad.

Return value

One of the following:
  • GamePad
  • Wheel
  • Arcade Stick
  • Flight Stick
  • Dance Pad
  • Guitar
  • Drum Kit
  • Unknown

int getNumber ( ) #

Returns the game pad number (up to four game pads are supported).

Return value

Game pad number.

void setRightMotor ( float speed ) #

Sets the amount of vibration for the right motor (a high-frequency motor).

Arguments

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

float getRightTrigger ( ) #

Returns an axis state value (the position) of the right trigger. Zero means the trigger is not pressed; 1 means the trigger is pressed to the maximum.

Return value

Value in range [0; 1].

float getRightX ( ) #

Returns a state value of the right thumbstick along the X axis. When a thumbstick 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 thumbstick along the Y axis. When a thumbstick is in the center position, this value is zero. Negative values indicate down; positive values indicate up.

Return value

Value in range [-1; 1].

void setStateButton ( int state, int button ) #

Sets a game pad button that switches a given state on and off.

Arguments

int getStateButton ( int state ) #

Returns a game pad button that switches a given state on and off.

Arguments

Return value

Button that switches the state (one of the CONTROLS_XPAD360_BUTTON_* variables):
  1. BUTTON_A = 0
  2. BUTTON_B
  3. BUTTON_X
  4. BUTTON_Y
  5. BUTTON_BACK
  6. BUTTON_START
  7. BUTTON_DPAD_UP
  8. BUTTON_DPAD_DOWN
  9. BUTTON_DPAD_LEFT
  10. BUTTON_DPAD_RIGHT
  11. BUTTON_THUMB_LEFT
  12. BUTTON_THUMB_RIGHT
  13. BUTTON_SHOULDER_LEFT
  14. BUTTON_SHOULDER_RIGHT

void getStateEvent ( int state ) #

Lets the user assign a game pad button to a given state.

Arguments

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

int isStateEvent ( ) #

Returns a value indicating if a game pad 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

Return value

State name.

int clearButton ( int button ) #

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

Arguments

Return value

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

bool saveState ( const Ptr<Stream> & stream ) #

Saves XBox 360 game pad settings into the stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// initialize a node and set its state
ControlsXPad360Ptr xpad = ControlsXPad360::create(1);
xpad->setStateButton(0,1);

// save state
BlobPtr blob_state = Blob::create();
xpad->saveState(blob_state);

// change state
xpad->setStateButton(2,1);

// restore state
blob_state->seekSet(0);				// returning the carriage to the start of the blob
xpad->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if the XBox 360 game pad settings are saved successfully; otherwise, false.

bool restoreState ( const Ptr<Stream> & stream ) #

Restores XBox 360 game pad settings from the stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// initialize a node and set its state
ControlsXPad360Ptr xpad = ControlsXPad360::create(1);
xpad->setStateButton(0,1);

// save state
BlobPtr blob_state = Blob::create();
xpad->saveState(blob_state);

// change state
xpad->setStateButton(2,1);

// restore state
blob_state->seekSet(0);				// returning the carriage to the start of the blob
xpad->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if the XBox 360 game pad settings are restored successfully; otherwise, false.

int updateEvents ( ) #

Scans a game pad (synchronizes states of game pad buttons and thumbsticks with the controller itself). 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-04-09
Build: ()