#import "keyboard.h" #import "memory.h" #import "oops.h" #include typedef struct { void (*action)(game_state *g); Uint32 repeat_ticks; long long ticks_remaining; int activate_anyway; // Hack to support key_down_only and key_up_only. int on_key_down_up; Uint8 state; } keybinding; keybinding *_bindings() { static keybinding *bindings = NULL; if (bindings == NULL) { bindings = (keybinding *)malloc(sizeof(keybinding) * SDLK_LAST); // SDLK_LAST is the last keysym + 1 memset(bindings, 0, sizeof(keybinding) * SDLK_LAST); } return bindings; } void keyboard_actions(game_state *g) { static Uint32 last_ticks = 0; Uint32 delta_ticks = SDL_GetTicks() - last_ticks; int i; keybinding *b = _bindings(); for (i=0; i