| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- $#include "Input.h"
- /// %Input state for a finger touch.
- struct TouchState
- {
- /// Touch (finger) ID.
- int touchID_ @ touchID;
- /// Position in screen coordinates.
- IntVector2 position_ @ position;
- /// Last position in screen coordinates.
- IntVector2 lastPosition_ @ lastPosition;
- /// Movement since last frame.
- IntVector2 delta_ @ delta;
- /// Finger pressure.
- float pressure_ @ pressure;
- };
- /// %Input state for a joystick.
- struct JoystickState
- {
- /// Return number of buttons.
- unsigned GetNumButtons() const;
- /// Return number of axes.
- unsigned GetNumAxes() const;
- /// Return number of hats.
- unsigned GetNumHats() const;
-
- /// Check if a button is held down.
- bool GetButtonDown(unsigned index) const;
-
- /// Check if a button has been pressed on this frame.
- bool GetButtonPress(unsigned index) const;
-
- /// Return axis position.
- float GetAxisPosition(unsigned index) const;
-
- /// Return hat position.
- int GetHatPosition(unsigned index) const;
- };
- /// %Input subsystem. Converts operating system window messages to input state and events.
- class Input : public Object
- {
- public:
- /// Set whether the operating system mouse cursor is visible. When not visible (default), is kept centered to prevent leaving the window.
- void SetMouseVisible(bool enable);
- /// Open a joystick. Return true if successful.
- bool OpenJoystick(unsigned index);
- /// Close a joystick.
- void CloseJoystick(unsigned index);
- /// Redetect joysticks. Return true if successful.
- bool DetectJoysticks();
-
- /// Check if a key is held down.
- bool GetKeyDown(int key) const;
- /// Check if a key has been pressed on this frame.
- bool GetKeyPress(int key) const;
- /// Check if a mouse button is held down.
- bool GetMouseButtonDown(int button) const;
- /// Check if a mouse button has been pressed on this frame.
- bool GetMouseButtonPress(int button) const;
- /// Check if a qualifier key is held down.
- bool GetQualifierDown(int qualifier) const;
- /// Check if a qualifier key has been pressed on this frame.
- bool GetQualifierPress(int qualifier) const;
- /// Return the currently held down qualifiers.
- int GetQualifiers() const;
- /// Return mouse position within window. Should only be used with a visible mouse cursor.
- IntVector2 GetMousePosition() const;
- /// Return mouse movement since last frame.
- const IntVector2& GetMouseMove() const;
- /// Return horizontal mouse movement since last frame.
- int GetMouseMoveX() const;
- /// Return vertical mouse movement since last frame.
- int GetMouseMoveY() const;
- /// Return mouse wheel movement since last frame.
- int GetMouseMoveWheel() const;
- /// Return number of active finger touches.
- unsigned GetNumTouches() const;
- /// Return active finger touch by index.
- TouchState* GetTouch(unsigned index) const;
- /// Return number of connected joysticks.
- unsigned GetNumJoysticks() const;
- /// Return joystick name by index.
- const String& GetJoystickName(unsigned index) const;
- /// Return joystick state by index. Automatically open if not opened yet.
- JoystickState* GetJoystick(unsigned index);
- /// Return whether fullscreen toggle is enabled.
- bool GetToggleFullscreen() const;
- /// Return whether the operating system mouse cursor is visible.
- bool IsMouseVisible() const;
- /// Return whether application window has input focus.
- bool HasFocus();
- /// Return whether application window is minimized.
- bool IsMinimized() const;
- };
- Input* GetInput();
|