src/keyboard.h

Thu, 30 Dec 2010 00:37:03 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 30 Dec 2010 00:37:03 +0000
changeset 86
ebce87d87808
child 90
934ae2efdd01
permissions
-rw-r--r--

add keyboard event handler; need to do register r/w next.

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