25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

158 satır
3.7 KiB

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