Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

caca_internals.h 4.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #ifndef __CACA_INTERNALS_H__
  15. #define __CACA_INTERNALS_H__
  16. #if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
  17. # include <inttypes.h>
  18. #endif
  19. typedef struct caca_timer caca_timer_t;
  20. typedef struct caca_privevent caca_privevent_t;
  21. #if !defined(_DOXYGEN_SKIP_ME)
  22. # define EVENTBUF_LEN 10
  23. #endif
  24. /* Graphics driver */
  25. enum caca_driver
  26. {
  27. CACA_DRIVER_NONE = 0,
  28. CACA_DRIVER_RAW = 1,
  29. #if defined(USE_COCOA)
  30. CACA_DRIVER_COCOA = 2,
  31. #endif
  32. #if defined(USE_CONIO)
  33. CACA_DRIVER_CONIO = 3,
  34. #endif
  35. #if defined(USE_GL)
  36. CACA_DRIVER_GL = 4,
  37. #endif
  38. #if defined(USE_NCURSES)
  39. CACA_DRIVER_NCURSES = 5,
  40. #endif
  41. #if defined(USE_SLANG)
  42. CACA_DRIVER_SLANG = 6,
  43. #endif
  44. #if defined(USE_VGA)
  45. CACA_DRIVER_VGA = 7,
  46. #endif
  47. #if defined(USE_WIN32)
  48. CACA_DRIVER_WIN32 = 8,
  49. #endif
  50. #if defined(USE_X11)
  51. CACA_DRIVER_X11 = 9,
  52. #endif
  53. };
  54. /* Available external drivers */
  55. #if defined(USE_COCOA)
  56. int cocoa_install(caca_display_t *);
  57. #endif
  58. #if defined(USE_CONIO)
  59. int conio_install(caca_display_t *);
  60. #endif
  61. #if defined(USE_GL)
  62. int gl_install(caca_display_t *);
  63. #endif
  64. #if defined(USE_NCURSES)
  65. int ncurses_install(caca_display_t *);
  66. #endif
  67. int raw_install(caca_display_t *);
  68. #if defined(USE_SLANG)
  69. int slang_install(caca_display_t *);
  70. #endif
  71. #if defined(USE_VGA)
  72. int vga_install(caca_display_t *);
  73. #endif
  74. #if defined(USE_WIN32)
  75. int win32_install(caca_display_t *);
  76. #endif
  77. #if defined(USE_X11)
  78. int x11_install(caca_display_t *);
  79. #endif
  80. /* Timer structure */
  81. struct caca_timer
  82. {
  83. int last_sec, last_usec;
  84. };
  85. /* Private event structure */
  86. struct caca_privevent
  87. {
  88. enum caca_event_type type;
  89. union
  90. {
  91. struct { unsigned int x, y, button; } mouse;
  92. struct { unsigned int w, h; } resize;
  93. struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
  94. } data;
  95. };
  96. /* Internal caca display context */
  97. struct caca_display
  98. {
  99. /* A link to our cucul canvas */
  100. cucul_canvas_t *cv;
  101. #if defined(USE_PLUGINS)
  102. void *plugin;
  103. #endif
  104. /* Device-specific functions */
  105. struct drv
  106. {
  107. enum caca_driver driver;
  108. struct driver_private *p;
  109. int (* init_graphics) (caca_display_t *);
  110. int (* end_graphics) (caca_display_t *);
  111. int (* set_display_title) (caca_display_t *, char const *);
  112. unsigned int (* get_display_width) (caca_display_t const *);
  113. unsigned int (* get_display_height) (caca_display_t const *);
  114. void (* display) (caca_display_t *);
  115. void (* handle_resize) (caca_display_t *);
  116. int (* get_event) (caca_display_t *, caca_privevent_t *);
  117. void (* set_mouse) (caca_display_t *, int);
  118. void (* set_cursor) (caca_display_t *, int);
  119. } drv;
  120. /* Mouse position */
  121. struct mouse
  122. {
  123. unsigned int x, y;
  124. } mouse;
  125. /* Window resize handling */
  126. struct resize
  127. {
  128. int resized; /* A resize event was requested */
  129. unsigned w, h; /* Requested width and height */
  130. } resize;
  131. /* Framerate handling */
  132. unsigned int delay, rendertime;
  133. caca_timer_t timer;
  134. int lastticks;
  135. struct events
  136. {
  137. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  138. caca_privevent_t buf[EVENTBUF_LEN];
  139. int queue;
  140. #endif
  141. #if defined(USE_SLANG) || defined(USE_NCURSES)
  142. caca_timer_t key_timer;
  143. unsigned int last_key_ticks;
  144. unsigned int autorepeat_ticks;
  145. caca_privevent_t last_key_event;
  146. #endif
  147. #if defined(USE_WIN32)
  148. unsigned char not_empty_struct;
  149. #endif
  150. } events;
  151. };
  152. /* Internal timer functions */
  153. extern void _caca_sleep(unsigned int);
  154. extern unsigned int _caca_getticks(caca_timer_t *);
  155. /* Internal event functions */
  156. extern void _caca_handle_resize(caca_display_t *);
  157. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  158. extern void _push_event(caca_display_t *, caca_privevent_t *);
  159. extern int _pop_event(caca_display_t *, caca_privevent_t *);
  160. #endif
  161. /* Internal window functions */
  162. extern void _caca_set_term_title(char const *);
  163. #endif /* __CACA_INTERNALS_H__ */