Unigine::ControlsApp Class
Header: | #include <UnigineControls.h> |
This class handles input from the current application window.
See Also#
- The Basic Object Movements usage example demonstrating how to set control keys
ControlsApp Class
Members
void setAlwaysRun ( int run ) #
Sets a value indicating if the player is running by default. If the player is in this mode, the Run control will switch them to walking. The default is 0. This parameter is stored in the following configuration file:Arguments
- int run - Positive integer to make the player run by default; otherwise, 0.
int getAlwaysRun ( ) #
Returns a value indicating if the player is running by default. If the player is in this mode, the Run control will switch them to walking. This parameter is stored in the following configuration file:Return value
1 if the player is running by default; otherwise, 0.void setEnabled ( bool enabled ) #
Enables or disables input handling for current application window.Arguments
- bool enabled - true to enable input handling for current application window, false to disable it.
bool isEnabled ( ) #
Returns a value indicating if input handling for current application window is enabled.Return value
true if input handling for current application window is enabled; otherwise, false.void setMouseDX ( float mousedx ) #
Updates a screen position change of the mouse pointer along the X axis.Arguments
- float mousedx - Change of the X coordinate.
float getMouseDX ( ) #
Returns a screen position change of the mouse pointer along the X axis during the last frame.Return value
Change of the X coordinate.void setMouseDY ( float mousedy ) #
Updates a screen position change of the mouse pointer along the Y axis.Arguments
- float mousedy - Change of the Y coordinate.
float getMouseDY ( ) #
Returns a screen position change of the mouse pointer along the Y axis during the last frame.Return value
Change of the Y coordinate.void setMouseEnabled ( bool enabled ) #
Enables or disables the mouse input.Arguments
- bool enabled - Positive integer to enable the mouse; otherwise, 0.
bool isMouseEnabled ( ) #
Returns a value indicating if the mouse is enabled.Return value
1 if the mouse is enabled; otherwise, 0.void setMouseInverse ( bool inverse ) #
Sets back-and-forth movements of the mouse (by Y-axis) to be interpreted as inverted: when the mouse is moved upward, the camera looks downwards, and when the mouse is moved downwards, the camera looks upwards. This mode is available only to control the camera. This parameter is stored in the following configuration file:Arguments
- bool inverse - true to inverse the mouse; otherwise, false.
bool isMouseInverse ( ) #
Returns a value indicating if back-and-forth movements of the mouse (by Y-axis) are inverted: when the mouse is moved upward, the camera looks downwards, and when the mouse is moved downwards, the camera looks upwards. This mode is available only to control the camera. This parameter is stored in the following configuration file:Return value
true if the mouse is inverted; otherwise, false.void setMouseRawInput ( bool input ) #
Sets a value indicating which type of mouse data is used to control the camera — raw (Input::getMouseDeltaRaw()) or processed by the OS (Input::getMouseDeltaPosition()).Arguments
- bool input - true to use raw mouse data to control the camera; false to use the mouse data as processed by the OS (system acceleration, various user settings).
bool isMouseRawInput ( ) const#
Returns a value indicating which type of mouse data is used to control the camera — raw (Input::getMouseDeltaRaw()) or processed by the OS (Input::getMouseDeltaPosition()).Return value
true if raw mouse data are used to control the camera; false — the mouse data as processed by the OS (system acceleration, various user settings).void setMouseSensitivity ( float sensitivity ) #
Sets mouse sensitivity used to increase or decrease the speed of mouse movement. This parameter is stored in the following configuration file:Arguments
- float sensitivity - Mouse sensitivity. Higher values increase the mouse speed; lower values decrease it.
float getMouseSensitivity ( ) #
Returns the current mouse sensitivity used to increase or decrease the speed of mouse movement. This parameter is stored in the following configuration file:Return value
Mouse sensitivity.void setState ( int state, int value ) #
Updates the state of a given control (sets the control on or off).Arguments
- int state - Control state number to update. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls
- int value - State value: positive value to "press" the control; 0 to release it.
int getState ( int state ) #
Returns the state of a given control.Arguments
- int state - Control state number. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls
Return value
State value: positive value means the control is "pressed"; 0 means the control is released.void setStateMouseButton ( int state, int button ) #
Sets a mouse button that switches a given state on and off. This parameter is stored in the following configuration file:Arguments
- int state - State (one of CONTROLS_STATE_* variables).
- int button - Button that toggles the state (one of MOUSE_BUTTON* variables).
int getStateMouseButton ( int state ) #
Returns a mouse button that switches a given state on and off. This parameter is stored in the following configuration file:Arguments
- int state - State (one of CONTROLS_STATE_* variables).
Return value
Button that toggles the state (one of MOUSE_BUTTON* variables).int isStateMouseButton ( int button ) #
Returns a value indicating if the given button assigned to the state.Arguments
- int button - Button that toggles the state (one of MOUSE_BUTTON* variables).
Return value
1 if the given button is assigned; otherwise, 0.void getStateEvent ( int state ) #
Lets the user assign a key or a mouse button to a given state.Arguments
- int state - State (one of the CONTROLS_STATE_* variables), to which a key or a mouse button is going to be assigned.
int isStateEvent ( ) #
Returns a value indicating if a key or a mouse button is successfully assigned to a state.Return value
1 if a key or a mouse button is already assigned; otherwise, 0.void setStateKey ( int state, int key ) #
Sets a key that toggles a given state on and off. This parameter is stored in the following configuration file:Arguments
- int state - State (one of CONTROLS_STATE_* variables).
- int key - Key that switches the state. It is a standard ASCII key code or one of the KEY* variables.
int getStateKey ( int state ) #
Returns a key that toggles a given state on and off. This parameter is stored in the following configuration file:Arguments
- int state - State (one of CONTROLS_STATE_* variables).
Return value
Key that switches the state. It is a standard ASCII key code or one of the KEY* variables:- KEY_ESC = 256
- KEY_TAB
- KEY_BACKSPACE
- KEY_RETURN
- KEY_DELETE
- KEY_INSERT
- KEY_HOME
- KEY_END
- KEY_PGUP
- KEY_PGDOWN
- KEY_LEFT
- KEY_RIGHT
- KEY_UP
- KEY_DOWN
- KEY_SHIFT
- KEY_CTRL
- KEY_ALT
- KEY_SCROLL
- KEY_CAPS
- KEY_NUM
- KEY_F1
- KEY_F2
- KEY_F3
- KEY_F4
- KEY_F5
- KEY_F6
- KEY_F7
- KEY_F8
- KEY_F9
- KEY_F10
- KEY_F11
- KEY_F12
int isStateKey ( int key ) #
Checks if a given key already acts as an application control. This is useful to avoid collisions between application controls and hot keys.Arguments
- int key - Key in one of the following formats:
- Character format (for example, 'a')
- Standard ASCII key code (for example, 97)
- One of KEY* variables
Return value
1 if the key is assigned to a state; otherwise, 0.String getStateName ( int state ) #
Returns the name of the given control state.Arguments
- int state - The control state number in range from 0 to the total number of states.
Return value
Name of the given control state.String getStateInfo ( int state ) const#
Returns the information about the given control state.Arguments
- int state - The control state number in range from 0 to the total number of states.
Return value
String containing information about the given control state.int clearState ( int state ) #
Returns a control state and clears it to 0 (control is not pressed).Arguments
- int state - Control state number. Possible values are in range [ STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.
Return value
1 if the control is pressed; otherwise, 0.void setMouseHandle ( Input::MOUSE_HANDLE handle ) #
Sets the mouse behavior mode. This parameter is stored in the following configuration file:Arguments
- Input::MOUSE_HANDLE handle - Mouse behavior mode, one of the MOUSE_HANDLE_* values.
Input::MOUSE_HANDLE getMouseHandle ( ) #
Returns the mouse behavior mode. This parameter is stored in the following configuration file:Return value
Mouse behavior mode, one of the MOUSE_HANDLE_* values.static void setPath ( const char * path ) #
Console: controls_config
Sets a new path to the controls configuration file (default: configs/default.controls). The path can be specified as an absolute path or relative to the -data_path or <project_name> folder if the -project_name is set. This parameter is stored in the following configuration file: Arguments
- const char * path - New path to the controls configuration file to be set.
static const char * getPath ( ) const#
Console: controls_config
Returns the current path to the controls configuration file (default: configs/default.controls). This parameter is stored in the following configuration file: Return value
Current path to the controls configuration file.void setRemoveGrabKey ( Input::KEY key ) #
Sets a new key to be used to switch off the grab mode of the mouse pointer (mouse pointer is bound to the application window). See this example for more information on mouse pointer modes and customization.Arguments
- Input::KEY key - New key to be used to switch off the grab mode of the mouse pointer.
Input::KEY getRemoveGrabKey ( ) const#
Returns the key currently used to switch off the grab mode of the mouse pointer (mouse pointer is bound to the application window). See this example for more information on mouse pointer modes and customization.Return value
Current key used to switch off the grab mode of the mouse pointer.static void setAutosave ( bool autosave ) #
Console: controls_config_autosave
Sets a value indicating if current controls configuration settings are automatically saved to the corresponding config file on loading, closing, and saving the world, as well as on the Engine shutdown. This parameter is stored in the following configuration file: Arguments
- bool autosave - true to enable automatic saving of current controls configuration settings; false — to disable it.
static bool isAutosave ( ) const#
Console: controls_config_autosave
Returns a value indicating if current controls configuration settings are automatically saved to the corresponding config file on loading, closing, and saving the world, as well as on the Engine shutdown. This parameter is stored in the following configuration file: Return value
true if automatic saving of current controls configuration settings is enabled; otherwise, 0.int load ( ) #
Console: controls_config_load
Loads controls configuration settings from a controls configuration file (configs/default.controls by default). To change the path to the controls configuration file use the setPath() method.Return value
1 if controls configuration settings are successfully loaded from a file; otherwise, 0.int save ( ) const#
Console: controls_config_save
Saves controls configuration settings to a controls configuration file (configs/default.controls by default). To change the path to the controls configuration file use the setPath() method.Return value
1 if controls configuration settings are successfully saved to a file; otherwise, 0.Last update:
2024-04-19
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)