You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

164 lines
3.9 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Do What The Fuck You Want To
  8. * Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. /** \file caca_internals.h
  12. * \version \$Id$
  13. * \author Sam Hocevar <sam@zoy.org>
  14. * \brief The \e libcaca private header.
  15. *
  16. * This header contains the private types and functions used by \e libcaca.
  17. */
  18. #ifndef __CACA_INTERNALS_H__
  19. #define __CACA_INTERNALS_H__
  20. #if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
  21. # include <inttypes.h>
  22. #elif !defined(CUSTOM_INTTYPES) && !defined(_DOXYGEN_SKIP_ME)
  23. # define CUSTOM_INTTYPES
  24. typedef unsigned char uint8_t;
  25. typedef unsigned short uint16_t;
  26. typedef unsigned long int uint32_t;
  27. typedef long int intptr_t;
  28. typedef long unsigned int uintptr_t;
  29. #endif
  30. #if !defined(_DOXYGEN_SKIP_ME)
  31. # define EVENTBUF_LEN 10
  32. #endif
  33. /* Graphics driver */
  34. enum caca_driver
  35. {
  36. CACA_DRIVER_NONE = 0,
  37. CACA_DRIVER_RAW = 1,
  38. #if defined(USE_CONIO)
  39. CACA_DRIVER_CONIO = 2,
  40. #endif
  41. #if defined(USE_GL)
  42. CACA_DRIVER_GL = 3,
  43. #endif
  44. #if defined(USE_NCURSES)
  45. CACA_DRIVER_NCURSES = 4,
  46. #endif
  47. #if defined(USE_SLANG)
  48. CACA_DRIVER_SLANG = 5,
  49. #endif
  50. #if defined(USE_VGA)
  51. CACA_DRIVER_VGA = 6,
  52. #endif
  53. #if defined(USE_WIN32)
  54. CACA_DRIVER_WIN32 = 7,
  55. #endif
  56. #if defined(USE_X11)
  57. CACA_DRIVER_X11 = 8,
  58. #endif
  59. };
  60. /* Available external drivers */
  61. #if defined(USE_CONIO)
  62. int conio_install(caca_t *);
  63. #endif
  64. #if defined(USE_GL)
  65. int gl_install(caca_t *);
  66. #endif
  67. #if defined(USE_NCURSES)
  68. int ncurses_install(caca_t *);
  69. #endif
  70. int raw_install(caca_t *);
  71. #if defined(USE_SLANG)
  72. int slang_install(caca_t *);
  73. #endif
  74. #if defined(USE_VGA)
  75. int vga_install(caca_t *);
  76. #endif
  77. #if defined(USE_WIN32)
  78. int win32_install(caca_t *);
  79. #endif
  80. #if defined(USE_X11)
  81. int x11_install(caca_t *);
  82. #endif
  83. /* Timer structure */
  84. struct caca_timer
  85. {
  86. int last_sec, last_usec;
  87. };
  88. /* Internal caca context */
  89. struct caca_context
  90. {
  91. /* A link to our cucul canvas */
  92. cucul_t *qq;
  93. /* Device-specific functions */
  94. struct drv
  95. {
  96. enum caca_driver driver;
  97. struct driver_private *p;
  98. int (* init_graphics) (caca_t *);
  99. int (* end_graphics) (caca_t *);
  100. int (* set_window_title) (caca_t *, char const *);
  101. unsigned int (* get_window_width) (caca_t *);
  102. unsigned int (* get_window_height) (caca_t *);
  103. void (* display) (caca_t *);
  104. void (* handle_resize) (caca_t *);
  105. int (* get_event) (caca_t *, struct caca_event *);
  106. void (* set_mouse) (caca_t *, int);
  107. } drv;
  108. /* Mouse position */
  109. struct mouse
  110. {
  111. unsigned int x, y;
  112. } mouse;
  113. /* Window resize handling */
  114. struct resize
  115. {
  116. int resized; /* A resize event was requested */
  117. unsigned w, h; /* Requested width and height */
  118. } resize;
  119. /* Framerate handling */
  120. unsigned int delay, rendertime;
  121. struct caca_timer timer;
  122. int lastticks;
  123. struct events
  124. {
  125. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  126. struct caca_event buf[EVENTBUF_LEN];
  127. int queue;
  128. #endif
  129. #if defined(USE_SLANG) || defined(USE_NCURSES)
  130. struct caca_timer key_timer;
  131. unsigned int last_key_ticks;
  132. unsigned int autorepeat_ticks;
  133. struct caca_event last_key_event;
  134. #endif
  135. } events;
  136. };
  137. /* Internal timer functions */
  138. extern void _caca_sleep(unsigned int);
  139. extern unsigned int _caca_getticks(struct caca_timer *);
  140. /* Internal event functions */
  141. extern void _caca_handle_resize(caca_t *);
  142. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  143. extern void _push_event(caca_t *, struct caca_event *);
  144. extern int _pop_event(caca_t *, struct caca_event *);
  145. #endif
  146. #endif /* __CACA_INTERNALS_H__ */