input debug working, fixed frame waster in gui

master
Allen Webster 2016-06-07 13:22:42 -04:00
parent 48eeb211ae
commit e49249c7e4
5 changed files with 95 additions and 42 deletions

View File

@ -31,6 +31,7 @@ typedef enum{
MDFR_CONTROL_INDEX, MDFR_CONTROL_INDEX,
MDFR_ALT_INDEX, MDFR_ALT_INDEX,
MDFR_CAPS_INDEX, MDFR_CAPS_INDEX,
MDFR_HOLD_INDEX,
// always last // always last
MDFR_INDEX_COUNT MDFR_INDEX_COUNT
} Key_Control; } Key_Control;

29
4ed.cpp
View File

@ -3559,9 +3559,36 @@ App_Step_Sig(app_step){
} }
} }
// NOTE(allen): Keyboard input to command coroutine. // NOTE(allen): Pass keyboard events to debug
Available_Input available_input = init_available_input(&key_summary, &input->mouse); Available_Input available_input = init_available_input(&key_summary, &input->mouse);
#if FRED_INTERNAL
{
Debug_Data *debug = &models->debug;
Key_Summary key_data = get_key_data(&available_input);
Debug_Input_Event *events = debug->input_events;
i32 count = key_data.count;
i32 preserved_inputs = ArrayCount(debug->input_events) - count;
memmove(events + count, events,
sizeof(Debug_Input_Event)*preserved_inputs);
for (i32 i = 0; i < key_data.count; ++i){
Key_Event_Data key = get_single_key(&key_data, i);
events[i].key = key.keycode;
events[i].is_hold = key.modifiers[MDFR_HOLD_INDEX];
events[i].is_ctrl = key.modifiers[MDFR_CONTROL_INDEX];
events[i].is_alt = key.modifiers[MDFR_ALT_INDEX];
events[i].is_shift = key.modifiers[MDFR_SHIFT_INDEX];
}
}
#endif
// NOTE(allen): Keyboard input to command coroutine.
if (models->command_coroutine != 0){ if (models->command_coroutine != 0){
Coroutine *command_coroutine = models->command_coroutine; Coroutine *command_coroutine = models->command_coroutine;
u32 get_flags = models->command_coroutine_flags[0]; u32 get_flags = models->command_coroutine_flags[0];

View File

@ -4466,6 +4466,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
} }
}break; }break;
#if FRED_INTERNAL
case VUI_Debug: case VUI_Debug:
{ {
view->current_scroll = &view->gui_scroll; view->current_scroll = &view->gui_scroll;
@ -4487,7 +4488,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
string.size = 0; string.size = 0;
u64 time = system->now_time_stamp(); u64 time = system->now_time_stamp();
append(&string, "last event time stamp: "); append(&string, "last redraw: ");
append_u64_to_str(&string, time); append_u64_to_str(&string, time);
gui_do_text_field(target, string, empty_str); gui_do_text_field(target, string, empty_str);
@ -4547,20 +4548,35 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
append(&string, " "); append(&string, " ");
} }
if (input_event->key >= ' ' && input_event->key <= '~'){ if (input_event->key > ' ' && input_event->key <= '~'){
append(&string, make_string(&input_event->key, 1)); append(&string, make_string(&input_event->key, 1));
} }
else if (input_event->key == ' '){
append(&string, "space");
}
else if (input_event->key == '\n'){
append(&string, "\\n");
}
else if (input_event->key == '\t'){
append(&string, "\\t");
}
else{ else{
String str; String str;
str.str = global_key_name(input_event->key, &str.size); str.str = global_key_name(input_event->key, &str.size);
if (str.str){
str.memory_size = str.size + 1; str.memory_size = str.size + 1;
append(&string, str); append(&string, str);
} }
else{
append(&string, "unrecognized!");
}
}
gui_do_text_field(target, string, empty_str); gui_do_text_field(target, string, empty_str);
} }
} }
}break; }break;
#endif
} }
} }
} }

View File

@ -490,9 +490,11 @@ gui_begin_list(GUI_Target *target, GUI_id id, i32 list_i,
} }
} }
if (list_max > 0){
if (list_i < list_min || list_i >= list_max){ if (list_i < list_min || list_i >= list_max){
result = 1; result = 1;
} }
}
if (result){ if (result){
gui_fill_update(update, target, h); gui_fill_update(update, target, h);
@ -500,8 +502,13 @@ gui_begin_list(GUI_Target *target, GUI_id id, i32 list_i,
gui_update_adjustment(update, list_min); gui_update_adjustment(update, list_min);
} }
else if (list_i >= list_max){ else if (list_i >= list_max){
if (list_max > 0){
gui_update_adjustment(update, list_max - 1); gui_update_adjustment(update, list_max - 1);
} }
else{
gui_update_adjustment(update, 0);
}
}
if (target->has_list_index_position){ if (target->has_list_index_position){
gui_update_position(update, target->list_index_position); gui_update_position(update, target->list_index_position);
} }

View File

@ -1532,12 +1532,13 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
result2 = 0; result2 = 0;
} }
// TODO(allen): This is becoming a really major issue. Apparently // TODO(allen): This is becoming a really major issue.
// control + i outputs a '\t' which is VALID ascii according to this system. // Apparently control + i outputs a '\t' which is VALID ascii
// So it reports the key as '\t'. This wasn't an issue before because we were // according to this system. So it reports the key as '\t'.
// ignoring control when computing character_no_caps_lock which is what // This wasn't an issue before because we were ignoring control
// is used for commands. But that is incorrect for some keyboard layouts where // when computing character_no_caps_lock which is what is used
// control+alt is used to signal AltGr for important keys. // for commands. But that is incorrect for some keyboard layouts
// where control+alt is used to signal AltGr for important keys.
if (result1 && result2){ if (result1 && result2){
char c1 = char_to_upper((char)x1); char c1 = char_to_upper((char)x1);
char cParam = char_to_upper((char)wParam); char cParam = char_to_upper((char)wParam);
@ -1595,6 +1596,7 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
data[*count].keycode = key; data[*count].keycode = key;
} }
memcpy(data[*count].modifiers, control_keys, control_keys_size); memcpy(data[*count].modifiers, control_keys, control_keys_size);
data[*count].modifiers[MDFR_HOLD_INDEX] = previous_state;
++(*count); ++(*count);
} }
} }