Input - Team-Innis/UtH-Engine GitHub Wiki
UtH has an API for pretty much any kind of input you could ever have need for.
You can access all of the functionality through the uthInput macro.
Keyboard
The following functions are available to query keyboard state:
IsKeyDown- Is the key currently down?IsKeyPressed- Was the key pressed once?IsKeyReleased- Was the key released?
Example
if (uthInput.Keyboard.IsKeyPressed(uth::Keyboard::Return))
{
// Do stuff...
}
Mouse
The following functions are available to query mouse state:
IsButtonDown- Is the button currently down?IsButtonPressed- Was the button pressed once?IsButtonReleased- Was the button released?Position- Get the current position of the cursor in pixel coordinates.Movement- Get the last movement of the cursor in pixel coordinates.Wheel- Get the last mouse wheel movement.
Touch
Handling touch input is a bit more complicated than dealing with mouse input, as the user can have multiple fingers on the screen at the same time, all doing a different gesture.
You can access the touch input state of a specific index by using uthInput.Touch[index].
The returned type has the following functions:
Motion- Returns an enum describing the current gesture.GetStartIndex- Returns the index of the first available touch.GetStartPosition- Get the start position if the current gesture is DRAG.GetEndPosition- Get the end position if the current gesture is DRAG.GetPosition- Get the current touch position.
Sensor
The following sensors API's are available in devices that support them:
- Accelerometer - With
GetAccelerometerInput - Gyroscope - With
GetGyroscopeInput
Controller
Controller support is available on every platform.
The following functions are available:
IsButtonDown- Is the button currently down?IsButtonUp- Is the button currently up (not pressed down)?IsButtonPressed- Was the button pressed once?IsButtonReleased- Was the button released?GetAxis- Get the current state of an axis.
Common (More here)
Common input can be used to query certain inputs platform-independently. This interface is based on events instead of states.
You can access the last event using the function Event which returns an enum describing the event type.
You can also query the position of the finger/mouse using Position.
Example
if (uthInput.Common.Event() == uth::InputEvent::TAP)
{
// Do stuff...
}
On a desktop environment, the TAP event would mean the same as CLICK.
Notes
KeyboardandMouseinput types are not available on mobile platforms.TouchandSensorinput types are only available on mobile platforms.