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.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. #elif !defined(CUSTOM_INTTYPES) && !defined(_DOXYGEN_SKIP_ME)
  18. # define CUSTOM_INTTYPES
  19. typedef unsigned char uint8_t;
  20. typedef unsigned short uint16_t;
  21. typedef unsigned long int uint32_t;
  22. typedef long int intptr_t;
  23. typedef long unsigned int uintptr_t;
  24. #endif
  25. typedef struct caca_timer caca_timer_t;
  26. #if !defined(_DOXYGEN_SKIP_ME)
  27. # define EVENTBUF_LEN 10
  28. #endif
  29. /* Graphics driver */
  30. enum caca_driver
  31. {
  32. CACA_DRIVER_NONE = 0,
  33. CACA_DRIVER_RAW = 1,
  34. #if defined(USE_CONIO)
  35. CACA_DRIVER_CONIO = 2,
  36. #endif
  37. #if defined(USE_GL)
  38. CACA_DRIVER_GL = 3,
  39. #endif
  40. #if defined(USE_NCURSES)
  41. CACA_DRIVER_NCURSES = 4,
  42. #endif
  43. #if defined(USE_SLANG)
  44. CACA_DRIVER_SLANG = 5,
  45. #endif
  46. #if defined(USE_VGA)
  47. CACA_DRIVER_VGA = 6,
  48. #endif
  49. #if defined(USE_WIN32)
  50. CACA_DRIVER_WIN32 = 7,
  51. #endif
  52. #if defined(USE_X11)
  53. CACA_DRIVER_X11 = 8,
  54. #endif
  55. };
  56. /* Available external drivers */
  57. #if defined(USE_CONIO)
  58. int conio_install(caca_display_t *);
  59. #endif
  60. #if defined(USE_GL)
  61. int gl_install(caca_display_t *);
  62. #endif
  63. #if defined(USE_NCURSES)
  64. int ncurses_install(caca_display_t *);
  65. #endif
  66. int raw_install(caca_display_t *);
  67. #if defined(USE_SLANG)
  68. int slang_install(caca_display_t *);
  69. #endif
  70. #if defined(USE_VGA)
  71. int vga_install(caca_display_t *);
  72. #endif
  73. #if defined(USE_WIN32)
  74. int win32_install(caca_display_t *);
  75. #endif
  76. #if defined(USE_X11)
  77. int x11_install(caca_display_t *);
  78. #endif
  79. /* Timer structure */
  80. struct caca_timer
  81. {
  82. int last_sec, last_usec;
  83. };
  84. /* Internal caca display context */
  85. struct caca_display
  86. {
  87. /* A link to our cucul canvas */
  88. cucul_canvas_t *cv;
  89. /* Device-specific functions */
  90. struct drv
  91. {
  92. enum caca_driver driver;
  93. struct driver_private *p;
  94. int (* init_graphics) (caca_display_t *);
  95. int (* end_graphics) (caca_display_t *);
  96. int (* set_display_title) (caca_display_t *, char const *);
  97. unsigned int (* get_display_width) (caca_display_t *);
  98. unsigned int (* get_display_height) (caca_display_t *);
  99. void (* display) (caca_display_t *);
  100. void (* handle_resize) (caca_display_t *);
  101. int (* get_event) (caca_display_t *, caca_event_t *);
  102. void (* set_mouse) (caca_display_t *, int);
  103. } drv;
  104. /* Mouse position */
  105. struct mouse
  106. {
  107. unsigned int x, y;
  108. } mouse;
  109. /* Window resize handling */
  110. struct resize
  111. {
  112. int resized; /* A resize event was requested */
  113. unsigned w, h; /* Requested width and height */
  114. } resize;
  115. /* Framerate handling */
  116. unsigned int delay, rendertime;
  117. caca_timer_t timer;
  118. int lastticks;
  119. struct events
  120. {
  121. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  122. caca_event_t buf[EVENTBUF_LEN];
  123. int queue;
  124. #endif
  125. #if defined(USE_SLANG) || defined(USE_NCURSES)
  126. caca_timer_t key_timer;
  127. unsigned int last_key_ticks;
  128. unsigned int autorepeat_ticks;
  129. caca_event_t last_key_event;
  130. #endif
  131. #if defined(USE_WIN32)
  132. unsigned char not_empty_struct;
  133. #endif
  134. } events;
  135. };
  136. /* Internal timer functions */
  137. extern void _caca_sleep(unsigned int);
  138. extern unsigned int _caca_getticks(caca_timer_t *);
  139. /* Internal event functions */
  140. extern void _caca_handle_resize(caca_display_t *);
  141. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  142. extern void _push_event(caca_display_t *, caca_event_t *);
  143. extern int _pop_event(caca_display_t *, caca_event_t *);
  144. #endif
  145. #endif /* __CACA_INTERNALS_H__ */