PLATFORM LAYER FEATURE: Win32 implementation. set_key_mode determines whether to return physical key codes or language translated key codes
This commit is contained in:
parent
aa773f7413
commit
a410ce5f6c
|
@ -298,6 +298,11 @@ define_api(Arena *arena){
|
||||||
api_param(arena, call, "Arena*", "arena");
|
api_param(arena, call, "Arena*", "arena");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
API_Call *call = api_call(arena, api, "set_key_mode", "void");
|
||||||
|
api_param(arena, call, "Key_Mode", "mode");
|
||||||
|
}
|
||||||
|
|
||||||
return(api);
|
return(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1225,6 +1225,7 @@ config_init_default(Config_Data *config){
|
||||||
config->mapping = SCu8(config->mapping_space, (u64)0);
|
config->mapping = SCu8(config->mapping_space, (u64)0);
|
||||||
config->mode = SCu8(config->mode_space, (u64)0);
|
config->mode = SCu8(config->mode_space, (u64)0);
|
||||||
|
|
||||||
|
config->bind_by_physical_key = false;
|
||||||
config->use_scroll_bars = false;
|
config->use_scroll_bars = false;
|
||||||
config->use_file_bars = true;
|
config->use_file_bars = true;
|
||||||
config->hide_file_bar_in_ui = true;
|
config->hide_file_bar_in_ui = true;
|
||||||
|
@ -1298,6 +1299,7 @@ config_parse__data(Application_Links *app, Arena *arena, String_Const_u8 file_na
|
||||||
config_fixed_string_var(parsed, "mapping", 0, &config->mapping, config->mapping_space);
|
config_fixed_string_var(parsed, "mapping", 0, &config->mapping, config->mapping_space);
|
||||||
config_fixed_string_var(parsed, "mode", 0, &config->mode, config->mode_space);
|
config_fixed_string_var(parsed, "mode", 0, &config->mode, config->mode_space);
|
||||||
|
|
||||||
|
config_bool_var(parsed, "bind_by_physical_key", 0, &config->bind_by_physical_key);
|
||||||
config_bool_var(parsed, "use_scroll_bars", 0, &config->use_scroll_bars);
|
config_bool_var(parsed, "use_scroll_bars", 0, &config->use_scroll_bars);
|
||||||
config_bool_var(parsed, "use_file_bars", 0, &config->use_file_bars);
|
config_bool_var(parsed, "use_file_bars", 0, &config->use_file_bars);
|
||||||
config_bool_var(parsed, "hide_file_bar_in_ui", 0, &config->hide_file_bar_in_ui);
|
config_bool_var(parsed, "hide_file_bar_in_ui", 0, &config->hide_file_bar_in_ui);
|
||||||
|
@ -1565,6 +1567,7 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
||||||
config_feedback_string(scratch, &list, "mapping", config->mapping);
|
config_feedback_string(scratch, &list, "mapping", config->mapping);
|
||||||
config_feedback_string(scratch, &list, "mode", config->mode);
|
config_feedback_string(scratch, &list, "mode", config->mode);
|
||||||
|
|
||||||
|
config_feedback_bool(scratch, &list, "bind_by_physical_key", config->bind_by_physical_key);
|
||||||
config_feedback_bool(scratch, &list, "use_scroll_bars", config->use_scroll_bars);
|
config_feedback_bool(scratch, &list, "use_scroll_bars", config->use_scroll_bars);
|
||||||
config_feedback_bool(scratch, &list, "use_file_bars", config->use_file_bars);
|
config_feedback_bool(scratch, &list, "use_file_bars", config->use_file_bars);
|
||||||
config_feedback_bool(scratch, &list, "hide_file_bar_in_ui", config->hide_file_bar_in_ui);
|
config_feedback_bool(scratch, &list, "hide_file_bar_in_ui", config->hide_file_bar_in_ui);
|
||||||
|
@ -1635,6 +1638,13 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
||||||
description.font.file_name = get_file_path_in_fonts_folder(scratch, config->default_font_name);
|
description.font.file_name = get_file_path_in_fonts_folder(scratch, config->default_font_name);
|
||||||
modify_global_face_by_description(app, description);
|
modify_global_face_by_description(app, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config->bind_by_physical_key){
|
||||||
|
system_set_key_mode(KeyMode_Physical);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
system_set_key_mode(KeyMode_LanguageArranged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
|
|
|
@ -191,6 +191,7 @@ struct Config_Data{
|
||||||
u8 mode_space[64];
|
u8 mode_space[64];
|
||||||
String_Const_u8 mode;
|
String_Const_u8 mode;
|
||||||
|
|
||||||
|
b8 bind_by_physical_key;
|
||||||
b8 use_scroll_bars;
|
b8 use_scroll_bars;
|
||||||
b8 use_file_bars;
|
b8 use_file_bars;
|
||||||
b8 hide_file_bar_in_ui;
|
b8 hide_file_bar_in_ui;
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
#if !defined(FCODER_SYSTEM_TYPES_H)
|
#if !defined(FCODER_SYSTEM_TYPES_H)
|
||||||
#define FCODER_SYSTEM_TYPES_H
|
#define FCODER_SYSTEM_TYPES_H
|
||||||
|
|
||||||
|
typedef i32 Key_Mode;
|
||||||
|
enum{
|
||||||
|
KeyMode_LanguageArranged,
|
||||||
|
KeyMode_Physical,
|
||||||
|
};
|
||||||
|
|
||||||
struct Plat_Handle{
|
struct Plat_Handle{
|
||||||
u32 d[4];
|
u32 d[4];
|
||||||
};
|
};
|
||||||
|
|
|
@ -364,7 +364,7 @@ static Command_Metadata fcoder_metacmd_table[245] = {
|
||||||
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 171 },
|
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 171 },
|
||||||
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 183 },
|
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 183 },
|
||||||
{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 864 },
|
{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 864 },
|
||||||
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "w:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1657 },
|
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "w:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1667 },
|
||||||
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 457 },
|
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 457 },
|
||||||
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 469 },
|
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 469 },
|
||||||
{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1453 },
|
{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1453 },
|
||||||
|
|
|
@ -53,6 +53,7 @@ vtable->show_mouse_cursor = system_show_mouse_cursor;
|
||||||
vtable->set_fullscreen = system_set_fullscreen;
|
vtable->set_fullscreen = system_set_fullscreen;
|
||||||
vtable->is_fullscreen = system_is_fullscreen;
|
vtable->is_fullscreen = system_is_fullscreen;
|
||||||
vtable->get_keyboard_modifiers = system_get_keyboard_modifiers;
|
vtable->get_keyboard_modifiers = system_get_keyboard_modifiers;
|
||||||
|
vtable->set_key_mode = system_set_key_mode;
|
||||||
}
|
}
|
||||||
#if defined(DYNAMIC_LINK_API)
|
#if defined(DYNAMIC_LINK_API)
|
||||||
function void
|
function void
|
||||||
|
@ -110,6 +111,7 @@ system_show_mouse_cursor = vtable->show_mouse_cursor;
|
||||||
system_set_fullscreen = vtable->set_fullscreen;
|
system_set_fullscreen = vtable->set_fullscreen;
|
||||||
system_is_fullscreen = vtable->is_fullscreen;
|
system_is_fullscreen = vtable->is_fullscreen;
|
||||||
system_get_keyboard_modifiers = vtable->get_keyboard_modifiers;
|
system_get_keyboard_modifiers = vtable->get_keyboard_modifiers;
|
||||||
|
system_set_key_mode = vtable->set_key_mode;
|
||||||
}
|
}
|
||||||
#undef DYNAMIC_LINK_API
|
#undef DYNAMIC_LINK_API
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#define system_set_fullscreen_sig() b32 system_set_fullscreen(b32 full_screen)
|
#define system_set_fullscreen_sig() b32 system_set_fullscreen(b32 full_screen)
|
||||||
#define system_is_fullscreen_sig() b32 system_is_fullscreen(void)
|
#define system_is_fullscreen_sig() b32 system_is_fullscreen(void)
|
||||||
#define system_get_keyboard_modifiers_sig() Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena)
|
#define system_get_keyboard_modifiers_sig() Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena)
|
||||||
|
#define system_set_key_mode_sig() void system_set_key_mode(Key_Mode mode)
|
||||||
typedef String_Const_u8 system_get_path_type(Arena* arena, System_Path_Code path_code);
|
typedef String_Const_u8 system_get_path_type(Arena* arena, System_Path_Code path_code);
|
||||||
typedef String_Const_u8 system_get_canonical_type(Arena* arena, String_Const_u8 name);
|
typedef String_Const_u8 system_get_canonical_type(Arena* arena, String_Const_u8 name);
|
||||||
typedef File_List system_get_file_list_type(Arena* arena, String_Const_u8 directory);
|
typedef File_List system_get_file_list_type(Arena* arena, String_Const_u8 directory);
|
||||||
|
@ -104,6 +105,7 @@ typedef void system_show_mouse_cursor_type(i32 show);
|
||||||
typedef b32 system_set_fullscreen_type(b32 full_screen);
|
typedef b32 system_set_fullscreen_type(b32 full_screen);
|
||||||
typedef b32 system_is_fullscreen_type(void);
|
typedef b32 system_is_fullscreen_type(void);
|
||||||
typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena);
|
typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena);
|
||||||
|
typedef void system_set_key_mode_type(Key_Mode mode);
|
||||||
struct API_VTable_system{
|
struct API_VTable_system{
|
||||||
system_get_path_type *get_path;
|
system_get_path_type *get_path;
|
||||||
system_get_canonical_type *get_canonical;
|
system_get_canonical_type *get_canonical;
|
||||||
|
@ -158,6 +160,7 @@ system_show_mouse_cursor_type *show_mouse_cursor;
|
||||||
system_set_fullscreen_type *set_fullscreen;
|
system_set_fullscreen_type *set_fullscreen;
|
||||||
system_is_fullscreen_type *is_fullscreen;
|
system_is_fullscreen_type *is_fullscreen;
|
||||||
system_get_keyboard_modifiers_type *get_keyboard_modifiers;
|
system_get_keyboard_modifiers_type *get_keyboard_modifiers;
|
||||||
|
system_set_key_mode_type *set_key_mode;
|
||||||
};
|
};
|
||||||
#if defined(STATIC_LINK_API)
|
#if defined(STATIC_LINK_API)
|
||||||
internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code);
|
internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code);
|
||||||
|
@ -213,6 +216,7 @@ internal void system_show_mouse_cursor(i32 show);
|
||||||
internal b32 system_set_fullscreen(b32 full_screen);
|
internal b32 system_set_fullscreen(b32 full_screen);
|
||||||
internal b32 system_is_fullscreen(void);
|
internal b32 system_is_fullscreen(void);
|
||||||
internal Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena);
|
internal Input_Modifier_Set system_get_keyboard_modifiers(Arena* arena);
|
||||||
|
internal void system_set_key_mode(Key_Mode mode);
|
||||||
#undef STATIC_LINK_API
|
#undef STATIC_LINK_API
|
||||||
#elif defined(DYNAMIC_LINK_API)
|
#elif defined(DYNAMIC_LINK_API)
|
||||||
global system_get_path_type *system_get_path = 0;
|
global system_get_path_type *system_get_path = 0;
|
||||||
|
@ -268,5 +272,6 @@ global system_show_mouse_cursor_type *system_show_mouse_cursor = 0;
|
||||||
global system_set_fullscreen_type *system_set_fullscreen = 0;
|
global system_set_fullscreen_type *system_set_fullscreen = 0;
|
||||||
global system_is_fullscreen_type *system_is_fullscreen = 0;
|
global system_is_fullscreen_type *system_is_fullscreen = 0;
|
||||||
global system_get_keyboard_modifiers_type *system_get_keyboard_modifiers = 0;
|
global system_get_keyboard_modifiers_type *system_get_keyboard_modifiers = 0;
|
||||||
|
global system_set_key_mode_type *system_set_key_mode = 0;
|
||||||
#undef DYNAMIC_LINK_API
|
#undef DYNAMIC_LINK_API
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -241,5 +241,9 @@ API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("is_ful
|
||||||
API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("get_keyboard_modifiers"), string_u8_litexpr("Input_Modifier_Set"), string_u8_litexpr(""));
|
API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("get_keyboard_modifiers"), string_u8_litexpr("Input_Modifier_Set"), string_u8_litexpr(""));
|
||||||
api_param(arena, call, "Arena*", "arena");
|
api_param(arena, call, "Arena*", "arena");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_key_mode"), string_u8_litexpr("void"), string_u8_litexpr(""));
|
||||||
|
api_param(arena, call, "Key_Mode", "mode");
|
||||||
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,3 +51,4 @@ api(system) function void show_mouse_cursor(i32 show);
|
||||||
api(system) function b32 set_fullscreen(b32 full_screen);
|
api(system) function b32 set_fullscreen(b32 full_screen);
|
||||||
api(system) function b32 is_fullscreen(void);
|
api(system) function b32 is_fullscreen(void);
|
||||||
api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena);
|
api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena);
|
||||||
|
api(system) function void set_key_mode(Key_Mode mode);
|
||||||
|
|
|
@ -151,6 +151,7 @@ struct Win32_Vars{
|
||||||
b8 lctrl_lalt_is_altgr;
|
b8 lctrl_lalt_is_altgr;
|
||||||
b8 got_useful_event;
|
b8 got_useful_event;
|
||||||
|
|
||||||
|
Key_Mode key_mode;
|
||||||
HKL kl_universal;
|
HKL kl_universal;
|
||||||
|
|
||||||
b8 full_screen;
|
b8 full_screen;
|
||||||
|
@ -349,6 +350,11 @@ system_get_keyboard_modifiers_sig(){
|
||||||
return(copy_modifier_set(arena, &win32vars.input_chunk.pers.modifiers));
|
return(copy_modifier_set(arena, &win32vars.input_chunk.pers.modifiers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal
|
||||||
|
system_set_key_mode_sig(){
|
||||||
|
win32vars.key_mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clipboard
|
// Clipboard
|
||||||
//
|
//
|
||||||
|
@ -1097,8 +1103,12 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
||||||
b8 down = !release;
|
b8 down = !release;
|
||||||
b8 is_right = HasFlag(lParam, bit_25);
|
b8 is_right = HasFlag(lParam, bit_25);
|
||||||
|
|
||||||
|
u64 vk = wParam;
|
||||||
|
|
||||||
|
if (win32vars.key_mode == KeyMode_Physical){
|
||||||
UINT scan_code = ((lParam >> 16) & bitmask_8);
|
UINT scan_code = ((lParam >> 16) & bitmask_8);
|
||||||
UINT vk = MapVirtualKeyEx(scan_code, MAPVK_VSC_TO_VK_EX, win32vars.kl_universal);
|
vk = MapVirtualKeyEx(scan_code, MAPVK_VSC_TO_VK_EX, win32vars.kl_universal);
|
||||||
|
}
|
||||||
|
|
||||||
Input_Modifier_Set_Fixed *mods = &win32vars.input_chunk.pers.modifiers;
|
Input_Modifier_Set_Fixed *mods = &win32vars.input_chunk.pers.modifiers;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ mapping = "";
|
||||||
// "4coder" - The default 4coder mode that has been around since the beginning of time (2015)
|
// "4coder" - The default 4coder mode that has been around since the beginning of time (2015)
|
||||||
// "notepad-like" - Single "thin" cursor and highlight ranges like in notepad, sublime, notepad++, etc
|
// "notepad-like" - Single "thin" cursor and highlight ranges like in notepad, sublime, notepad++, etc
|
||||||
mode = "4coder";
|
mode = "4coder";
|
||||||
|
bind_by_physical_key = false;
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
use_scroll_bars = false;
|
use_scroll_bars = false;
|
||||||
|
|
Loading…
Reference in New Issue