/* * keyboard.h * * Keyboard handling and key bindings. * */ #import "game.h" #include "SDL.h" // Actually executes actions. Should be called every frame. void keyboard_actions(game_state *g); // When [key] is pressed, call action every [repeat_interval] seconds until the key is released. // If there's already a binding on [key], it will be removed. void bind_key(SDLKey key, void (*action)(game_state *g), float repeat_interval); extern const float key_down_only; // Pass this as [repeat_interval] to call function only on key down. extern const float key_up_only; // Pass this as [repeat_interval] to call function only on key up. // Unbind the function bound to [key], if there is one. void unbind_key(SDLKey key); // Update a key's state. // [state] is the same as in the SDL keyboard event. Possible values: // SDL_PRESSED => key pressed // SDL_RELEASED => key released void update_key_state(SDLKey key, Uint8 state);