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.

преди 18 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 18 години
преди 19 години
преди 19 години
преди 19 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. /* Device-specific functions */
  83. struct drv
  84. {
  85. enum caca_driver driver;
  86. struct driver_private *p;
  87. int (* init_graphics) (caca_display_t *);
  88. int (* end_graphics) (caca_display_t *);
  89. int (* set_display_title) (caca_display_t *, char const *);
  90. unsigned int (* get_display_width) (caca_display_t *);
  91. unsigned int (* get_display_height) (caca_display_t *);
  92. void (* display) (caca_display_t *);
  93. void (* handle_resize) (caca_display_t *);
  94. int (* get_event) (caca_display_t *, caca_event_t *);
  95. void (* set_mouse) (caca_display_t *, int);
  96. } drv;
  97. /* Mouse position */
  98. struct mouse
  99. {
  100. unsigned int x, y;
  101. } mouse;
  102. /* Window resize handling */
  103. struct resize
  104. {
  105. int resized; /* A resize event was requested */
  106. unsigned w, h; /* Requested width and height */
  107. } resize;
  108. /* Framerate handling */
  109. unsigned int delay, rendertime;
  110. caca_timer_t timer;
  111. int lastticks;
  112. struct events
  113. {
  114. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  115. caca_event_t buf[EVENTBUF_LEN];
  116. int queue;
  117. #endif
  118. #if defined(USE_SLANG) || defined(USE_NCURSES)
  119. caca_timer_t key_timer;
  120. unsigned int last_key_ticks;
  121. unsigned int autorepeat_ticks;
  122. caca_event_t last_key_event;
  123. #endif
  124. #if defined(USE_WIN32)
  125. unsigned char not_empty_struct;
  126. #endif
  127. } events;
  128. };
  129. /* Internal timer functions */
  130. extern void _caca_sleep(unsigned int);
  131. extern unsigned int _caca_getticks(caca_timer_t *);
  132. /* Internal event functions */
  133. extern void _caca_handle_resize(caca_display_t *);
  134. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  135. extern void _push_event(caca_display_t *, caca_event_t *);
  136. extern int _pop_event(caca_display_t *, caca_event_t *);
  137. #endif
  138. #endif /* __CACA_INTERNALS_H__ */