Adonthell  0.4
input.h
Go to the documentation of this file.
1 /*
2  $Id: input.h,v 1.11 2001/07/19 08:41:27 gnurou Exp $
3 
4  Copyright (C) 1999/2000/2001 Alexandre Courbot.
5  Part of the Adonthell Project http://adonthell.linuxgames.com
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 
16 /**
17  * @file input.h
18  * @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
19  *
20  * @brief Declares the input class.
21  *
22  *
23  */
24 
25 
26 
27 #ifndef INPUT_H__
28 #define INPUT_H__
29 
30 #include "types.h"
31 #include "SDL_keysym.h"
32 
33 
34 /**
35  * Handles keyboard and mouse input.
36  *
37  * @todo Rewrite it!
38  *
39  */
40 class input
41 {
42 public:
43 
44  /**
45  * Initialise the input system.
46  *
47  */
48  static void init();
49 
50  /**
51  * Free resources occupied by the input system.
52  *
53  */
54  static void shutdown();
55 
56  /**
57  * Update the input state.
58  *
59  */
60  static void update();
61 
62  /**
63  * Returns whether a key is currently pushed or not.
64  *
65  * @param key key to test.
66  *
67  * @return true if key is currently pushed, false otherwise.
68  */
69  static bool is_pushed(SDLKey key);
70 
71  /**
72  * Returns whether a key has been pushed since last function call, false otherwise.
73  *
74  * @param key key to test.
75  *
76  * @return true if the key has been pushed since last call, false otherwise.
77  */
78  static bool has_been_pushed(SDLKey key);
79 
80 
81  /**
82  * Returns the code of the next key on the input queue.
83  *
84  *
85  * @return Code of the next key that has been pushed.
86  */
87  static s_int32 get_next_key();
88 
89  /**
90  * Returns the next unicode on the input queue.
91  *
92  *
93  * @return Unicode of the next key that has been pushed.
94  */
95  static s_int32 get_next_unicode();
96 
97  /**
98  * Sets whether the key repeat is active or not.
99  *
100  * @param delay delay (in ms) before repetition.
101  * @param interval interval (in ms) between repetitions.
102  */
103  static void set_key_repeat(int delay=SDL_DEFAULT_REPEAT_DELAY, int interval=SDL_DEFAULT_REPEAT_INTERVAL);
104 
105  /**
106  * Totally clears the key queue.
107  *
108  */
109  static void clear_keys_queue();
110 
111 
112 private:
113  static u_int16 last_key;
114 
115  static int filterevents(const SDL_Event *event);
116 
117  static u_int16 mouse_posx, mouse_posy;
118  static u_int8 * keystate;
119  static u_int8 * p_keystate;
120  static s_int32 keystatelength;
121 #ifndef SWIG
122  static bool mouse_button[3];
123 #endif
124 
125 };
126 
127 #endif
#define s_int32
32 bits long signed integer
Definition: types.h:44
Declares some basic types.
Handles keyboard and mouse input.
Definition: input.h:40
#define u_int16
16 bits long unsigned integer
Definition: types.h:32
static void update()
Update the input state.
Definition: input.cc:63
Base class for events.
Definition: event.h:71
#define u_int8
8 bits long unsigned integer
Definition: types.h:29
static bool has_been_pushed(SDLKey key)
Returns whether a key has been pushed since last function call, false otherwise.
Definition: input.cc:76
static s_int32 get_next_key()
Returns the code of the next key on the input queue.
Definition: input.cc:89
static void init()
Initialise the input system.
Definition: input.cc:46
static void shutdown()
Free resources occupied by the input system.
Definition: input.cc:58
static bool is_pushed(SDLKey key)
Returns whether a key is currently pushed or not.
Definition: input.cc:68
static void clear_keys_queue()
Totally clears the key queue.
Definition: input.cc:128
static s_int32 get_next_unicode()
Returns the next unicode on the input queue.
Definition: input.cc:107
static void set_key_repeat(int delay=SDL_DEFAULT_REPEAT_DELAY, int interval=SDL_DEFAULT_REPEAT_INTERVAL)
Sets whether the key repeat is active or not.
Definition: input.cc:84