Changeset 335
- Timestamp:
- Jan 11, 2004, 2:45:57 AM (19 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/configure.ac
r333 r335 30 30 31 31 AC_CHECK_HEADERS(inttypes.h endian.h) 32 AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp usleep Sleep )32 AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp usleep Sleep gettimeofday) 33 33 AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") 34 34 -
libcaca/trunk/src/caca.c
r331 r335 48 48 #if defined(USE_X11) 49 49 # include <X11/Xlib.h> 50 #endif 51 #if defined(USE_WIN32) 52 # include <windows.h> 50 53 #endif 51 54 … … 157 160 #endif 158 161 #if defined(USE_X11) 159 /* Nothing to do */ 162 if(_caca_driver == CACA_DRIVER_X11) 163 { 164 /* Nothing to do */ 165 } 166 else 167 #endif 168 #if defined(USE_WIN32) 169 if(_caca_driver == CACA_DRIVER_WIN32) 170 { 171 /* Nothing to do */ 172 printf("initialising win32 driver\n"); 173 } 174 else 160 175 #endif 161 176 { … … 374 389 else 375 390 #endif 391 #if defined(USE_WIN32) 392 if(_caca_driver == CACA_DRIVER_WIN32) 393 { 394 /* Nothing to do */ 395 } 396 else 397 #endif 376 398 { 377 399 /* Dummy */ … … 391 413 if(var && *var) 392 414 { 415 #if defined(USE_WIN32) 416 if(!strcasecmp(var, "win32")) 417 _caca_driver = CACA_DRIVER_WIN32; 418 else 419 #endif 393 420 #if defined(USE_CONIO) 394 421 if(!strcasecmp(var, "conio")) … … 417 444 #endif 418 445 446 #if defined(USE_WIN32) 447 _caca_driver = CACA_DRIVER_WIN32; 448 return; 449 #endif 419 450 #if defined(USE_CONIO) 420 451 _caca_driver = CACA_DRIVER_CONIO; … … 488 519 static void caca_init_terminal(void) 489 520 { 490 #if defined(HAVE_GETENV) && defined(HAVE_PUTENV) 521 #if defined(HAVE_GETENV) && defined(HAVE_PUTENV) && \ 522 (defined(USE_SLANG) || defined(USE_NCURSES)) 491 523 char *term, *colorterm, *other; 524 #endif 492 525 493 526 #if defined(USE_SLANG) … … 499 532 return; 500 533 534 #if defined(HAVE_GETENV) && defined(HAVE_PUTENV) && \ 535 (defined(USE_SLANG) || defined(USE_NCURSES)) 501 536 term = getenv("TERM"); 502 537 colorterm = getenv("COLORTERM"); -
libcaca/trunk/src/caca_internals.h
r331 r335 46 46 CACA_DRIVER_X11 = 4, 47 47 #endif 48 #if defined(USE_WIN32) 49 CACA_DRIVER_WIN32 = 5, 50 #endif 48 51 CACA_DRIVER_NONE = 0 49 52 }; … … 65 68 66 69 /* Timer functions */ 70 extern void _caca_sleep(unsigned int); 67 71 extern unsigned int _caca_getticks(struct caca_timer *); 68 72 -
libcaca/trunk/src/graphics.c
r332 r335 62 62 #include <string.h> 63 63 #include <stdlib.h> 64 #include <unistd.h>65 64 #include <stdarg.h> 66 65 … … 936 935 ticks += _caca_getticks(&timer)) 937 936 { 938 #if defined(HAVE_USLEEP) 939 usleep(IDLE_USEC); 940 #elif defined(HAVE_SLEEP) 941 Sleep(IDLE_USEC / 1000); 942 #else 943 SLEEP 944 #endif 937 _caca_sleep(IDLE_USEC); 945 938 } 946 939 -
libcaca/trunk/src/io.c
r332 r335 48 48 # include <X11/keysym.h> 49 49 #endif 50 51 #include <unistd.h> 50 #if defined(USE_WIN32) 51 # include <windows.h> 52 #endif 52 53 53 54 #include "caca.h" … … 122 123 return event; 123 124 124 #if defined(HAVE_USLEEP) 125 usleep(10000); 126 #elif defined(HAVE_SLEEP) 127 Sleep(10); 128 #else 129 SLEEP 130 #endif 125 _caca_sleep(10000); 131 126 } 132 127 } … … 543 538 else 544 539 #endif 540 #if defined(USE_WIN32) 541 if(_caca_driver == CACA_DRIVER_WIN32) 542 { 543 return CACA_EVENT_NONE; 544 } 545 else 546 #endif 545 547 { 546 548 /* Dummy */ -
libcaca/trunk/src/time.c
r331 r335 34 34 #include <time.h> 35 35 36 #if defined(USE_WIN32) 37 # include <windows.h> 38 #endif 39 40 #include <unistd.h> 41 36 42 #include "caca.h" 37 43 #include "caca_internals.h" 38 44 45 void _caca_sleep(unsigned int usec) 46 { 47 #if defined(HAVE_USLEEP) 48 usleep(usec); 49 #elif defined(HAVE_SLEEP) 50 Sleep(usec / 1000); 51 #else 52 SLEEP 53 #endif 54 } 55 39 56 unsigned int _caca_getticks(struct caca_timer *timer) 40 57 { 58 #if defined(HAVE_GETTIMEOFDAY) 41 59 struct timeval tv; 60 #elif defined(USE_WIN32) 61 static long long int freq = -1LL; 62 long long int usec; 63 #endif 42 64 unsigned int ticks = 0; 65 int new_sec, new_usec; 43 66 67 #if defined(HAVE_GETTIMEOFDAY) 44 68 gettimeofday(&tv, NULL); 69 new_sec = tv.tv_sec; 70 new_usec = tv.tv_usec; 71 #elif defined(USE_WIN32) 72 if(freq == -1LL) 73 { 74 if(!QueryPerformanceFrequency((LARGE_INTEGER *)&freq)) 75 freq = 0; 76 } 77 78 QueryPerformanceCounter((LARGE_INTEGER *)&usec); 79 new_sec = usec / freq; 80 new_usec = usec % freq; 81 #endif 45 82 46 83 if(timer->last_sec != 0) … … 48 85 /* If the delay was greater than 60 seconds, return 10 seconds 49 86 * otherwise we may overflow our ticks counter. */ 50 if( tv.tv_sec >= timer->last_sec + 60)87 if(new_sec >= timer->last_sec + 60) 51 88 ticks = 60 * 1000000; 52 89 else 53 90 { 54 ticks = ( tv.tv_sec - timer->last_sec) * 1000000;55 ticks += tv.tv_usec;91 ticks = (new_sec - timer->last_sec) * 1000000; 92 ticks += new_usec; 56 93 ticks -= timer->last_usec; 57 94 } 58 95 } 59 96 60 timer->last_sec = tv.tv_sec;61 timer->last_usec = tv.tv_usec;97 timer->last_sec = new_sec; 98 timer->last_usec = new_usec; 62 99 63 100 return ticks; -
libcaca/trunk/test/event.c
r332 r335 26 26 #include <stdio.h> 27 27 #include <string.h> 28 #include <stdlib.h> 28 29 29 30 #include "caca.h"
Note: See TracChangeset
for help on using the changeset viewer.