This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
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
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.

Unigine.Input Class

The Input class contains functions for simple manual handling of user inputs using a keyboard, a mouse or a game pad.

This class represents an engine's singleton.

Usage Example#

The following example shows a way to move and rotate a node by using the Input class:

Source code (C#)
void Update()
{
	float move_speed = 1.0f;
	float turn_speed = 5.0f;

    if (Console.Activity)
    	return;

	vec3 direction = node.GetWorldDirection(MathLib.AXIS.Y);
	if (Input.IsKeyPressed(Input.KEY.UP) || Input.IsKeyPressed(Input.KEY.W))
	{
		node.WorldPosition += direction * move_speed * Engine.ifps;
	}
	
	if (Input.IsKeyPressed(Input.KEY.DOWN) || Input.IsKeyPressed(Input.KEY.S))
	{
	    node.WorldPosition -= direction * move_speed * Engine.ifps;
	}
	
	if (Input.IsKeyPressed(Input.KEY.LEFT) || Input.IsKeyPressed(Input.KEY.A))
	{
	    node.Rotate(0.0f, 0.0f, turn_speed * Engine.ifps);
	}
	
	if (Input.IsKeyPressed(Input.KEY.RIGHT) || Input.IsKeyPressed(Input.KEY.D))
	{
	    node.Rotate(0.0f, 0.0f, -turn_speed * Engine.ifps);
	}
}

Input Class

Enums

KEY#

NameDescription
SPACE = ' 'Space key
EXCLAIM = '!'Exclamation mark key
DOUBLE_QUOTE = '"'Double quote key
HASH = '#'Hash key
DOLLAR = '$'Dollar key
PERCENT = '%'Percent key
AMPERSAND = '&'Ampersand key
QUOTE = '\''Quote key
APOSTROPHE = '\''Apostrophe key ( KEY_APOSTROPHE = KEY_QUOTE)
LEFT_PAREN = '('Left parenthesis key
RIGHT_PAREN = ')'Right parenthesis key
ASTERISK = '*'Asterisk key
PLUS = '+'Plus key
COMMA = ','Comma key
MINUS = '-'Minus key
DOT = '.'Dot key
SLASH = '/'Slash key
COLON = ':'Colon key
SEMICOLON = ';'Semicolon key
LESS = '<'Less than key
EQUALS = '='Equals key
GREATER = '>'Greater than key
QUESTION = '?'Question key
AT = '@'At key
LEFT_BRACKET = '['Left square bracket key
BACK_SLASH = '\\'Back slash key
RIGHT_BRACKET = ']'Right square bracket key
CARET = '^'Caret key
UNDERSCORE = '_'Underscore key
BACK_QUOTE = '`'Back quote key
DIGIT_0 = '0'The 0 key of the alphanumeric keyboard
DIGIT_1 = '1'The 1 key of the alphanumeric keyboard
DIGIT_2 = '2'The 2 key of the alphanumeric keyboard
DIGIT_3 = '3'The 3 key of the alphanumeric keyboard
DIGIT_4 = '4'The 4 key of the alphanumeric keyboard
DIGIT_5 = '5'The 5 key of the alphanumeric keyboard
DIGIT_6 = '6'The 6 key of the alphanumeric keyboard
DIGIT_7 = '7'The 7 key of the alphanumeric keyboard
DIGIT_8 = '8'The 8 key of the alphanumeric keyboard
DIGIT_9 = '9'The 9 key of the alphanumeric keyboard
A = 'a'A key
B = 'b'B key
C = 'c'C key
D = 'd'D key
E = 'e'E key
F = 'f'F key
G = 'g'G key
H = 'h'H key
I = 'i'I key
J = 'j'J key
K = 'k'K key
L = 'l'L key
M = 'm'M key
N = 'n'N key
O = 'o'O key
P = 'p'P key
Q = 'q'Q key
R = 'r'R key
S = 's'S key
T = 't'T key
U = 'u'U key
V = 'v'V key
W = 'w'W key
X = 'x'X key
Y = 'y'Y key
Z = 'z'Z key
ESC = 256Escape key
TAB = 257Tab key
BACKSPACE = 258Backspace key
RETURN = 259Return key
DELETE = 260Delete
INSERT = 261Insert key
HOME = 262Home key
END = 263End key
PGUP = 264Page Up key
PGDOWN = 265Page down
LEFT = 266Left arrow key
RIGHT = 267Right arrow key
UP = 268Up arrow key
DOWN = 269Down arrow key
SHIFT = 270Shift key
CTRL = 271Control key
ALT = 272Alt key
CMD = 273Command key
SCROLL = 274Scroll lock key
CAPS = 275Caps lock key
NUM = 276Num lock key
F1 = 277F1 key
F2 = 278F2 key
F3 = 279F3 key
F4 = 280F4 key
F5 = 281F5 key
F6 = 282F6 key
F7 = 283F7 key
F8 = 284F8 key
F9 = 285F9 key
F10 = 286F10 key
F11 = 287F11 key
F12 = 288F12 key
NUM_KEYS = 289The number of all keys

MOUSE_BUTTON#

NameDescription
LEFT = 0Left mouse button
MIDDLE = 1Middle mouse button
RIGHT = 2Right mouse button
DCLICK = 3Left mouse button double click
AUX_0 = 4Auxiliary mouse button
AUX_1 = 5Auxiliary mouse button
AUX_2 = 6Auxiliary mouse button
AUX_3 = 7Auxiliary mouse button
MOUSE_NUM_BUTTONS = 8Number of mouse buttons

MOUSE_HANDLE#

NameDescription
GRAB = 0The mouse is grabbed when clicked (the cursor disappears and camera movement is controlled by the mouse).
SOFT = 1The mouse cursor disappears after being idle for a short time period.
USER = 2The mouse is not handled by the system (allows input handling by some custom module).

Properties

int CountActiveGamePads#

The number of active game pads.

int CountGamePads#

The number of all game pads.

int MouseWheelHorizontal#

The horizontal mouse scroll value.

int MouseWheel#

The vertical mouse scroll value.

vec2 MouseDelta#

Vector containing delta values of the mouse cursor position.

ivec2 MouseCoordDelta#

Vector containing integer delta values of the mouse cursor position.

ivec2 MouseCoord#

Vector containing integer values of the mouse cursor position.

Input.MOUSE_HANDLE MouseHandle#

The mouse behavior mode, one of the MOUSE_HANDLE values.
set
Sets the mouse behavior mode.
set value - Mouse behavior mode, one of the MOUSE_HANDLE values.

Members


InputGamePad GetGamePad ( int num ) #

Returns a game pad of the given index.

Arguments

  • int num - index.

Return value

InputGamepad object.

InputGamePad GetActiveGamePad ( int num ) #

Returns an active game pad of the given index.

Arguments

  • int num - index.

Return value

InputGamePad object.

bool IsKeyPressed ( Input.KEY key ) #

Returns a value indicating if the given key is pressed or not. Check this value to perform continuous actions.
Source code (C#)
if (Input.IsKeyPressed(Input.KEY.RETURN)) {
	Log.Message("enter key is held down\n");
}

Arguments

  • Input.KEY key - One of the Input.KEY enum values.

Return value

True if the key is pressed; otherwise, false.

bool IsKeyDown ( Input.KEY key ) #

Returns a value indicating if the given key was pressed during the current frame or not. Check this value to perform one-time actions on pressing a key.
Source code (C#)
if (Input.IsKeyDown(Input.KEY.SPACE)) {
	Log.Message("space key was pressed\n");
}

Arguments

  • Input.KEY key - One of the Input.KEY enum values.

Return value

True during the first frame when the key was pressed, false for the following ones until it is released and pressed again.

bool IsKeyUp ( Input.KEY key ) #

Returns a value indicating if the given key was released during the current frame or not. Check this value to perform one-time actions on releasing a key.
Source code (C#)
if (Input.IsKeyUp(Input.KEY.F)) {
	Log.Message("f key was released\n");
}

Arguments

  • Input.KEY key - One of the Input.KEY enum values.

Return value

True during the first frame when the key was released; otherwise, false.

bool IsMouseButtonPressed ( Input.MOUSE_BUTTON button ) #

Returns a value indicating if the given mouse button is pressed or not. Check this value to perform continuous actions.
Source code (C#)
if (Input.IsMouseButtonPressed(Input.MOUSE_BUTTON.LEFT)) {
	Log.Message("left mouse button is held down\n");
}

Arguments

Return value

True if the mouse button is pressed; otherwise, false.

bool IsMouseButtonDown ( Input.MOUSE_BUTTON button ) #

Returns a value indicating if the given mouse button was pressed during the current frame or not. Check this value to perform one-time actions on pressing a mouse button.
Source code (C#)
if (Input.IsMouseButtonDown(Input.MOUSE_BUTTON.LEFT)) {
	Log.Message("left mouse button was pressed\n");
}

Arguments

Return value

True during the first frame when the mouse button was released; otherwise, false.

bool IsMouseButtonUp ( Input.MOUSE_BUTTON button ) #

Returns a value indicating if the given mouse button was released during the current frame or not. Check this value to perform one-time actions on releasing a mouse button.
Source code (C#)
if (Input.IsMouseButtonUp(Input.MOUSE_BUTTON.LEFT)) {
	Log.Message("left mouse button was released\n");
}

Arguments

Return value

True during the first frame when the mouse button was released; otherwise, false.
Last update: 2020-09-23
Build: ()