From 162ffe828aca8076c513b6bad7b0322062c218dc Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 14 Nov 2017 23:33:15 -0500 Subject: [PATCH] Experiments with keyboard bindings for Mac alt keys, done and undone I think. get_clock fix for Mac --- 4coder_remapping_commands.cpp | 2 +- 4ed_font_system_functions.cpp | 2 +- platform_linux/linux_4ed.cpp | 9 +++++++++ platform_mac/mac_4ed.cpp | 8 ++++++++ platform_mac/mac_4ed.m | 7 +++++++ platform_mac/osx_objective_c_to_cpp_links.h | 3 +++ platform_unix/unix_4ed_functions.cpp | 12 ------------ 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/4coder_remapping_commands.cpp b/4coder_remapping_commands.cpp index cc30d797..9108702e 100644 --- a/4coder_remapping_commands.cpp +++ b/4coder_remapping_commands.cpp @@ -64,7 +64,7 @@ bind(Bind_Helper *context, Key_Code code, int32_t m, int32_t t, Generic_Command } else if (t == 1){ bind(context, code, MDFR_CTRL|MDFR_CMND|f, cmd); - bind(context, code, MDFR_ALT|MDFR_CMND|f, cmd); + bind(context, code, MDFR_ALT|f, cmd); } }break; } diff --git a/4ed_font_system_functions.cpp b/4ed_font_system_functions.cpp index fb9ef972..d624517d 100644 --- a/4ed_font_system_functions.cpp +++ b/4ed_font_system_functions.cpp @@ -297,7 +297,7 @@ system_set_font(System_Functions *system, Partition *part, Render_Font *font, ch } } else{ - LOGF("font \"%.*s\" name is too long to load in current build (max %u)\n", filename_len, filename, sizeof(font->filename) - 1); + LOGF("font \"%.*s\" name is too long to load in current build (max %u)\n", filename_len, filename, (u32)(sizeof(font->filename) - 1)); } } diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index 52e66893..6f917b9b 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -234,6 +234,15 @@ Sys_Get_4ed_Path_Sig(system_get_4ed_path){ } #include "unix_4ed_functions.cpp" + +internal +Sys_Now_Time_Sig(system_now_time){ + struct timespec spec; + clock_gettime(CLOCK_REALTIME, &spec); + u64 result = (spec.tv_sec*UINT64_C(1000000)) + (spec.tv_nsec/UINT64_C(1000)); + return(result); +} + #include "4ed_shared_file_handling.cpp" //////////////////////////////// diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index 0d8b37e4..6051fce7 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -126,6 +126,14 @@ Sys_Get_4ed_Path_Sig(system_get_4ed_path){ //#include "mac_fd_check.cpp" #include "unix_4ed_functions.cpp" + +internal +Sys_Now_Time_Sig(system_now_time){ + f64 t = osx_timer_seconds(); + u64 result = (u64)(t*1000000.f); + return(result); +} + #include "4ed_shared_file_handling.cpp" //////////////////////////////// diff --git a/platform_mac/mac_4ed.m b/platform_mac/mac_4ed.m index c580e721..22500a15 100644 --- a/platform_mac/mac_4ed.m +++ b/platform_mac/mac_4ed.m @@ -86,6 +86,7 @@ osx_error_dialogue(char *str){ static DISPLINK_SIG(osx_display_link); @implementation My4coderView + - (void)keyDown:(NSEvent *)event{ NSString *real = [event charactersIgnoringModifiers]; NSString *with_mods = [event characters]; @@ -710,6 +711,12 @@ osx_close_app(void){ [NSApp terminate: nil]; } +f32 +osx_timer_seconds(void){ + f32 result = CACurrentMediaTime(); + return(result); +} + int main(int argc, char **argv){ memset(&osx_objc, 0, sizeof(osx_objc)); diff --git a/platform_mac/osx_objective_c_to_cpp_links.h b/platform_mac/osx_objective_c_to_cpp_links.h index 370ecd1f..ef0ac3f2 100644 --- a/platform_mac/osx_objective_c_to_cpp_links.h +++ b/platform_mac/osx_objective_c_to_cpp_links.h @@ -126,6 +126,9 @@ osx_is_fullscreen(void); external void osx_close_app(void); +external f32 +osx_timer_seconds(void); + #endif // BOTTOM diff --git a/platform_unix/unix_4ed_functions.cpp b/platform_unix/unix_4ed_functions.cpp index 288bb7b9..08964dff 100644 --- a/platform_unix/unix_4ed_functions.cpp +++ b/platform_unix/unix_4ed_functions.cpp @@ -440,17 +440,5 @@ system_directory_exists(char *path){ return(result); } -// -// Time -// - -internal -Sys_Now_Time_Sig(system_now_time){ - struct timespec spec; - clock_gettime(CLOCK_REALTIME, &spec); - u64 result = (spec.tv_sec * UINT64_C(1000000)) + (spec.tv_nsec / UINT64_C(1000)); - return(result); -} - // BOTTOM