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