Input

Inherited: None

Description

Use this class to get information from the inpute devices, like mouse, keyboard, joystick and etc.

Note: All input data updates once per frame during Engine::update() method.

Note: Many mobile devices are capable of tracking multiple fingers touching the screen simultaneously.

Public Methods

None

Static Methods

int

getCode (const std::string & )

std::string

inputString ()

bool

isKey (Input::KeyCode code)

bool

isKeyDown (Input::KeyCode code)

bool

isKeyUp (Input::KeyCode code)

bool

isMouseButton (int button)

bool

isMouseButtonDown (int button)

bool

isMouseButtonUp (int button)

int

joystickButtons (in int)

int

joystickCount ()

Vector4

joystickThumbs (int index)

Vector2

joystickTriggers (int index)

Vector4

mouseDelta ()

void

mouseLockCursor (bool lock)

Vector4

mousePosition ()

float

mouseScrollDelta ()

void

setKeyboardVisible (bool visible)

int

touchCount ()

Vector4

touchPosition (int index)

int

touchState (in int)

Methods Description

int Input::getCode (std::string & **)

Returns a key code, mouse buttons


std::string Input::inputString ()

Returns characters entered since the last frame.


bool Input::isKey (Input::KeyCode code)

Returns true in case of a key with code is pressed; otherwise returns false. Please refer to Input::KeyCode to see possible key *code*s.


bool Input::isKeyDown (Input::KeyCode code)

Returns true during the frame in case of a key with code is pressed; otherwise returns false. Please refer to Input::KeyCode to see possible key *code*s.


bool Input::isKeyUp (Input::KeyCode code)

Returns true during the frame in case of a key with code is released; otherwise returns false. Please refer to Input::KeyCode to see possible key *code*s.


bool Input::isMouseButton (int button)

Returns the state of mouse button. Example code:

if(Input::isMouseButton(0)) {
    aInfo() << "Left button pressed";
}
if(Input::isMouseButton(1)) {
    aInfo() << "Right button pressed";
}
if(Input::isMouseButton(3)) {
    aInfo() << "Middle button pressed";
}

bool Input::isMouseButtonDown (int button)

Returns true in case of the button is pressed; otherwise returns false.


bool Input::isMouseButtonUp (int button)

Returns true in case of the button is released; otherwise returns false.


int Input::joystickButtons (in int)

Returns the states of buttons for joystick with index. Please refer to Input::KeyCode to see possible buttons.

Note: This method returns a bit masked value. To retrieve the state of the required button please make bit comparison.

Example code:

if(Input::joystickButtons(0) & Input::JOYSTICK_) {
    ...
}

int Input::joystickCount ()

Returns the number of connected joysticks.


Vector4 Input::joystickThumbs (int index)

Returns the thumbs position of joystick with index. The components x and y will contain a value for the left thumbs. The components z and w will contain a value for the right thumbs.


Vector2 Input::joystickTriggers (int index)

Returns the value of pressure for the joystick triggers with index. The component x will contain a value for the left trigger and component y will contain value for the right trigger.


Vector4 Input::mouseDelta ()

Returns the mouse position delta. The absolute position will be stored in x and y components. The normalized position will be stored in z and w components.

Note: Delta value recalculated once per frame, calling this method multiple times in one frame will return the same result.

Note: The value will be Vector4(0.0f) if a mouse is not moved.


void Input::mouseLockCursor (bool lock)

Tries to lock mouse cursor.


Vector4 Input::mousePosition ()

Returns the mouse position. The absolute position will be stored in x and y components. The normalized position will be stored in z and w components.


float Input::mouseScrollDelta ()

Returns the mouse wheel scrolling delta.

Note: Delta value recalculated once per frame, calling this method multiple times in one frame will return the same result.

Note: The value will be 0.0f if a mouse wheel is not rotated.


void Input::setKeyboardVisible (bool visible)

Sets virtual keyboard visible.

Note: Does nothing for the desktop platforms.


int Input::touchCount ()

Returns the number of touches.


Vector4 Input::touchPosition (int index)

Returns the position of touch with index. The absolute position will be stored in x and y components. The normalized position will be stored in z and w components.


int Input::touchState (in int)

Returns the state of touch with index. Please refer to Input::TouchState to see possible states.