This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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 gamepad.

This class represents an engine's singleton.

See Also#

  • Input sample in C# Component Samples suite

Usage Examples#

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

Source code (C#)
private Node box = null;

private const float moveSpeed = 1.0f;
private const float turnSpeed = 30.0f;

private void Init()
{

	box = Primitives.CreateBox(vec3.ONE);

}

private void Update()
{

	if (Unigine.Console.Active)
		return;

	if (Input.IsKeyPressed(Input.KEY.UP) || Input.IsKeyPressed(Input.KEY.W))
		box.Translate(vec3.FORWARD * moveSpeed * Game.IFps);

	if (Input.IsKeyPressed(Input.KEY.DOWN) || Input.IsKeyPressed(Input.KEY.S))
		box.Translate(vec3.BACK * moveSpeed * Game.IFps);

	if (Input.IsKeyPressed(Input.KEY.LEFT) || Input.IsKeyPressed(Input.KEY.A))
		box.Rotate(0.0f, 0.0f, turnSpeed * Game.IFps);

	if (Input.IsKeyPressed(Input.KEY.RIGHT) || Input.IsKeyPressed(Input.KEY.D))
		box.Rotate(0.0f, 0.0f, -turnSpeed * Game.IFps);

}

The following code demonstrates how to receive an event that changed the button state to IsKeyDown, IsKeyUp. Such code can also be used for the mouse and touch buttons.

Source code (C#)
private void Update()
{

	if (Input.IsKeyDown(Input.KEY.T) || Input.IsKeyUp(Input.KEY.T))
		{
			InputEventKeyboard e = Input.GetKeyEvent(Input.KEY.T);
			Unigine.Console.MessageLine($"{Input.GetKeyName(e.Key)} {e.Action} time = {e.Timestamp} frame = {e.Frame}");
		}
}

The following code illustrates receiving the immediate input — the user receives the event notification immediately after filtering:

Source code (C#)
private void Init()
{

	Input.AddCallback(Input.CALLBACK_INDEX.IMMEDIATE_INPUT, OnImmediateInput);

}

private void OnImmediateInput(InputEvent e)
{
	switch (e.Type)
	{
		case InputEvent.TYPE.INPUT_EVENT_KEYBOARD:
		{
			InputEventKeyboard k = e as InputEventKeyboard;
			Unigine.Console.MessageLine($"keyboard event: {Input.GetKeyName(k.Key)} {k.Action}");
			break;
		}

		case InputEvent.TYPE.INPUT_EVENT_MOUSE_BUTTON:
		{
			InputEventMouseButton m = e as InputEventMouseButton;
			Unigine.Console.MessageLine($"mouse button event: {Input.GetMouseButtonName(m.Button)} {m.Action}");
			break;
		}

		default: break;
	}
}

The following code illustrates how the event filter works. Pressing the "W" button and mouse movements will be declined, i.e. these events won't be taken as input:

Source code (C#)
private void Init()
{

	Input.SetEventsFilter(EventFilter);

}

private int EventFilter(InputEvent e)
{
	switch (e.Type)
	{
		case InputEvent.TYPE.INPUT_EVENT_KEYBOARD:
		{
			// skip 'W' key repeat events
			InputEventKeyboard k = e as InputEventKeyboard;
			if (k.Key == Input.KEY.W && k.Action == InputEventKeyboard.ACTION.REPEAT)
				return 1;
			break;
		}

		case InputEvent.TYPE.INPUT_EVENT_MOUSE_MOTION:
		{
			// skip all mouse motion events
			return 1;
		}

		default: break;
	}

	return 0;
}

The following code is an example of input events creation. We'll imitate the input of the show_profiler 1 console command as if it were an event from the keyboard.

Source code (C#)
enum STATE
{
	OPEN_CONSOLE = 0,
	TYPING_COMMAND,
	APPLY_COMMAND,
	FINISH,
}

private STATE state = STATE.OPEN_CONSOLE;
private string command = "show_profiler 1";

private void Update()
{

	switch (state)
	{
		case STATE.OPEN_CONSOLE:
		{
			InputEventKeyboard key = new InputEventKeyboard();
			key.Action = InputEventKeyboard.ACTION.DOWN;
			key.Key = Input.KEY.BACK_QUOTE;
			Input.SendEvent(key);
			state = STATE.TYPING_COMMAND;
			break;
		}

		case STATE.TYPING_COMMAND:
		{
			for (int i = 0; i < command.Length; i++)
			{
				InputEventText text = new InputEventText();
				text.Unicode = (uint)command[i];
				Input.SendEvent(text);
			}
			state = STATE.APPLY_COMMAND;
			break;
		}

		case STATE.APPLY_COMMAND:
		{
			InputEventKeyboard key = new InputEventKeyboard();
			key.Action = InputEventKeyboard.ACTION.REPEAT;
			key.Key = Input.KEY.ENTER;
			Input.SendEvent(key);
			state = STATE.FINISH;
			break;
		}

		default: break;
	}
}

The following code demonstrates how to obtain various button names using the GetKeyName(), KeyToUnicode(), and GetKeyLocalName() methods:

Source code (C#)
/*...*/
using System.Linq;
using System.Text;

/*...*/

	private void Init()
	{

		Unigine.Console.Onscreen = true;

	}

	private void Update()
	{

		var printInfo = (string state, Input.KEY key) =>
		{
			uint unicode = Input.KeyToUnicode(key);
			string unicodeName = Encoding.Unicode.GetString(BitConverter.GetBytes(unicode));
			unicodeName = unicodeName.TrimEnd('\0');
			Unigine.Console.Message($"{state}: (key='{Input.GetKeyName(key)}', unicode='{unicodeName}', local_name='{Input.GetKeyLocalName(key)}') ");
		};

		printInfo("Up", Input.KEY.W);
		printInfo("Jump", Input.KEY.SPACE);
		printInfo("Run", Input.KEY.RIGHT_SHIFT);
		Unigine.Console.Message("\n");
	}

Input Class

Enums

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).

MOUSE_BUTTON#

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

MODIFIER#

NameDescription
LEFT_SHIFT = 0Left Shift key used as modifier.
RIGHT_SHIFT = 1Right Shift key used as modifier.
LEFT_CTRL = 2Left Ctrl key used as modifier.
RIGHT_CTRL = 3Right Ctrl key used as modifier.
LEFT_ALT = 4Left Alt key used as modifier.
RIGHT_ALT = 5Right Alt key used as modifier.
LEFT_CMD = 6Left Command key used as modifier.
RIGHT_CMD = 7Right Command key used as modifier.
NUM_LOCK = 8Num Lock key used as modifier.
CAPS_LOCK = 9Caps Lock key used as modifier.
SCROLL_LOCK = 10Scroll Lock key used as modifier.
ALT_GR = 11Alt Gr key used as modifier.
ANY_SHIFT = 12Any Shift key used as modifier.
ANY_CTRL = 13Any Ctrl key used as modifier.
ANY_ALT = 14Any Alt key used as modifier.
ANY_CMD = 15Any Command key used as modifier.
NONE = 16
NUM_MODIFIERS = 17

KEY#

NameDescription
UNKNOWN = 0Unknown key
ESC = 1Escape key
F1 = 2F1 key
F2 = 3F2 key
F3 = 4F3 key
F4 = 5F4 key
F5 = 6F5 key
F6 = 7F6 key
F7 = 8F7 key
F8 = 9F8 key
F9 = 10F9 key
F10 = 11F10 key
F11 = 12F11 key
F12 = 13F12 key
PRINTSCREEN = 14Print Screen key
SCROLL_LOCK = 15Scroll Lock key
PAUSE = 16Pause key
BACK_QUOTE = 17Back quote key
DIGIT_1 = 18The 1 key of the alphanumeric keyboard
DIGIT_2 = 19The 2 key of the alphanumeric keyboard
DIGIT_3 = 20The 3 key of the alphanumeric keyboard
DIGIT_4 = 21The 4 key of the alphanumeric keyboard
DIGIT_5 = 22The 5 key of the alphanumeric keyboard
DIGIT_6 = 23The 6 key of the alphanumeric keyboard
DIGIT_7 = 24The 7 key of the alphanumeric keyboard
DIGIT_8 = 25The 8 key of the alphanumeric keyboard
DIGIT_9 = 26The 9 key of the alphanumeric keyboard
DIGIT_0 = 27The 0 key of the alphanumeric keyboard
MINUS = 28Minus key
EQUALS = 29Equals key
BACKSPACE = 30Backspace key
TAB = 31Tab key
Q = 32Q key
W = 33W key
E = 34E key
R = 35R key
T = 36T key
Y = 37Y key
U = 38U key
I = 39I key
O = 40O key
P = 41P key
LEFT_BRACKET = 42Left square bracket key
RIGHT_BRACKET = 43Right square bracket key
ENTER = 44Enter key
CAPS_LOCK = 45Caps Lock key
A = 46A key
S = 47S key
D = 48D key
F = 49F key
G = 50G key
H = 51H key
J = 52J key
K = 53K key
L = 54L key
SEMICOLON = 55Semicolon key
QUOTE = 56Quote key
BACK_SLASH = 57Backward slash key
LEFT_SHIFT = 58Left Shift key
LESS = 59Less than key
Z = 60Z key
X = 61X key
C = 62C key
V = 63V key
B = 64B key
N = 65N key
M = 66M key
COMMA = 67Comma key
DOT = 68Dot key
SLASH = 69Slash key
RIGHT_SHIFT = 70Right Shift key
LEFT_CTRL = 71Left Ctrl key
LEFT_CMD = 72Left Command key
LEFT_ALT = 73Left Alt key
SPACE = 74Space key
RIGHT_ALT = 75Right Alt key
RIGHT_CMD = 76Right Command key
MENU = 77Menu key
RIGHT_CTRL = 78Right Ctrl key
INSERT = 79Insert key
DELETE = 80Delete key
HOME = 81Home key
END = 82End key
PGUP = 83Page Up key
PGDOWN = 84Page down
UP = 85Up arrow key
LEFT = 86Left arrow key
DOWN = 87Down arrow key
RIGHT = 88Right arrow key
NUM_LOCK = 89Num Lock key
NUMPAD_DIVIDE = 90Divide key of the numeric keypad
NUMPAD_MULTIPLY = 91Multiply key of the numeric keypad
NUMPAD_MINUS = 92Minus key of the numeric keypad
NUMPAD_DIGIT_7 = 93The 7 key of the numeric keypad
NUMPAD_DIGIT_8 = 94The 8 key of the numeric keypad
NUMPAD_DIGIT_9 = 95The 9 key of the numeric keypad
NUMPAD_PLUS = 96Plus key of the numeric keypad
NUMPAD_DIGIT_4 = 97The 4 key of the numeric keypad
NUMPAD_DIGIT_5 = 98The 5 key of the numeric keypad
NUMPAD_DIGIT_6 = 99The 6 key of the numeric keypad
NUMPAD_DIGIT_1 = 100The 1 key of the numeric keypad
NUMPAD_DIGIT_2 = 101The 2 key of the numeric keypad
NUMPAD_DIGIT_3 = 102The 3 key of the numeric keypad
NUMPAD_ENTER = 103Enter key of the numeric keypad
NUMPAD_DIGIT_0 = 104The 0 key of the numeric keypad
NUMPAD_DOT = 105Dot key of the numeric keypad
ANY_SHIFT = 106Any Shift key
ANY_CTRL = 107Any Ctrl key
ANY_ALT = 108Any Alt key
ANY_CMD = 109Any Command key
ANY_UP = 110Any up arrow key
ANY_LEFT = 111Any left arrow key
ANY_DOWN = 112Any down arrow key
ANY_RIGHT = 113Any right arrow key
ANY_ENTER = 114Any up arrow key
ANY_DELETE = 115Any Delete key
ANY_INSERT = 116Any Insert key
ANY_HOME = 117Any Home key
ANY_END = 118Any End key
ANY_PGUP = 119Any Page Up key
ANY_PGDOWN = 120Any Page Down key
ANY_DIGIT_1 = 121The 1 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_2 = 122The 2 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_3 = 123The 3 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_4 = 124The 4 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_5 = 125The 5 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_6 = 126The 6 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_7 = 127The 7 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_8 = 128The 8 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_9 = 129The 9 key of either alphanumeric keyboard or numeric keypad
ANY_DIGIT_0 = 130The 0 key of either alphanumeric keyboard or numeric keypad
ANY_MINUS = 131Any minus key
ANY_EQUALS = 132Any Equals key
ANY_DOT = 133Any dot key
NUM_KEYS = 134Number of keys.

CALLBACK_INDEX#

NameDescription
MOUSE_DOWN = 0Callback when the mouse button is pressed.
MOUSE_UP = 1Callback when the mouse button is released.
MOUSE_WHEEL = 2Callback when the mouse scroll wheel is moved.
MOUSE_WHEEL_HORIZONTAL = 3Callback when the mouse wheel is moved horizontally.
MOUSE_MOTION = 4Callback when the mouse is moved.
KEY_DOWN = 5Callback when the key is pressed and held.
KEY_UP = 6Callback when the key is released.
KEY_REPEAT = 7Callback when the key is pressed repeatedly.
TEXT_PRESS = 8Callback when the key that has a corresponding printable symbol is pressed.
TOUCH_DOWN = 9Callback when the touch is pressed.
TOUCH_UP = 10Callback when the touch is released.
TOUCH_MOTION = 11Callback when the touch is moved.
GAMEPAD_CONNECTED = 12Callback when a gamepad is connected. The callback signature is as follows:
Source code (C#)
void gamepad_connected_callback(uint index)
index - gamepad index.
GAMEPAD_DISCONNECTED = 13Callback when a gamepad is disconnected. The callback signature is as follows:
Source code (C#)
void gamepad_disconnected_callback(uint index)
index - gamepad index.
GAMEPAD_BUTTON_DOWN = 14Callback when a gamepad button is pressed. The callback signature is as follows:
Source code (C#)
void gamepad_button_down_callback(uint index, Input.GAMEPAD_BUTTON b)
index - gamepad index, b - gamepad button.
GAMEPAD_BUTTON_UP = 15Callback when a gamepad button is released. The callback signature is as follows:
Source code (C#)
void gamepad_button_up_callback(uint index, Input.GAMEPAD_BUTTON b)
index - gamepad index, b - gamepad button.
GAMEPAD_AXIS_MOTION = 16Callback when a gamepad axis state value is changed. The callback signature is as follows:
Source code (C#)
void gamepad_axis_callback(uint index, Input.GAMEPAD_AXIS a)
index - gamepad index, a - gamepad axis.
JOY_CONNECTED = 17Callback when a joystick is connected. The callback signature is as follows:
Source code (C#)
void joystick_connected_callback(uint index)
index - joystick index.
JOY_DISCONNECTED = 18Callback when a joystick is disconnected. The callback signature is as follows:
Source code (C#)
void joystick_disconnected_callback(uint index)
index - joystick index.
JOY_BUTTON_DOWN = 19Callback when a joystick button is pressed. The callback signature is as follows:
Source code (C#)
void joystick_button_down_callback(uint index, int b)
index - joystick index, b - button index.
JOY_BUTTON_UP = 20Callback when a joystick button is released. The callback signature is as follows:
Source code (C#)
void joystick_button_up_callback(uint index, int b)
index - joystick index, b - button index.
JOY_AXIS_MOTION = 21Callback when a joystick axis state value is changed. The callback signature is as follows:
Source code (C#)
void joystick_axis_callback(uint index, int a)
index - joystick index, a - axis index.
JOY_POV_MOTION = 22Callback when a joystick POV state value is changed. The callback signature is as follows:
Source code (C#)
void joystick_pov_callback(uint index, int pov)
index - joystick index, pov - pov index.
IMMEDIATE_INPUT = 23Callback that allows receiving input events immediately from proxy before being processed by the engine. This callback can be called in different threads depending on the proxy implementation.
NUM_CALLBACKS = 24Callback counter.

DEVICE_TYPE#

NameDescription
UNKNOWN = 0Unknown device.
GAME_CONTROLLER = 1Game controller device.
WHEEL = 2Wheel device.
ARCADE_STICK = 3Arcade stick device.
FLIGHT_STICK = 4Flight stick device.
DANCE_PAD = 5Dance pad device.
GUITAR = 6Guitar.
DRUM_KIT = 7Drum kit.
THROTTLE = 8Throttle device.

GAMEPAD_BUTTON#

Buttons of the gamepad.
NameDescription
A = 0Button A of the gamepad.
B = 1Button B of the gamepad.
X = 2Button X of the gamepad.
Y = 3Button Y of the gamepad.
BACK = 4Button "Back" of the gamepad.
START = 5Button "Start" of the gamepad.
DPAD_UP = 6Button "Up" of the gamepad.
DPAD_DOWN = 7Button "Down" of the gamepad.
DPAD_LEFT = 8Button "Left" of the gamepad.
DPAD_RIGHT = 9Button "Right" of the gamepad.
THUMB_LEFT = 10Left thumbstick button of the gamepad.
THUMB_RIGHT = 11Right thumbstick button of the gamepad.
SHOULDER_LEFT = 12Left shoulder (bumper) button of the gamepad.
SHOULDER_RIGHT = 13Right shoulder (bumper) button of the gamepad.
NUM_BUTTONS

GAMEPAD_AXIS#

NameDescription
LEFT_X = 0X axis of the left stick of the gamepad.
LEFT_Y = 1Y axis of the left stick of the gamepad.
RIGHT_X = 2X axis of the right stick of the gamepad.
RIGHT_Y = 3Y axis of the right stick of the gamepad.
LEFT_TRIGGER = 4Left trigger of the gamepad.
RIGHT_TRIGGER = 5Right trigger of the gamepad.
NUM_AXES

JOYSTICK_POV#

POV (Point-of-View) switch or DPad states.
NameDescription
NOT_PRESSED = 0POV (Point-of-View) hat switch or D-Pad (directional pad) button is not pressed.
UP = 1POV (Point-of-View) hat switch or D-Pad (directional pad) is in up position.
UP_RIGHT = 2POV (Point-of-View) hat switch or D-Pad (directional pad) is in right-up position.
RIGHT = 3POV (Point-of-View) hat switch or D-Pad (directional pad) is in right position.
DOWN_RIGHT = 4POV (Point-of-View) hat switch or D-Pad (directional pad) is in down-right position.
DOWN = 5POV (Point-of-View) hat switch or D-Pad (directional pad) is in down position.
DOWN_LEFT = 6POV (Point-of-View) hat switch or D-Pad (directional pad) is in down-left position.
LEFT = 7POV (Point-of-View) hat switch or D-Pad (directional pad) is in left position.
UP_LEFT = 8POV (Point-of-View) hat switch or D-Pad (directional pad) is in left-up position.

Properties

int NumJoysticks#

The number of joysticks.

int NumGamePads#

The number of all gamepads.

int MouseWheelHorizontal#

The horizontal mouse scroll value.

int MouseWheel#

The vertical mouse scroll value.

ivec2 MouseDeltaPosition#

The vector containing delta values of the mouse cursor position.

ivec2 MousePosition#

The vector containing integer values of the mouse cursor position.

Input.MOUSE_HANDLE MouseHandle#

The mouse behavior mode, one of the MOUSE_HANDLE values.

bool MouseCursorNeedUpdate#

The value indicating that changes were made to the cursor (it was shown, hidden, changed to system, or anything else) and it has to be updated. Suppose the cursor was modified, for example, by the Interface plugin. After closing the plugin's window the cursor shall not return to its previous state because SDL doesn't even know about the changes. You can use this flag to signalize, that mouse cursor must be updated.

bool MouseCursorSystem#

The value indicating if the os mouse pointer is displayed.

bool MouseCursorHide#

The value indicating if the mouse cursor is hidden in the current frame.

bool MouseGrab#

The value indicating if the mouse pointer is bound to the application window.

string Clipboard#

The contents of the system clipboard.

bool IsEmptyClipboard#

The value indicating if the clipboard is empty.

ivec2 MouseDeltaRaw#

The change in the absolute mouse position, dots per inch.

Members


InputGamePad GetGamePad ( int num ) #

Returns a gamepad of the given index.

Arguments

  • int num - Gamepad index.

Return value

InputGamepad object.

InputJoystick GetJoystick ( int num ) #

Returns a joystick with the given index.

Arguments

  • int num - Joystick index.

Return value

InputJoystick object.

bool IsKeyPressed ( Input.KEY key ) #

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

Arguments

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. Check this value to perform one-time actions on pressing a key.
Source code (C#)
if (Input.IsKeyDown(Input.KEY.SPACE)) {
	Log.Message("the Space key was pressed\n");
}

Arguments

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. Check this value to perform one-time actions on releasing a key.
Source code (C#)
if (Input.IsKeyUp(Input.KEY.F)) {
	Log.Message("the F key was released\n");
}

Arguments

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. Check this value to perform continuous actions.
Source code (C#)
if (Input.IsMouseButtonPressed(Input.MOUSE_BUTTON.LEFT)) {
	Log.Message("the 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. 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("the 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. 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.

bool IsTouchPressed ( int index ) #

Returns a value indicating if the touchscreen is pressed by the finger.

Arguments

  • int index - Touch input index.

Return value

true if the touchscreen is pressed; otherwise, false.

bool IsTouchDown ( int index ) #

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

Arguments

  • int index - Touch input index.

Return value

true if the touchscreen is pressed during the current frame; otherwise, false.

bool IsTouchUp ( int index ) #

Returns a value indicating if the given touch was released.

Arguments

  • int index - Touch input index.

Return value

true during the first frame when the touch was released; otherwise, false.

ivec2 GetTouchPosition ( int index ) #

Returns a vector containing integer values of touch position.

Arguments

  • int index - Touch input index.

Return value

The touch position.

ivec2 GetTouchDelta ( int index ) #

Returns a vector containing screen position change of the touch along the X and Y axes — the difference between the values in the previous and the current frames.

Arguments

  • int index - Touch input index.

Return value

The touch position delta.

InputEventTouch GetTouchEvent ( int index ) #

Returns the action cast to the touch event.

Arguments

  • int index - Touch input index.

Return value

Touch input event.

int GetTouchEvents ( int index, InputEventTouch[] events ) #

Returns the actions cast to the touch event.

Arguments

  • int index - Touch input index.
  • InputEventTouch[] events - The buffer with touch input events.

Return value

Number of touch input events.

InputEventKeyboard GetKeyEvent ( Input.KEY key ) #

Returns the currently processed keyboard input event.

Arguments

Return value

Keyboard input event, or null if there are no events for the specified key in the current frame.

int GetKeyEvents ( Input.KEY key, InputEventKeyboard[] events ) #

Returns the buffer with events for the specified key.

Arguments

string GetKeyName ( Input.KEY key ) #

Returns the specified key name.

Arguments

Return value

Key name.

Input.KEY GetKeyByName ( string name ) #

Returns the key by its name.

Arguments

  • string name - Key name.

Return value

One of the Input.KEY enum values.

InputEventMouseButton GetMouseButtonEvent ( Input.MOUSE_BUTTON button ) #

Returns the mouse motion input event for the specified button.

Arguments

Return value

Mouse motion input event.

string GetMouseButtonName ( Input.MOUSE_BUTTON button ) #

Returns the mouse button name.

Arguments

Return value

Mouse button name.

Input.MOUSE_BUTTON GetMouseButtonByName ( string name ) #

Returns the mouse button by its name.

Arguments

  • string name - Mouse button name.

Return value

One of the Input.MOUSE_BUTTON enum values.

int GetEventsBuffer ( int frame, InputEvent[] events ) #

Returns the buffer with the input events for the specified frame.

Arguments

  • int frame - Number of frame for which the buffer of input events is to be obtained. Input events are stored for the last 60 frames. 0 is the current frame, 1 is the previous frame, etc.
  • InputEvent[] events - The buffer with input events.

void SendEvent ( InputEvent e ) #

Creates a user event and dispatches it to the Engine.

Arguments

void SetEventsFilter ( IntPtr func ) #

Sets a callback function to be executed on receiving input events. This input event filter enables you to reject certain input events for the Engine and get necessary information on all input events.

Arguments

  • IntPtr func - Input event callback.

bool IsModifierEnabled ( Input.MODIFIER modifier ) #

Returns the value indicating if the specified modifier is enabled.

Arguments

Return value

true if the modifier is enabled; otherwise, false.

uint KeyToUnicode ( Input.KEY key ) #

Returns the specified key transformed to unicode.

Arguments

Return value

Unicode symbol.

Input.KEY UnicodeToKey ( uint unicode ) #

Returns the specified key transformed to unicode.

Arguments

  • uint unicode - Unicode symbol.

Return value

One of the Input.KEY enum values.

void SetMouseCursorSkinCustom ( Image image ) #

Sets a custom image to be used for the mouse cursor.

Arguments

  • Image image - Image containing pointer shapes to be set for the mouse cursor (e.g., select, move, resize, etc.).

void SetMouseCursorSkinSystem ( ) #

Sets the current OS cursor skin (pointer shapes like select, move, resize, etc.).

void SetMouseCursorSkinDefault ( ) #

Sets the default Engine cursor skin (pointer shapes like select, move, resize, etc.).

void SetMouseCursorCustom ( Image image, int x = 0, int y = 0 ) #

Sets a custom image for the OS mouse cursor. The image must be of the square size and RGBA8 format.
Source code (C#)
// create an instance of the Image class
Image cursor = new Image("textures/my_cursor.png");
// set the image as the mouse cursor
Input.SetMouseCursorCustom(cursor);
// show the OS mouse pointer
Input.MouseCursorSystem = true;

Arguments

  • Image image - Cursor image to be set.
  • int x - X coordinate of the cursor's hot spot.
  • int y - Y coordinate of the cursor's hot spot.

void ClearMouseCursorCustom ( ) #

Clears the custom mouse cursor set via the setMouseCursorCustom() method.

void UpdateMouseCursor ( ) #

Updates the mouse cursor. This method should be called after making changes to the mouse cursor to apply them all together. After calling this method the cursor shall be updated in the next frame.

string GetKeyLocalName ( Input.KEY key ) #

Returns the name for the specified key taken from the currently selected keyboard layout.
Notice
The returned value is affected by the modifier such as Shift.

Arguments

Return value

Localized name for the specified key.

int GetMouseButtonEvents ( Input.MOUSE_BUTTON button, InputEventMouseButton[] events ) #

Returns the number of input events for the specified mouse button and puts the events to the specified output buffer.

Arguments

Return value

Number of input events for the specified mouse button.

ivec2 GetForceMousePosition ( ) #

Returns the absolute mouse position obtained from the OS.

Return value

The absolute mouse position.

bool IsKeyText ( Input.KEY key ) #

Returns a value indicating if the given key has a corresponding printable symbol (current Num Lock state is taken into account). For example, pressing 2 on the numpad with Num Lock enabled produces "2", while with disabled Num Lock the same key acts as a down arrow. Keys like Esc, PrintScreen, BackSpace do not produce any printable symbol at all.

Arguments

Return value

true if the key value is a symbol; otherwise, false.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for mouse button events. Callback functions can be used to determine actions to be performed when various input events occur. Here is an example of tracking mouse button events via callbacks:
Source code (C#)
public void button_clicked(Input.MOUSE_BUTTON button)
{
	// actions to be performed ...
}

// somewhere in the code

// setting our callback function on clicking a mouse button
Input.AddCallback(Input.CALLBACK_INDEX.MOUSE_DOWN, button_clicked);

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for the mouse motion event. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the following:
  • CallbackDelegate func - Callback function with the following signature:
    Source code (C#)
    void CallbackDelegate(int x, int y);
    (x, y) - mouse coordinates delta.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for keyboard events. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for a unicode key or a touch event. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the following:
  • CallbackDelegate func - Callback function with the following signature:
    Source code (C#)
    void CallbackDelegate(InputEvent event);
    event - input event.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for a gamepad button event. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for a gamepad axis event. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the following:
  • CallbackDelegate func - Callback function with the following signature:
    Source code (C#)
    void CallbackDelegate(uint index, Input.GAMEPAD_AXIS axis);
    index - gamepad index. axis - gamepad axis index.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr AddCallback ( CALLBACK_INDEX callback, CallbackDelegate func ) #

Adds a callback of the specified type for an action event. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the following:
  • CallbackDelegate func - Callback function with the following signature:
    Source code (C#)
    void CallbackDelegate(uint index, int action);
    index - device index. action - action index.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool RemoveCallback ( CALLBACK_INDEX callback, IntPtr id ) #

Removes the specified callback from the list of callbacks of the specified type. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

Return value

true if the callback with the given ID was removed successfully; otherwise false.

void ClearCallbacks ( CALLBACK_INDEX callback ) #

Clears all added callbacks of the specified type. Callback functions can be used to determine actions to be performed when various input events occur.

Arguments

string GetModifierName ( Input.MODIFIER modifier ) #

Returns the name of the key modifier by its scancode.

Arguments

Return value

Key name of the modifier.

Input.MODIFIER GetModifierByName ( string name ) #

Returns the scancode of the key modifier by its name.

Arguments

  • string name - Key name of the modifier.

Return value

Scancode of the modifier.
Last update: 2023-04-13
Build: ()