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);
}
@ -274,7 +276,7 @@ map_get_binding_non_recursive(Command_Map *map, Input_Event *event, Binding_Matc
result = map->text_input_command;
}
else{
Map_Event_Breakdown breakdown = map_get_event_breakdown(event);
Map_Event_Breakdown breakdown = map_get_event_breakdown(event);
Table_Lookup lookup = table_lookup(&map->event_code_to_binding_list, breakdown.key);
if (lookup.found_match){
u64 val = 0;

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
}
@ -946,7 +946,7 @@ mac_toggle_fullscreen(void){
- (void)keyDown:(NSEvent*)event{
// NOTE(yuval): Process keyboard event
[self process_keyboard_event:event down:true];
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
// TODO(allen): Deduplicate with insertText version
// NOTE(allen): We need to manually send text for '\n' and '\t'
@ -961,9 +961,9 @@ mac_toggle_fullscreen(void){
}
if ((c == '\t') || (c == '\n')){
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->text.string = SCu8(str, 1);
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);
}
} else{
} else {
mac_vars.active_key_stroke = 0;
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;