summaryrefslogtreecommitdiffhomepage
path: root/src/gestures.h
diff options
context:
space:
mode:
authorRay San <[email protected]>2017-11-27 12:46:40 +0100
committerRay San <[email protected]>2017-11-27 12:46:40 +0100
commitc9722161d11b250006f17de62dd9ff17e46aeed4 (patch)
tree87d3b7f8b49bea17dc72bffd7a471980a18154f3 /src/gestures.h
parentca921e5a53fdd3412f5f81e3a739f54d68cb63a7 (diff)
downloadraylib-c9722161d11b250006f17de62dd9ff17e46aeed4.tar.gz
raylib-c9722161d11b250006f17de62dd9ff17e46aeed4.zip
Support GetCurrentTime() on macOS
Diffstat (limited to 'src/gestures.h')
-rw-r--r--src/gestures.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gestures.h b/src/gestures.h
index e2f004e2..68bdc11b 100644
--- a/src/gestures.h
+++ b/src/gestures.h
@@ -156,6 +156,11 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
#include <stdint.h> // Required for: uint64_t
#endif
+#if defined(__APPLE__) // macOS also defines __MACH__
+ #include <mach/clock.h> // Required for: clock_get_time()
+ #include <mach/mach.h> // 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;
}