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
uint32_t |
getCode (const std::string & name) |
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) |
uint32_t |
joystickButtons (uint32_t index) |
uint32_t |
|
joystickThumbs (uint32_t index) |
|
joystickTriggers (uint32_t index) |
|
mouseDelta () |
|
void |
mouseLockCursor (bool lock) |
float |
|
void |
setKeyboardVisible (bool visible) |
uint32_t |
touchCount () |
touchPosition (uint32_t index) |
|
uint32_t |
touchState (uint32_t index) |
Methods Description
uint32_t Input::getCode (std::string & name)
Converts a key name to code.
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.
uint32_t Input::joystickButtons (uint32_t index)
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_) {
...
}
uint32_t Input::joystickCount ()
Returns the number of connected joysticks.
Vector4 Input::joystickThumbs (uint32_t 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 (uint32_t 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.
uint32_t Input::touchCount ()
Returns the number of touches.
Vector4 Input::touchPosition (uint32_t 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.
uint32_t Input::touchState (uint32_t index)
Returns the state of touch with index. Please refer to Input::TouchState to see possible states.