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;
Key_Code *binding_mods = binding_mod_set->mods;
for (i32 i = 0; i < binding_mod_count; i += 1){
if (has_modifier(event_mod_set, binding_mods[i])){
result += 1;
if (!has_modifier(event_mod_set, binding_mods[i])){
result = 0;
break;
}
result += 1;
}
return(result);
}

View File

@ -348,7 +348,7 @@ os_popup_error(char *title, char *message){
#if defined(FRED_INTERNAL)
function inline void
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();\
@ -909,7 +909,7 @@ mac_toggle_fullscreen(void){
mac_profile("Frame", prev_timer_start, mac_vars.timer_start);
#if FRED_INTERNAL
printf("\n");
//printf("\n");
#endif
}
@ -1211,6 +1211,12 @@ Input_Event *event = push_input_event(&mac_vars.frame_arena, &mac_vars.input_chu
mac_vars.active_text_input = 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);
event->kind = InputEventKind_KeyRelease;
event->key.code = key;

View File

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