UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and 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
CIGI Client Plugin
Rendering-Related Classes

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 a singleton of the Engine class and can be accessed via the following way:

Source code (C#)
Engine.input

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 (Engine.console.Activity)
    	return;

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

Properties

int CountActiveGamePads#

The number of active game pads.

int CountGamePads#

The number of all game pads.

int MouseShow#

The value indicating if the OS mouse pointer should be displayed.
set
Sets the value indicating if the OS mouse pointer should be displayed.
set value - 1 if the OS mouse pointer should be displayed; 0 if the application cursor is used only.

int MouseGrab#

The value indicating if the mouse pointer is bound to the application window.
set
Sets the value indicating if the mouse pointer is bound to the application window.
set value - 1 if the mouse cannot leave the application window; otherwise, 0.

int MouseWheelHorizontalDelta#

The horizontal mouse scroll delta.

int MouseWheelHorizontal#

The horizontal mouse scroll value.

int MouseWheelDelta#

The vertical mouse scroll delta.

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.

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 (Engine.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 (Engine.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 (Engine.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 (Engine.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 (Engine.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 (Engine.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: 2019-08-16