How Can We Help?

Code Reference

Easy Input’s functionality is primarily contained in classes: EnumInput and InputManager.

EnumInput

EnumInput is a class that really defines a set of enumerations. I prefer to use ‘const int’ values for enumerations because they transfer easier and the compiler replaces the actual values at compile time. That means there is no lookup at run-time.

For the most part, these enums match Unity’s KeyCode enums. However, there are some changes. The big reason for the changes is to compress the length and to customize the Xbox controller entries.

To access values, simply use syntax like:

EnumInput.GAMEPAD_RIGHT_STICK_X

 

EnumInput.EnumNames

This property is a convenient dictionary that allows you to convert an enumerated value into a string. For example, ‘EnumInput.GAMEPAD_RIGHT_STICK_X’ results in the following string value: “GAMEPAD_RIGHT_STICK_X”.

To use, simply do the following:

string lName = EnumInput.EnumNames[EnumInput.GAMEPAD_RIGHT_STICK_X];

 

 

InputManager

This is the work-horse of Easy Input. It’s a static class so you can access it from anywhere using syntax like:

InputManager.IsJustPressed("Attack");

 

float DoublePressTime
Determines the length of time between presses at which a double-press is considered. The default is 0.5 seconds.

bool UseKeyboardBasic
Determines if the alpha-numeric keys of the keyboard are processed.

bool UseKeyboardKeyPad
Determines if the keypad on the keyboard is processed.

bool UseKeyboardFKeys
Determines if the function keys on a Windows keyboard are processed.

bool UseMouse
Determines if the mouse inputs are processed.

bool UseGamepad
Determines if the Xbox controller inputs are processed. If you’re disabling the Xbox controller, you don’t need to setup Unity’s InputManager.

bool InvertViewY
Determines if the ‘ViewY’ property inverts the results that are returned from the input.

int InputManager.KeysPressedCount
Count of keyboard input IDs that are currently pressed.

int[] InputManager.KeysPressed
Array of keyboard input IDs that are currently pressed.

void InputManager.AddAlias(string AliasName, int InputID)
Adds a new alias including the name and corresponding input.

void InputManager.AddAlias(string AliasName, int InputID, int HelperID)
Adds a new alias including the name and corresponding input. The helper input is required as well for the alias to be active. Think ‘Alt + T’ where ‘Alt’ is the helper.

void InputManager.RemoveAlias(string AliasName)
Removes all inputs associated with the alias name.

void InputManager.RemoveAlias(string AliasName, int InputID)
Removes the specific entry that has the matching alias name and input id. All other input IDs associated with the alias remain.

void InputManager.RemoveAlias(string AliasName, int InputID, int HelperID)
Removes the specific entry that has the matching alias name and input id. All other input IDs associated with the alias remain.

float InputManager.MovementMagnitude
The magnitude of the movement value (from MovementX and MovementY).

float InputManager.MovementX
The ‘x’ component of the movement from the input as set up using the default action aliases. Values are from -1 to 1.

float InputManager.MovementY
The ‘y’ component of the movement from the input as set up using the default action aliases. Values are from -1 to 1.

float InputManager.ViewX
The ‘x’ component of the view movement from the input as set up using the default action aliases. Values are from -1 to 1 (before multiplied by MouseViewSensativity).

float InputManager.ViewY
The ‘y’ component of the view movement from the input as set up using the default action aliases. Values are from -1 to 1 (before multiplied by MouseViewSensativity).

float InputManager.MouseViewSensativity
Multiplier for the view movement to speed it up or slow it down.

float InputManager.MouseX
The ‘x’ component of the mouse’s screen position in pixels. 0 is considered the left of the screen.

float InputManager.MouseY
The ‘y’ component of the mouse’s screen position in pixels. 0 is considered the bottom of the screen.

float InputManager.MouseXDelta
The movement of the mouse on the x-axis this frame (in pixels).

float InputManager.MouseYDelta
The movement of the mouse on the y-axis this frame (in pixels).

float InputManager.AxisX
The ‘x’ component of the mouse movement as reported by Unity. Values are from -1 to 1 and setup in Unity’s InputManager.

float InputManager.AxisY
The ‘y’ component of the mouse movement as reported by Unity. Values are from -1 to 1 and setup in Unity’s InputManager.

float InputManager.LeftStickX, float InputManager.RightStickX
The ‘x’ component of the Xbox controller’s sticks.

float InputManager.LeftStickY, float InputManager.RightStickY
The ‘y’ component of the Xbox controller’s sticks.

bool InputManager.IsLeftStickActive, bool InputManager.IsRightStickActive
Determines if the Xbox controller’s sticks are outside the [0,0] position.

float InputManager.LeftStickMagnitude, float InputManager.RightStickMagnitude
The magnitude of the Xbox controller’s sticks.

float InputManager.LeftTrigger, float InputManager.RightTrigger
The value of the Xbox controller’s triggers.

float InputManager.GetValue(int InputID), float InputManager.GetValue(string AliasName)
Returns the current value of the input.

bool InputManager.IsPressed(int InputID), bool InputManager.IsPressed(string AliasName)
Determines if the input is current active (ie has a value other than ‘0’). For buttons this means they are pressed.

bool InputManager.IsDoublePressed(int InputID), bool InputManager.IsDoublePressed(string AliasName)
Determines if the pressed value is a result of a double-click or double-press.

bool InputManager.IsJustPressed(int InputID), bool InputManager.IsJustPressed(string AliasName)
Determines if the input was activated this frame.

bool InputManager.IsJustReleased(int InputID), bool InputManager.IsJustReleased(string AliasName)
Determines if the input was released this frame.

float InputManager.PressedTime(int InputID), float InputManager.PressedTime(string AliasName)
The time (in total game seconds) that the input was last pressed.

float InputManager.PressedElapsedTime(int InputID), float InputManager.PressedElapsedTime(string AliasName)
The time (in seconds) that the input has been pressed for. A value of 0 is returned if the input is not being pressed.

float InputManager.ReleasedTime(int InputID), float InputManager.ReleasedTime(string AliasName)
The time (in total game seconds) that the input was last released from being pressed.

float InputManager.ReleasedElapsedTime(int InputID), float InputManager.ReleasedElapsedTime(string AliasName)
The time (in seconds) that the input has been released for. A value of 0 is returned if the input is not released.

bool IsEventsEnabled
If you also own the Event System – Dispatcher, this InputManager will push events to listeners. Enable or disable this flag to allow that to happen. See Push Events.

long InputManager.UpdateElapsedTicks
Number of CPU ticks the update process has taken. This is a performance diagnostic. In testing, average times were about 0.03 milliseconds per frame.

 

Page Contents