src/Input.hh
author terom
Sat, 06 Dec 2008 23:47:13 +0000
changeset 236 0048ba274152
parent 235 0a0c729365ee
child 237 3d5465bcb67d
permissions -rw-r--r--
move weapons definition out to Weapons.cc
#ifndef INPUT_HH
#define INPUT_HH

#include <stdint.h>
#include <ClanLib/Display/input_device.h>
#include <ClanLib/Display/keys.h>

// const uint16_t INPUT_INTERVAL_MS = 20;

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        = 0x0080,
    INPUT_ROPE          = 0x0100,
    INPUT_UNROPE        = 0x0200,
    INPUT_ROPE_UP       = 0x0400,
    INPUT_ROPE_DOWN     = 0x0800,
};

enum GuiInputBit {
    GUI_INPUT_QUIT              = 0x0001,
    GUI_INPUT_DISPLAY_WEAPON    = 0x0002,
    GUI_INPUT_DEBUG_PLAYER      = 0x0004,
};

typedef uint16_t PlayerInput;
typedef uint16_t GuiInput;

template <typename BitEnumType> struct InputKeymapEntry;

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