2017-11-08 18:24:30 +00:00
|
|
|
/*
|
|
|
|
4coder_remapping_commands.cpp - Commands that remap all of the keys to one of the maps
|
|
|
|
in the set of default maps.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FCODER_REMAPPING_COMMANDS_CPP)
|
|
|
|
#define FCODER_REMAPPING_COMMANDS_CPP
|
|
|
|
|
|
|
|
//
|
|
|
|
// Buffer Filling Helpers
|
|
|
|
//
|
|
|
|
|
2017-11-18 22:40:10 +00:00
|
|
|
#include "4coder_generated/remapping.h"
|
|
|
|
|
2017-11-09 00:56:26 +00:00
|
|
|
void
|
2017-11-15 16:58:29 +00:00
|
|
|
default_keys(Bind_Helper *context){
|
2017-11-18 22:40:10 +00:00
|
|
|
fill_keys_default(context);
|
2017-11-09 00:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mac_default_keys(Bind_Helper *context){
|
2017-11-20 03:24:37 +00:00
|
|
|
fill_keys_mac_default(context);
|
2017-11-09 00:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Remapping Commands
|
|
|
|
//
|
|
|
|
|
|
|
|
static Bind_Helper
|
|
|
|
get_context_on_global_part(void){
|
2018-11-20 08:18:54 +00:00
|
|
|
Bind_Helper result = {};
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 size = (1 << 20);
|
2017-11-09 00:56:26 +00:00
|
|
|
for (;;){
|
|
|
|
void *data = push_array(&global_part, char, size);
|
|
|
|
if (data != 0){
|
|
|
|
result = begin_bind_helper(data, size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
size = (size >> 1);
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2017-11-15 23:57:21 +00:00
|
|
|
CUSTOM_COMMAND_SIG(set_bindings_choose)
|
|
|
|
CUSTOM_DOC("Remap keybindings using the 'choose' mapping rule.")
|
|
|
|
{
|
2017-11-21 21:30:40 +00:00
|
|
|
#if defined(IS_WINDOWS) || defined(IS_LINUX)
|
2017-11-09 00:56:26 +00:00
|
|
|
|
|
|
|
set_bindings_default(app);
|
|
|
|
|
2017-11-21 21:30:40 +00:00
|
|
|
#elif defined(IS_MAC)
|
2017-11-09 00:56:26 +00:00
|
|
|
|
|
|
|
set_bindings_mac_default(app);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-11-15 23:57:21 +00:00
|
|
|
CUSTOM_COMMAND_SIG(set_bindings_default)
|
|
|
|
CUSTOM_DOC("Remap keybindings using the 'default' mapping rule.")
|
|
|
|
{
|
2017-11-09 00:56:26 +00:00
|
|
|
Temp_Memory temp = begin_temp_memory(&global_part);
|
|
|
|
|
|
|
|
Bind_Helper context = get_context_on_global_part();
|
|
|
|
set_all_default_hooks(&context);
|
|
|
|
default_keys(&context);
|
|
|
|
Bind_Buffer result = end_bind_helper_get_buffer(&context);
|
|
|
|
global_set_mapping(app, result.data, result.size);
|
|
|
|
|
|
|
|
end_temp_memory(temp);
|
|
|
|
}
|
|
|
|
|
2017-11-15 23:57:21 +00:00
|
|
|
CUSTOM_COMMAND_SIG(set_bindings_mac_default)
|
|
|
|
CUSTOM_DOC("Remap keybindings using the 'mac-default' mapping rule.")
|
|
|
|
{
|
2017-11-09 00:56:26 +00:00
|
|
|
Temp_Memory temp = begin_temp_memory(&global_part);
|
|
|
|
|
|
|
|
Bind_Helper context = get_context_on_global_part();
|
|
|
|
set_all_default_hooks(&context);
|
|
|
|
mac_default_keys(&context);
|
|
|
|
Bind_Buffer result = end_bind_helper_get_buffer(&context);
|
|
|
|
global_set_mapping(app, result.data, result.size);
|
|
|
|
|
|
|
|
end_temp_memory(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|