Skip to content

InputMaster

Shahriar Shahrabi edited this page May 13, 2020 · 3 revisions

Input Master

The InputMaster class is a manager type class responsible for helping with getting input from the window. It is created during the construction of the ToyRendererApp and updated along with the other manager type class before the Update call.

The main way of interaction with the InputMaster is through inquiring a specific key through one of the main 3 calls, GetKeyDown, GetKeyUp and GetKey. An example would be:

float x = 0.0f;

if (ToyRenderer::InputMaster::GetKey(ToyRenderer::KeyName::D)) x -= movementSpeed;
if (ToyRenderer::InputMaster::GetKey(ToyRenderer::KeyName::A)) x += movementSpeed;

In the above example the value of x can be used to animate left, right movement.


Main functions of the InputMaster:

Function Name Purpose
static bool GetKeyDown(KeyName) Returns true if the enquirered key has been press in the last frame
static bool GetKeyUp(KeyName) Returns true if the enquirered key has been released in the last frame
static bool GetKey(KeyName) Returns true if the enquirered key is currently pressed

Main member values:

Member Value Name Purpose
static Mouse mouse The mouse on the screen. Through this class you can get the mouse position, the delta of its movement and set its visibility
Clone this wiki locally