Fixing issue where keyUp events aren't sent for keys that become modified by the command key

This commit is contained in:
Peter Slattery 2024-03-22 17:55:59 -06:00
parent cba2574e8a
commit e33bdffc7d
3 changed files with 18 additions and 10 deletions

View File

@ -216,9 +216,11 @@ map_loose_match(Input_Modifier_Set *binding_mod_set, Input_Modifier_Set *event_m
i32 binding_mod_count = binding_mod_set->count; i32 binding_mod_count = binding_mod_set->count;
Key_Code *binding_mods = binding_mod_set->mods; Key_Code *binding_mods = binding_mod_set->mods;
for (i32 i = 0; i < binding_mod_count; i += 1){ for (i32 i = 0; i < binding_mod_count; i += 1){
if (has_modifier(event_mod_set, binding_mods[i])){ if (!has_modifier(event_mod_set, binding_mods[i])){
result += 1; result = 0;
break;
} }
result += 1;
} }
return(result); return(result);
} }

View File

@ -348,7 +348,7 @@ os_popup_error(char *title, char *message){
#if defined(FRED_INTERNAL) #if defined(FRED_INTERNAL)
function inline void function inline void
mac_profile(char *name, u64 begin, u64 end){ mac_profile(char *name, u64 begin, u64 end){
printf("%s Time: %fs\n", name, ((end - begin) / 1000000.0f)); //printf("%s Time: %fs\n", name, ((end - begin) / 1000000.0f));
} }
#define MacProfileScope(name) for (u64 glue(_i_, __LINE__) = 0, glue(_begin_, __LINE__) = system_now_time();\ #define MacProfileScope(name) for (u64 glue(_i_, __LINE__) = 0, glue(_begin_, __LINE__) = system_now_time();\
@ -909,7 +909,7 @@ mac_toggle_fullscreen(void){
mac_profile("Frame", prev_timer_start, mac_vars.timer_start); mac_profile("Frame", prev_timer_start, mac_vars.timer_start);
#if FRED_INTERNAL #if FRED_INTERNAL
printf("\n"); //printf("\n");
#endif #endif
} }
@ -963,7 +963,7 @@ mac_toggle_fullscreen(void){
u8 *str = push_array(&mac_vars.frame_arena, u8, 1); u8 *str = push_array(&mac_vars.frame_arena, u8, 1);
str[0] = (u8)c; str[0] = (u8)c;
Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chunk.trans.event_list); Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chunk.trans.event_list);
event->kind = InputEventKind_TextInsert; event->kind = InputEventKind_TextInsert;
event->text.string = SCu8(str, 1); event->text.string = SCu8(str, 1);
event->text.next_text = 0; event->text.next_text = 0;
@ -1206,11 +1206,17 @@ Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chu
system_signal_step(0); system_signal_step(0);
} }
} else{ } else {
mac_vars.active_key_stroke = 0; mac_vars.active_key_stroke = 0;
mac_vars.active_text_input = 0; mac_vars.active_text_input = 0;
if (key != 0){ if (key != 0){
// NOTE(PS): when releasing the command key, assume all keys being pressed
// are released
if (key == KeyCode_Command) {
mods->count = 0;
}
Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chunk.trans.event_list); Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chunk.trans.event_list);
event->kind = InputEventKind_KeyRelease; event->kind = InputEventKind_KeyRelease;
event->key.code = key; event->key.code = key;

View File

@ -16,7 +16,7 @@ struct Mac_Metal{
function function
mac_render_sig(mac_metal__render){ mac_render_sig(mac_metal__render){
#if defined(FRED_INTERNAL) #if defined(FRED_INTERNAL)
printf("Redering using Metal!\n"); //printf("Redering using Metal!\n");
#endif #endif
Mac_Metal *metal = (Mac_Metal*)renderer; Mac_Metal *metal = (Mac_Metal*)renderer;