Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

170 rindas
4.0 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_NETWORK)
  45. CACA_DRIVER_NETWORK = 4,
  46. #endif
  47. #if defined(USE_NCURSES)
  48. CACA_DRIVER_NCURSES = 5,
  49. #endif
  50. #if defined(USE_SLANG)
  51. CACA_DRIVER_SLANG = 6,
  52. #endif
  53. #if defined(USE_VGA)
  54. CACA_DRIVER_VGA = 7,
  55. #endif
  56. #if defined(USE_WIN32)
  57. CACA_DRIVER_WIN32 = 8,
  58. #endif
  59. #if defined(USE_X11)
  60. CACA_DRIVER_X11 = 9,
  61. #endif
  62. };
  63. /* Available external drivers */
  64. #if defined(USE_CONIO)
  65. int conio_install(caca_t *);
  66. #endif
  67. #if defined(USE_GL)
  68. int gl_install(caca_t *);
  69. #endif
  70. #if defined(USE_NETWORK)
  71. int network_install(caca_t *);
  72. #endif
  73. #if defined(USE_NCURSES)
  74. int ncurses_install(caca_t *);
  75. #endif
  76. int raw_install(caca_t *);
  77. #if defined(USE_SLANG)
  78. int slang_install(caca_t *);
  79. #endif
  80. #if defined(USE_VGA)
  81. int vga_install(caca_t *);
  82. #endif
  83. #if defined(USE_WIN32)
  84. int win32_install(caca_t *);
  85. #endif
  86. #if defined(USE_X11)
  87. int x11_install(caca_t *);
  88. #endif
  89. /* Timer structure */
  90. struct caca_timer
  91. {
  92. int last_sec, last_usec;
  93. };
  94. /* Internal caca context */
  95. struct caca_context
  96. {
  97. /* A link to our cucul canvas */
  98. cucul_t *qq;
  99. /* Device-specific functions */
  100. struct drv
  101. {
  102. enum caca_driver driver;
  103. struct driver_private *p;
  104. int (* init_graphics) (caca_t *);
  105. int (* end_graphics) (caca_t *);
  106. int (* set_window_title) (caca_t *, char const *);
  107. unsigned int (* get_window_width) (caca_t *);
  108. unsigned int (* get_window_height) (caca_t *);
  109. void (* display) (caca_t *);
  110. void (* handle_resize) (caca_t *);
  111. int (* get_event) (caca_t *, struct caca_event *);
  112. void (* set_mouse) (caca_t *, int);
  113. } drv;
  114. /* Mouse position */
  115. struct mouse
  116. {
  117. unsigned int x, y;
  118. } mouse;
  119. /* Window resize handling */
  120. struct resize
  121. {
  122. int resized; /* A resize event was requested */
  123. unsigned w, h; /* Requested width and height */
  124. } resize;
  125. /* Framerate handling */
  126. unsigned int delay, rendertime;
  127. struct caca_timer timer;
  128. int lastticks;
  129. struct events
  130. {
  131. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  132. struct caca_event buf[EVENTBUF_LEN];
  133. int queue;
  134. #endif
  135. #if defined(USE_SLANG) || defined(USE_NCURSES)
  136. struct caca_timer key_timer;
  137. unsigned int last_key_ticks;
  138. unsigned int autorepeat_ticks;
  139. struct caca_event last_key_event;
  140. #endif
  141. } events;
  142. };
  143. /* Internal timer functions */
  144. extern void _caca_sleep(unsigned int);
  145. extern unsigned int _caca_getticks(struct caca_timer *);
  146. /* Internal event functions */
  147. extern void _caca_handle_resize(caca_t *);
  148. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  149. extern void _push_event(caca_t *, struct caca_event *);
  150. extern int _pop_event(caca_t *, struct caca_event *);
  151. #endif
  152. #endif /* __CACA_INTERNALS_H__ */