| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #ifndef ANKI_INPUT_INPUT_H
- #define ANKI_INPUT_INPUT_H
- #include "anki/math/Math.h"
- #include <SDL/SDL_scancode.h>
- #include <boost/array.hpp>
- namespace anki {
- /// Handle the SDL input
- class Input
- {
- public:
- Input()
- {
- init();
- }
- /// @name Acessors
- /// @{
- short getKey(uint i) const
- {
- return keys[i];
- }
- short getMouseBtn(uint i) const
- {
- return mouseBtns[i];
- }
- bool getWarpMouse() const
- {
- return warpMouseFlag;
- }
- bool& getWarpMouse()
- {
- return warpMouseFlag;
- }
- void setWarpMouse(const bool x)
- {
- warpMouseFlag = x;
- }
- /// @}
- void reset();
- void handleEvents();
- // mouse stuff
- Vec2 mousePosNdc; ///< The coords are in the NDC space
- /// The coords are in the window space. (0, 0) is in the upper left
- /// corner
- Vec2 mousePos;
- Vec2 mouseVelocity;
- bool hideCursor;
- private:
- /// @name Keys and btns
- /// @{
- /// Shows the current key state
- /// - 0 times: unpressed
- /// - 1 times: pressed once
- /// - >1 times: Kept pressed 'n' times continuously
- boost::array<short, SDL_NUM_SCANCODES> keys;
- /// Mouse btns. Supporting 3 btns & wheel. @see keys
- boost::array<short, 8> mouseBtns;
- /// @}
- bool warpMouseFlag;
- void init();
- };
- } // end namespace
- #endif
|