src/Graphics/Input.hh
author Tero Marttila <terom@fixme.fi>
Thu, 22 Jan 2009 00:02:53 +0200
branchnew_graphics
changeset 414 cede5463b845
parent 389 src/Input.hh@e74c1820fbd2
child 416 38cba347a3a9
permissions -rw-r--r--
port Input to new Graphics, still a bit hacky, but everything seems to work now
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
     1
#ifndef GRAPHICS_INPUT_HH
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
     2
#define GRAPHICS_INPUT_HH
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
     4
#include "../Input.hh"
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
     5
#include "../Timer.hh"
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
     6
#include "../Types.hh"
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
     7
230
78cf0cd69af4 better input handling
terom
parents: 229
diff changeset
     8
#include <ClanLib/Display/input_device.h>
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     9
#include <ClanLib/Display/keys.h>
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    10
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    11
#include <list>
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    12
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    13
namespace graphics
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    14
{
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    15
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    16
/**
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    17
 * Flags to control input behaviour
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    18
 */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    19
enum InputFlagBits {
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    20
    /** Default */
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    21
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    22
    /**
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    23
     * The bit is not limited, i.e. it is set every time if it's present
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    24
     */
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    25
    INPUT_FLAG_UNLIMITED    = 0x0000,
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    26
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    27
    /**
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    28
     * The bit is repeat-limited using INPUT_REPEAT_DELAY
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    29
     */
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    30
    INPUT_FLAG_SLOWREPEAT   = 0x0001,
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    31
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    32
    /**
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    33
     * The bit is repeat-limited using an infinite delay, i.e. you must release the key to trigger it again
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    34
     */
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    35
    INPUT_FLAG_NOREPEAT     = 0x0002,
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    36
};
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    37
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    38
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    39
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    40
 * The bits used in the GuiInput bitmask, each represents something handled locally by Graphics.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    41
 */
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 230
diff changeset
    42
enum GuiInputBit {
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    43
    GUI_INPUT_NONE              = 0x0000,
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    44
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 230
diff changeset
    45
    GUI_INPUT_QUIT              = 0x0001,
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 230
diff changeset
    46
    GUI_INPUT_DISPLAY_WEAPON    = 0x0002,
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 230
diff changeset
    47
    GUI_INPUT_DEBUG_PLAYER      = 0x0004,
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 319
diff changeset
    48
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 319
diff changeset
    49
    GUI_INPUT_TOGGLE_FULLSCREEN = 0x0008,
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    50
};
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    51
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    52
/**
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    53
 * Bitmask of InputFlagBits
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    54
 */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    55
typedef uint8_t InputFlags;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    56
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    57
/**
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    58
 * Bitmask for GuiInputBits
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    59
 *
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    60
 * @see GuiInputBit
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    61
 */
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 230
diff changeset
    62
typedef uint16_t GuiInput;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    63
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    64
/**
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    65
 * Keymap definition struct
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
    66
 */
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    67
template <typename BitEnumType> struct InputKeymapEntry {
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    68
    /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    69
     * The input bit to set if present
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    70
     */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    71
    BitEnumType input;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    72
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    73
    /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    74
     * Flags to use
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    75
     *
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    76
     * @see InputFlagBits
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    77
     */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    78
    InputFlags flags;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    79
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    80
    /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    81
     * Up to two keycodes to check
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    82
     */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    83
    int keycodes[2];
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    84
};
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    85
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    86
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    87
/**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    88
 * A InputKeyRepeatQueue entry, this contains the input bit value itself, and then the remaining expire time
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    89
 */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    90
template <typename BitEnumType> struct InputKeyRepeatEntry {
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    91
        BitEnumType value;
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    92
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    93
        /**
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    94
         * The remaining expire time. If this is zero, it never expires
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
    95
         */
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    96
        TimeMS expire;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    97
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    98
    public:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
    99
        InputKeyRepeatEntry (BitEnumType value, TimeMS expire);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   100
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   101
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   102
         * Since priority_queue always gives the greatest item, the one with the longest expire is the least item
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   103
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   104
        bool operator< (const struct InputKeyRepeatEntry &other);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   105
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   106
        /**
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   107
         * Decrements expire, returning true if it has now expired, false otherwise. Always returns false if expire is
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   108
         * zero.
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   109
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   110
        bool updateExpired (TimeMS dt);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   111
};
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   112
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   113
/**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   114
 * A InputKeyRepeatQueue maintains a list of InputKeyRepeatEntry's, lets you add new input values, find old ones,
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   115
 * and update the list
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   116
 */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   117
template <typename BitEnumType> class InputKeyRepeatQueue {
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   118
    private:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   119
        TimeMS expire;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   120
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   121
        typedef InputKeyRepeatEntry<BitEnumType> entry_type;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   122
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   123
        std::list<entry_type> list;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   124
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   125
        typedef typename std::list<entry_type>::iterator list_iterator;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   126
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   127
    public:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   128
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   129
         * Constructs this queue to contain entries with the given expiry time
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   130
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   131
        InputKeyRepeatQueue (TimeMS expire);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   132
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   133
        /**
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   134
         * Push a new input bit onto the queue.
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   135
         *
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   136
         * If expire is true, the bit will automatically expire after our expire time, otherwise, it iwll never expire
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   137
         * until forget()'d
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   138
         */
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   139
        void push (BitEnumType bit, bool expire = true);
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   140
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   141
        /**
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   142
         * Remove any entry for the given bit
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   143
         */
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   144
        void forget (BitEnumType bit);
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   145
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   146
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   147
         * Checks if the given input is in the queue
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   148
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   149
        bool find (BitEnumType bit);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   150
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   151
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   152
         * Updates the list, removing expired items
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   153
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   154
        void update (TimeMS dt);
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   155
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   156
        /**
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   157
         * Clear the queue completely
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   158
         */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   159
        void clear (void);
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   160
};
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   161
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   162
/**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   163
 * An InputHandler uses an InputKeymapEntry to maintain a BitMaskType of current inputs
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   164
 */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   165
template <typename BitEnumType, typename BitMaskType> class InputHandler {
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   166
    private:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   167
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   168
         * The keyboard that we read input from
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   169
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   170
        CL_InputDevice &keyboard;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   171
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   172
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   173
         * The keymap that we use
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   174
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   175
        InputKeymapEntry<BitEnumType> *keymap;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   176
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   177
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   178
         * The current bitmask value
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   179
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   180
        BitMaskType value;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   181
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   182
        /**
319
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   183
         * The previous value, used to detect key-up. This also includes keys that were filtered out
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   184
         */
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   185
        BitMaskType prev_value;
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   186
9f6a838d58c4 improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents: 311
diff changeset
   187
        /**
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   188
         * How long the bitmask was held...
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   189
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   190
        TimeMS dt;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   191
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   192
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   193
         * The KeyRepeatQueue
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   194
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   195
        InputKeyRepeatQueue<BitEnumType> queue;
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   196
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   197
        /**
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   198
         * Are we enabled or not?
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   199
         */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   200
        bool _enabled;
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   201
    
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   202
    public:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   203
        /**
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   204
         * Constructs the InputHandler using the given keyboard, keymap and key-repeat expire time.
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   205
         *
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   206
         * The InputHandler is initially disabled, and must be enabled using enable() for use. 
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   207
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   208
        InputHandler (CL_InputDevice &keyboard, InputKeymapEntry<BitEnumType> *keymap, TimeMS keyrepeat_expire);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   209
    
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   210
    private: 
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   211
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   212
         * Returns true if the keycode is valid, false if not.
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   213
         *
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   214
         * A positive keycode requires that the keycode be active, a negative keycode that the keycode be inactive,
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   215
         * and a zero keycode always returns true.
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   216
         *
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   217
         * @param keycode A positive keycode to check that it's set, negative keycode to check that it's not set, or zero
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   218
         * @returns bool true if positive+set/negavtive+notset/zero, false otherwise
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   219
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   220
        bool checkKeycode (int keycode);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   221
    
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   222
    public:
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   223
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   224
         * Updates the keyrepeat queue
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   225
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   226
        void update (TimeMS dt);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   227
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   228
        /**
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   229
         * Reads the current input mask value and length into mask and dt, and reset ours to zero.
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   230
         *
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   231
         * It is an error to attempt to read input while disabled.
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   232
         *
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   233
         * @param mask our BitMaskType value is returned using this
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   234
         * @param dt how long the input was held for
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   235
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   236
        void readValue (BitMaskType &mask, TimeMS &dt);
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   237
        
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   238
        /**
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   239
         * Enables this input handler, collecting bits in value
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   240
         */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   241
        void enable (void);
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   242
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   243
        /**
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   244
         * Disables this input handler, zeroing any state, so that enable() works cleanly
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   245
         */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   246
        void disable (void);
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   247
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   248
        /**
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   249
         * Current enable/disable state
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   250
         */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   251
        bool enabled (void) const { return _enabled; }
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   252
};
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   253
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
   254
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
   255
 * Handles reading input from a keyboard and mapping it to PlayerInput/GuiInput bitmasks
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 237
diff changeset
   256
 */
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   257
class Input {
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   258
    protected:
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   259
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   260
         * The keyboard device that we use
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   261
         */
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   262
        CL_InputDevice &keyboard;
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   263
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   264
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   265
         * Our update timer
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   266
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   267
        Timer update_timer;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   268
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   269
        CL_SlotContainer slots;
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   270
    
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   271
    public:        
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   272
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   273
         * Our PlayerInput
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   274
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   275
        InputHandler<PlayerInputBit, PlayerInput> player;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   276
        
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   277
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   278
         * Our GuiInput
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   279
         */
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   280
        InputHandler<GuiInputBit, GuiInput> gui;
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   281
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   282
    public:
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   283
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   284
         * Build the input handler using the given keyboard and the default keymaps
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   285
         */
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   286
        Input (CL_InputDevice &keyboard);
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   287
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   288
    public:
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   289
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   290
         * Reads the current PlayerInput value via mask, and the length of the input via dt
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   291
         */
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   292
        void readPlayerInput (PlayerInput &mask, TimeMS &dt);
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   293
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   294
        /**
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   295
         * Reads the current GuiInput mask and returns it
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 300
diff changeset
   296
         */
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   297
        GuiInput readGuiInput (void);
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
   298
};
230
78cf0cd69af4 better input handling
terom
parents: 229
diff changeset
   299
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   300
}
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   301
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   302
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   303
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   304
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   305
/*
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   306
 * Public template class method definitions
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   307
 */
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   308
#include <cassert>
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   309
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   310
namespace graphics
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   311
{
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   312
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   313
template <typename BitEnumType, typename BitMaskType> 
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   314
void InputHandler<BitEnumType, BitMaskType>::enable (void) {
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   315
    // sanity-check
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   316
    assert(!_enabled);
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   317
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   318
    // update state
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   319
    _enabled = true;
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   320
}
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   321
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   322
template <typename BitEnumType, typename BitMaskType> 
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   323
void InputHandler<BitEnumType, BitMaskType>::disable (void) {
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   324
    // sanity-check
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   325
    assert(_enabled);
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   326
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   327
    // update state
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   328
    value = prev_value = 0;
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   329
    _enabled = false;
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   330
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   331
    // and clear keyrepeat list
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   332
    queue.clear();
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   333
}
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   334
       
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   335
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   336
}
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
   337
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   338
#endif