Thu, 30 Dec 2010 00:44:25 +0000
add NELEMS macro to utils.h
1 #ifndef _KEYBOARD_H
2 #define _KEYBOARD_H
4 #define KEYBOARD_BUFFER_SIZE 0x100
6 /**
7 * Keyboard controller state
8 */
9 typedef struct {
10 unsigned char keybuf[KEYBOARD_BUFFER_SIZE]; ///< Keyboard data buffer
11 size_t readptr; ///< Keyboard buffer read pointer
12 size_t writeptr; ///< Keyboard buffer write pointer
13 size_t buflen; ///< Keyboard buffer fill level (buffer length)
14 int keystate[0x80]; ///< List of key up/down states
15 } KEYBOARD_STATE;
17 /**
18 * Initialise the keyboard.
19 *
20 * Initialises a keyboard state block in preparation for keyboard events.
21 *
22 * @param state Keyboard state block
23 */
24 void keyboard_init(KEYBOARD_STATE *state);
26 /**
27 * Issue a keyboard event.
28 *
29 * Call this function when SDL issues a keyboard event in the event loop.
30 */
31 void keyboard_event(KEYBOARD_STATE *state, SDL_Event *ev);
33 #endif