No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

caca_internals.h 3.8 KiB

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