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