src/keyboard.h

changeset 86
ebce87d87808
child 90
934ae2efdd01
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/keyboard.h	Thu Dec 30 00:37:03 2010 +0000
     1.3 @@ -0,0 +1,33 @@
     1.4 +#ifndef _KEYBOARD_H
     1.5 +#define _KEYBOARD_H
     1.6 +
     1.7 +#define KEYBOARD_BUFFER_SIZE 0x100
     1.8 +
     1.9 +/**
    1.10 + * Keyboard controller state
    1.11 + */
    1.12 +typedef struct {
    1.13 +	unsigned char	keybuf[KEYBOARD_BUFFER_SIZE];		///< Keyboard data buffer
    1.14 +	size_t			readptr;							///< Keyboard buffer read pointer
    1.15 +	size_t			writeptr;							///< Keyboard buffer write pointer
    1.16 +	size_t			buflen;								///< Keyboard buffer fill level (buffer length)
    1.17 +	int				keystate[0x80];						///< List of key up/down states
    1.18 +} KEYBOARD_STATE;
    1.19 +
    1.20 +/**
    1.21 + * Initialise the keyboard.
    1.22 + *
    1.23 + * Initialises a keyboard state block in preparation for keyboard events.
    1.24 + *
    1.25 + * @param	state	Keyboard state block
    1.26 + */
    1.27 +void keyboard_init(KEYBOARD_STATE *state);
    1.28 +
    1.29 +/**
    1.30 + * Issue a keyboard event.
    1.31 + *
    1.32 + * Call this function when SDL issues a keyboard event in the event loop.
    1.33 + */
    1.34 +void keyboard_event(KEYBOARD_STATE *state, SDL_Event *ev);
    1.35 +
    1.36 +#endif