.. _api_Input: Input ===== Inherited: None .. _api_Input_description: 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. .. _api_Input_public: Public Methods -------------- None .. _api_Input_static: Static Methods -------------- +--------------------------------+-------------------------------------------------------------------------+ | :ref:`uint32_t` | :ref:`getCode` (const std::string & name) | +--------------------------------+-------------------------------------------------------------------------+ | std::string | :ref:`inputString` () | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isKey` (Input::KeyCode code) | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isKeyDown` (Input::KeyCode code) | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isKeyUp` (Input::KeyCode code) | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isMouseButton` (int button) | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isMouseButtonDown` (int button) | +--------------------------------+-------------------------------------------------------------------------+ | bool | :ref:`isMouseButtonUp` (int button) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`uint32_t` | :ref:`joystickButtons` (uint32_t index) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`uint32_t` | :ref:`joystickCount` () | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`joystickThumbs` (uint32_t index) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`joystickTriggers` (uint32_t index) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`mouseDelta` () | +--------------------------------+-------------------------------------------------------------------------+ | void | :ref:`mouseLockCursor` (bool lock) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`mousePosition` () | +--------------------------------+-------------------------------------------------------------------------+ | float | :ref:`mouseScrollDelta` () | +--------------------------------+-------------------------------------------------------------------------+ | void | :ref:`setKeyboardVisible` (bool visible) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`uint32_t` | :ref:`touchCount` () | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`touchPosition` (uint32_t index) | +--------------------------------+-------------------------------------------------------------------------+ | :ref:`uint32_t` | :ref:`touchState` (uint32_t index) | +--------------------------------+-------------------------------------------------------------------------+ .. _api_Input_methods: Methods Description ------------------- .. _api_Input_getCode: :ref:`uint32_t` **Input::getCode** (std::string & *name*) Converts a key *name* to code. ---- .. _api_Input_inputString: std::string **Input::inputString** () Returns characters entered since the last frame. ---- .. _api_Input_isKey: bool **Input::isKey** (:ref:`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. ---- .. _api_Input_isKeyDown: bool **Input::isKeyDown** (:ref:`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. ---- .. _api_Input_isKeyUp: bool **Input::isKeyUp** (:ref:`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. ---- .. _api_Input_isMouseButton: 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"; } ---- .. _api_Input_isMouseButtonDown: bool **Input::isMouseButtonDown** (int *button*) Returns true in case of the *button* is pressed; otherwise returns false. ---- .. _api_Input_isMouseButtonUp: bool **Input::isMouseButtonUp** (int *button*) Returns true in case of the *button* is released; otherwise returns false. ---- .. _api_Input_joystickButtons: :ref:`uint32_t` **Input::joystickButtons** (:ref:`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_) { ... } ---- .. _api_Input_joystickCount: :ref:`uint32_t` **Input::joystickCount** () Returns the number of connected joysticks. ---- .. _api_Input_joystickThumbs: :ref:`Vector4` **Input::joystickThumbs** (:ref:`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. ---- .. _api_Input_joystickTriggers: :ref:`Vector2` **Input::joystickTriggers** (:ref:`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. ---- .. _api_Input_mouseDelta: :ref:`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. ---- .. _api_Input_mouseLockCursor: void **Input::mouseLockCursor** (bool *lock*) Tries to *lock* mouse cursor. ---- .. _api_Input_mousePosition: :ref:`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. ---- .. _api_Input_mouseScrollDelta: 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. ---- .. _api_Input_setKeyboardVisible: void **Input::setKeyboardVisible** (bool *visible*) Sets virtual keyboard *visible*. **Note:** Does nothing for the desktop platforms. ---- .. _api_Input_touchCount: :ref:`uint32_t` **Input::touchCount** () Returns the number of touches. ---- .. _api_Input_touchPosition: :ref:`Vector4` **Input::touchPosition** (:ref:`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. ---- .. _api_Input_touchState: :ref:`uint32_t` **Input::touchState** (:ref:`uint32_t` *index*) Returns the state of touch with *index*. Please refer to Input::TouchState to see possible states.