X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=blobdiff_plain;f=src%2Fwinnie.cc;h=f79a9e8556605e24fa3aba39e4c56be26b88e110;hp=a2c61eed1303e5069756978435aa90db6d548580;hb=15e07ead145a859762b48ac9062a07cddf826151;hpb=e4076629a736e957739c31cd20bbbbb70327023b diff --git a/src/winnie.cc b/src/winnie.cc index a2c61ee..f79a9e8 100644 --- a/src/winnie.cc +++ b/src/winnie.cc @@ -1,3 +1,5 @@ +#include + #include "keyboard.h" #include "mouse.h" #include "shalloc.h" @@ -42,3 +44,18 @@ void winnie_shutdown() destroy_shared_memory(); } + +long winnie_get_time() +{ + static struct timeval init_tv; + struct timeval tv; + + gettimeofday(&tv, 0); + + if(!tv.tv_sec && !tv.tv_usec) { + init_tv = tv; + return 0; + } + + return (tv.tv_usec - init_tv.tv_usec) / 1000 + (tv.tv_sec - init_tv.tv_sec) * 1000; +}