diff --git a/src/gestures.h b/src/gestures.h index e2f004e2c..68bdc11bf 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -156,6 +156,11 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang #include // Required for: uint64_t #endif +#if defined(__APPLE__) // macOS also defines __MACH__ + #include // Required for: clock_get_time() + #include // Required for: mach_timespec_t +#endif + //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- @@ -532,6 +537,22 @@ static double GetCurrentTime(void) time = ((double)nowTime/1000000.0); // Time in miliseconds #endif +#if defined(__APPLE__) + //#define CLOCK_REALTIME CALENDAR_CLOCK + //#define CLOCK_MONOTONIC SYSTEM_CLOCK + + clock_serv_t cclock; + mach_timespec_t now; + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); + + // NOTE: OS X does not have clock_gettime(), using clock_get_time() + clock_get_time(cclock, &now); + mach_port_deallocate(mach_task_self(), cclock); + uint64_t nowTime = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec; // Time in nanoseconds + + time = ((double)nowTime/1000000.0); // Time in miliseconds +#endif + return time; }