terom@185: #ifndef INPUT_HH terom@185: #define INPUT_HH terom@185: terom@221: #include terom@230: #include terom@221: #include terom@185: terom@283: // const TimeMS INPUT_INTERVAL_MS = 20; terom@221: terom@283: /** terom@283: * The bits used in the PlayerInput bitmask, each represents a separate action handled by LocalPlayer::handleInput. terom@283: * terom@283: * @see LocalPlayer::handleInput terom@283: */ terom@233: enum PlayerInputBit { terom@233: INPUT_NONE = 0x0000, terom@233: terom@221: INPUT_AIM_UP = 0x0001, terom@221: INPUT_AIM_DOWN = 0x0002, terom@185: terom@185: INPUT_MOVE_LEFT = 0x0004, terom@185: INPUT_MOVE_RIGHT = 0x0008, terom@185: terom@221: INPUT_JUMP = 0x0010, terom@221: INPUT_DIG = 0x0020, terom@185: INPUT_SHOOT = 0x0040, terom@237: INPUT_CHANGE_NEXT = 0x0080, terom@237: INPUT_CHANGE_PREV = 0x0100, terom@237: INPUT_ROPE = 0x0200, terom@237: INPUT_UNROPE = 0x0400, terom@237: INPUT_ROPE_UP = 0x0800, terom@237: INPUT_ROPE_DOWN = 0x1000, terom@300: terom@300: INPUT_SUICIDE = 0x2000, terom@185: }; terom@185: terom@283: /** terom@283: * The bits used in the GuiInput bitmask, each represents something handled locally by Graphics. terom@283: */ terom@233: enum GuiInputBit { terom@233: GUI_INPUT_QUIT = 0x0001, terom@233: GUI_INPUT_DISPLAY_WEAPON = 0x0002, terom@233: GUI_INPUT_DEBUG_PLAYER = 0x0004, terom@221: }; terom@221: terom@283: /** terom@283: * Bitmask of PlayerInputBits terom@283: * terom@283: * @see PlayerInputBit terom@283: */ terom@233: typedef uint16_t PlayerInput; terom@283: terom@283: /** terom@283: * Bitmask for GuiInputBits terom@283: * terom@283: * @see GuiInputBit terom@283: */ terom@233: typedef uint16_t GuiInput; terom@185: terom@283: /** terom@283: * Keymap definition used in Input.cc terom@283: */ terom@235: template struct InputKeymapEntry; terom@235: terom@283: /** terom@283: * Handles reading input from a keyboard and mapping it to PlayerInput/GuiInput bitmasks terom@283: */ terom@235: class Input { terom@235: protected: terom@235: CL_InputDevice &keyboard; terom@235: terom@235: public: terom@235: Input (CL_InputDevice &keyboard); terom@235: terom@235: private: terom@235: bool checkKeycode (int keycode); terom@235: template BitMaskType buildMask (InputKeymapEntry *keymap); terom@235: terom@235: public: terom@235: /* terom@235: * Reads the keyboard to determine current state of the Player/Gui input terom@235: */ terom@235: PlayerInput readPlayerInput (void); terom@235: GuiInput readGuiInput (void); terom@235: }; terom@230: terom@185: #endif