engine.inputjoystick Functions
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.
This class handles joystick input. Generic joysticks can be hot-plugged. So, you can connect your joystick before or after create an instance of this class.
The InputJoystick class provides access to the following controller input:
- Axes detect movement along X and Y axes (if a joystick is two-axis, which is the most typical case) and along Z axis (if it is three-axis one). Two-axis joysticks are configured in such a way that left-to-right movement of the stick is mapped to the movement along the X axis, while movement from backward to forward (down-up) indicates movement along the Y axis. In case of 3D joystick, twisting the stick to the left (counter-clockwise) or to the right (clockwise) corresponds to movement along the Z axis.
Axes are quired for their states via getAxis(). To provide smooth interpolation between frames and avoid jerks, axis values can be filtered via setFilter(). - Buttons correspond to the controller's buttons and can be either pressed or released in the current frame, or continuously pressed for multiple frames in a row including the current one.
- POV (Point-Of-View) hat switches indicate the direction of view and support a number of positions such as left, right, up and down (similar to a D-pad).
InputJoystick Class
Members
int getPlayerIndex ( ) #
Returns the index of player for the joystick. 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 joystick.int isAvailable ( ) #
Returns a value indicating if the joystick is available.Return value
1 if the joystick is available; otherwise, 0.string getName ( ) #
Returns the name of the joystick.Return value
Joystick name.int getNumber ( ) #
Returns the joystick number.Return value
Joystick number.int getDeviceType ( ) #
Returns a value indicating the type of the device (wheel, throttle, etc.).Return value
Device type. One of the DEVICE_* values of the Input class.void setFilter ( float filter ) #
Sets a filter value used to correct the current state of the joystick axis relative to the previous one.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 joystick axis 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.int getNumAxes ( ) #
Returns the number of axes supported by the joystick.Return value
Number of axes for the joystick.float getAxis ( unsigned int axis ) #
Returns a state value for the axis win the specified number. It includes position of the joystick along the following axes: X, Y (two-axis joystick) and Z (three-axis joystick). When a joystick is in the center position, X and Y axes values are zero. Negative values indicate left or down; positive values indicate right or up.Arguments
- unsigned int axis - Axis number.
Return value
Value in range [-1; 1].float getAxisDelta ( unsigned int axis ) #
Arguments
- unsigned int axis - Axis number.
string getAxisName ( unsigned int axis ) #
Returns the name of a given axis by its number.Arguments
- unsigned int axis - Axis number.
Return value
Axis name.int getNumPovs ( ) #
Returns the number of POV hat switches supported by the joystick.Return value
Number of POV hats.int getPov ( unsigned int pov ) #
Returns a POV hat switch state. POV hats support the following positions: left, right, up and down.Arguments
- unsigned int pov - POV hat number.
Return value
POV hat state. One of the JOYSTICK_POV values of the Input class.string getPovName ( unsigned int pov ) #
Returns the name of a given POV hat switch.Arguments
- unsigned int pov - POV hat number.
Return value
POV hat name.int getNumButtons ( ) #
Returns the number of buttons supported by the joystick.Return value
Number of buttons.int isButtonPressed ( unsigned int key ) #
Returns a value indicating if the button with the specified number is pressed. Check this value to perform continuous actions.Arguments
- unsigned int key - Button number.
Return value
1 if the button with the specified number is pressed; otherwise - 0 (pressed).int isButtonDown ( unsigned int key ) #
Returns a value indicating if the button with the specified number was pressed during the current frame.Arguments
- unsigned int key - Button number.
Return value
1 if the button with the specified number was pressed during the current frame; otherwise - 0 (pressed).int isButtonUp ( unsigned int key ) #
Returns a value indicating if the button with the specified number was released during the current frame.Arguments
- unsigned int key - Button number.
Return value
1 if the button with the specified number was released during the current frame; otherwise - 0.string getButtonName ( unsigned int button ) #
Returns the name of the button with the specified number.Arguments
- unsigned int button - Button number.
Return value
Button name.InputEventJoyButton getButtonEvent ( int button ) #
Returns the currently processed joystick button input event.Arguments
- int button - Button number.
Return value
Joystick button input event, or null if there are no events for the specified joystick button in the current frame.InputEventJoyPovMotion getPovEvent ( int pov ) #
Returns the currently processed joystick POV hat input event.Arguments
- int pov - POV hat number.
Return value
Joystick POV hat input event, or null if there are no events for the specified joystick POV hat in the current frame.string getGuid ( ) #
Returns the GUID created on the basis of vendor and product identifiers and product version number. It enables you to identify device model (Controller XBox One, etc.), however, it will be the same for two identical models.Return value
Device model GUID.int getVendor ( ) #
Returns a unique identifier of the device manufacturer (vendor). This can be very useful in case your application uses non-standard custom input devices to ensure proper configuration (dead zones, inverse flags, correction curves, etc.).Return value
Unique identifier of the device manufacturer (vendor).int getProduct ( ) #
Returns a unique identifier for the product (GUID). This identifier is established by the manufacturer of the device. This can be very useful in case your application uses non-standard custom input devices to ensure proper configuration (dead zones, inverse flags, correction curves, etc.).Return value
Unique identifier for the product (GUID).int getProductVersion ( ) #
Returns the version of the product established by the manufacturer of the device. This can be very useful in case your application uses non-standard custom input devices to ensure proper configuration (dead zones, inverse flags, correction curves, etc.).Return value
Version of the product established by the manufacturer of the device.Last update:
2023-04-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)