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