diff --git a/src/game.c b/src/game.c index 3347910..e8bb763 100644 --- a/src/game.c +++ b/src/game.c @@ -89,7 +89,7 @@ int game_init(struct Window* window) void scene_setup(void) { - struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT}}; + struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT | KMD_SHIFT}}; struct Key_Combination backward_keys[2] = {{KEY_S, KMD_NONE}, {KEY_DOWN, KMD_NONE}}; /* struct Key_Combination up_keys[2] = {KEY_Q}; */ /* struct Key_Combination down_keys[2] = {KEY_E}; */ @@ -427,7 +427,7 @@ void update(float dt, int* window_should_close) /* if(input_map_state_get("Window_Maximize", KS_RELEASED)) window_fullscreen_set(game_state->window, 0); */ debug(dt); - //debug_gui(dt); + debug_gui(dt); editor_update(dt); input_update(); /* This should always be the last thing. Probably * put this in post update? */ diff --git a/src/input.c b/src/input.c index 4553669..8dab9fc 100644 --- a/src/input.c +++ b/src/input.c @@ -76,17 +76,18 @@ void input_on_key(int key, int scancode, int state, int repeat, int mod_ctrl, in if(mod_ctrl) mods |= KMD_CTRL; if(mod_shift) mods |= KMD_SHIFT; if(mod_alt) mods |= KMD_ALT; - for(int i = 0; i < array_len(input_map_list); i++) { struct Input_Map* map = &input_map_list[i]; for(int j = 0; j < array_len(map->keys); j++) { - if(map->state == KS_PRESSED && state == KS_RELEASED && map->keys[j].mods == mods) + if(map->state == KS_PRESSED && + state == KS_RELEASED && + ((map->keys[j].mods & mods) == map->keys[j].mods)) { map->state = state; } - if(map->keys[j].key == key && (map->keys[j].mods == mods)) + if(map->keys[j].key == key && ((map->keys[j].mods & mods) == map->keys[j].mods)) { map->state = state; break; diff --git a/src/input.h b/src/input.h index db83892..0b89c92 100644 --- a/src/input.h +++ b/src/input.h @@ -15,10 +15,11 @@ struct Key_Combination enum Key_Mod { - KMD_NONE = KMOD_NONE, KMD_ALT = KMOD_ALT, KMD_SHIFT = KMOD_SHIFT, - KMD_CTRL = KMOD_CTRL + KMD_CTRL = KMOD_CTRL, + //KMD_NONE = !(KMD_ALT | KMD_SHIFT | KMD_CTRL) + KMD_NONE = 0 }; enum Key_State diff --git a/src/platform.c b/src/platform.c index d30f9ef..12dba00 100644 --- a/src/platform.c +++ b/src/platform.c @@ -225,11 +225,11 @@ void platform_poll_events(int* out_quit) int key = event.key.keysym.sym; int state = event.key.state; int repeat = event.key.repeat; - int mod_ctrl = (event.key.keysym.mod & KMOD_CTRL); - int mod_shift = (event.key.keysym.mod & KMOD_SHIFT); - int mod_alt = (event.key.keysym.mod & KMOD_ALT); + int mod_ctrl = (event.key.keysym.mod & KMOD_CTRL) ? 1 : 0; + int mod_shift = (event.key.keysym.mod & KMOD_SHIFT) ? 1 : 0; + int mod_alt = (event.key.keysym.mod & KMOD_ALT) ? 1 : 0; platform_state->on_keyboard_func(key, scancode, state, repeat, mod_ctrl, mod_shift, mod_alt); - log_message("Key name : %s", SDL_GetKeyName(key)); + //log_message("Key name : %s", SDL_GetKeyName(key)); break; } case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: