This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
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
创建内容
内容优化
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::InputGamePad Class

Header: #include <UnigineInput.h>

The InputGamePad class represents a game pad and contains a set of functions for handling user inputs.

InputGamePad Class

Enums

BUTTON#

Buttons of the game pad.
Name说明/描 述
BUTTON_A = 0Button A.
BUTTON_B = 1Button B.
BUTTON_X = 2Button X.
BUTTON_Y = 3Button Y.
BUTTON_BACK = 4Button "Back".
BUTTON_START = 5Button "Start".
BUTTON_DPAD_UP = 6Button "Up".
BUTTON_DPAD_DOWN = 7Button "Down".
BUTTON_DPAD_LEFT = 8Button "Left".
BUTTON_DPAD_RIGHT = 9Button "Right".
BUTTON_THUMB_LEFT = 10Left thumbstick button.
BUTTON_THUMB_RIGHT = 11Right thumbstick button.
BUTTON_SHOULDER_LEFT = 12Left shoulder (bumper) button.
BUTTON_SHOULDER_RIGHT = 13Right shoulder (bumper) button.
NUM_BUTTONS = 14Number of buttons on a game pad.

AXIS#

Name说明/描 述
AXIS_LEFT_X = 0X axis of the left stick.
AXIS_LEFT_Y = 1Y axis of the left stick.
AXIS_RIGHT_X = 2X axis of the right stick.
AXIS_RIGHT_Y = 3Y axis of the right stick.
AXIS_LEFT_TRIGGER = 4Left trigger.
AXIS_RIGHT_TRIGGER = 5Right trigger.
NUM_AXES = 6Number of axes on a game pad.

MODEL_TYPE#

Name说明/描 述
MODEL_TYPE_UNKNOWN = 0Unknown model.
MODEL_TYPE_XBOX_360 = 1Xbox 360.
MODEL_TYPE_XBOX_ONE = 2Xbox One.
MODEL_TYPE_PS3 = 3PlayStation 3.
MODEL_TYPE_PS4 = 4PlayStation 4.
MODEL_TYPE_PS5 = 5PlayStation 5.

Members


int getNumber ( ) const#

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

Return value

Game pad number.

const char * getName ( ) const#

Returns the name of the game pad.

Return value

User-friendly name of the game pad. One of the following:
  • GamePad
  • Wheel
  • Arcade Stick
  • Flight Stick
  • Dance Pad
  • Guitar
  • Drum Kit
  • Unknown

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 ( ) const#

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

The filter of the gamepad.

Math::vec2 getAxesLeft ( ) const#

Returns a vector of axes of the left thumbstick. When a thumbstick is in the center position, this value is [0,0]. The values correspond to the following thumbstick positions:
  • First value corresponds to the X axis. Negative values indicate the left position; positive values indicate right.
  • Second value corresponds to the Y axis. Negative values indicate the down position; positive values indicate up.

Return value

A vector of two values in the [-1;1] range.

Math::vec2 getAxesLeftDelta ( ) const#

Returns a vector of delta values of the left thumbstick axes — the difference between the values in the previous and the current frames.

Return value

Vector of delta axes.

Math::vec2 getAxesRight ( ) const#

Returns a vector of axes of the right thumbstick. When a thumbstick is in the center position, this value is [0,0]. The values correspond to the following thumbstick positions:
  • First value corresponds to the X axis. Negative values indicate the left position; positive values indicate right.
  • Second value corresponds to the Y axis. Negative values indicate the down position; positive values indicate up.

Return value

A vector of two values in the [-1;1] range.

Math::vec2 getAxesRightDelta ( ) const#

Returns a vector of delta values of the right thumbstick axes — the difference between the values in the previous and the current frames.

Return value

Vector of delta axes.

float getTriggerLeft ( ) const#

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

Return value

Value in range [0; 1].

float getTriggerLeftDelta ( ) const#

Returns the delta value of the left trigger — the difference between the values in the previous and the current frame.

Return value

Left trigger delta.

float getTriggerRight ( ) const#

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

Return value

Value in range [0; 1].

float getTriggerRightDelta ( ) const#

Returns the delta value of the right trigger — the difference between the values in the previous and the current frame.

Return value

Right trigger delta.

void setVibration ( float low_frequency, float high_frequency, float duration_ms = 100.0f ) #

Sets the amount of vibration for the right (high-frequency) and left (low-frequency) motors for the time period specified in milliseconds.

Arguments

  • float low_frequency - Vibration value in the [0.0f; 1.0f] range for the left (low-frequency) motor.
  • float high_frequency - Vibration value in the [0.0f; 1.0f] range for the right (high-frequency) motor.
  • float duration_ms - Vibration period duration, in milliseconds.

bool isAvailable ( ) const#

Checks if the game pad is available.

Return value

true if the game pad is available; otherwise, false.

bool isButtonPressed ( InputGamePad::BUTTON button ) const#

Returns a value indicating if the given button is pressed.

Arguments

Return value

true if the button is pressed; otherwise, false.

bool isButtonDown ( InputGamePad::BUTTON button ) const#

Returns a value indicating if the given button was pressed during the current frame.

Arguments

Return value

true if the button was pressed during the current frame; otherwise, false.

bool isButtonUp ( InputGamePad::BUTTON button ) const#

Returns a value indicating if the given button was released during the current frame.

Arguments

Return value

true if the button was released during the current frame; otherwise, false.

int getPlayerIndex ( ) const#

Returns the index of player for the gamepad. Some devices support connection of multiple players (e.g., XBox 360 supports up to four players connected through XBox 360 gamepads). This method enables you to get this index.

Return value

Player index for the gamepad.

Input::DEVICE_TYPE getDeviceType ( ) const#

Returns a value indicating the type of the device (wheel, throttle, etc.).

Return value

Device type. One of the Input::DEVICE_TYPE_* values.

InputGamePad::MODEL_TYPE getModelType ( ) const#

Returns a value indicating the game pad model type.

Return value

Game pad model type identifier.
Last update: 2022-12-14
Build: ()