You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

158 lines
3.6 KiB

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