| 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. 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 | #include "stubs.h" |
|---|
| 19 | |
|---|
| 20 | typedef struct caca_timer caca_timer_t; |
|---|
| 21 | typedef struct caca_privevent caca_privevent_t; |
|---|
| 22 | |
|---|
| 23 | #if !defined(_DOXYGEN_SKIP_ME) |
|---|
| 24 | # define EVENTBUF_LEN 10 |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | /* Graphics driver */ |
|---|
| 28 | enum caca_driver |
|---|
| 29 | { |
|---|
| 30 | CACA_DRIVER_NONE = 0, |
|---|
| 31 | CACA_DRIVER_RAW = 1, |
|---|
| 32 | #if defined(USE_COCOA) |
|---|
| 33 | CACA_DRIVER_COCOA = 2, |
|---|
| 34 | #endif |
|---|
| 35 | #if defined(USE_CONIO) |
|---|
| 36 | CACA_DRIVER_CONIO = 3, |
|---|
| 37 | #endif |
|---|
| 38 | #if defined(USE_GL) |
|---|
| 39 | CACA_DRIVER_GL = 4, |
|---|
| 40 | #endif |
|---|
| 41 | #if defined(USE_NCURSES) |
|---|
| 42 | CACA_DRIVER_NCURSES = 5, |
|---|
| 43 | #endif |
|---|
| 44 | #if defined(USE_SLANG) |
|---|
| 45 | CACA_DRIVER_SLANG = 6, |
|---|
| 46 | #endif |
|---|
| 47 | #if defined(USE_VGA) |
|---|
| 48 | CACA_DRIVER_VGA = 7, |
|---|
| 49 | #endif |
|---|
| 50 | #if defined(USE_WIN32) |
|---|
| 51 | CACA_DRIVER_WIN32 = 8, |
|---|
| 52 | #endif |
|---|
| 53 | #if defined(USE_X11) |
|---|
| 54 | CACA_DRIVER_X11 = 9, |
|---|
| 55 | #endif |
|---|
| 56 | }; |
|---|
| 57 | |
|---|
| 58 | /* Available external drivers */ |
|---|
| 59 | #if defined(USE_COCOA) |
|---|
| 60 | int cocoa_install(caca_display_t *); |
|---|
| 61 | #endif |
|---|
| 62 | #if defined(USE_CONIO) |
|---|
| 63 | int conio_install(caca_display_t *); |
|---|
| 64 | #endif |
|---|
| 65 | #if defined(USE_GL) |
|---|
| 66 | int gl_install(caca_display_t *); |
|---|
| 67 | #endif |
|---|
| 68 | #if defined(USE_NCURSES) |
|---|
| 69 | int ncurses_install(caca_display_t *); |
|---|
| 70 | #endif |
|---|
| 71 | int raw_install(caca_display_t *); |
|---|
| 72 | #if defined(USE_SLANG) |
|---|
| 73 | int slang_install(caca_display_t *); |
|---|
| 74 | #endif |
|---|
| 75 | #if defined(USE_VGA) |
|---|
| 76 | int vga_install(caca_display_t *); |
|---|
| 77 | #endif |
|---|
| 78 | #if defined(USE_WIN32) |
|---|
| 79 | int win32_install(caca_display_t *); |
|---|
| 80 | #endif |
|---|
| 81 | #if defined(USE_X11) |
|---|
| 82 | int x11_install(caca_display_t *); |
|---|
| 83 | #endif |
|---|
| 84 | |
|---|
| 85 | /* Timer structure */ |
|---|
| 86 | struct caca_timer |
|---|
| 87 | { |
|---|
| 88 | int last_sec, last_usec; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | /* Private event structure */ |
|---|
| 92 | struct caca_privevent |
|---|
| 93 | { |
|---|
| 94 | enum caca_event_type type; |
|---|
| 95 | |
|---|
| 96 | union |
|---|
| 97 | { |
|---|
| 98 | struct { unsigned int x, y, button; } mouse; |
|---|
| 99 | struct { unsigned int w, h; } resize; |
|---|
| 100 | struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key; |
|---|
| 101 | } data; |
|---|
| 102 | }; |
|---|
| 103 | |
|---|
| 104 | /* Internal caca display context */ |
|---|
| 105 | struct caca_display |
|---|
| 106 | { |
|---|
| 107 | /* A link to our cucul canvas */ |
|---|
| 108 | cucul_canvas_t *cv; |
|---|
| 109 | int autorelease; |
|---|
| 110 | |
|---|
| 111 | #if defined(USE_PLUGINS) |
|---|
| 112 | void *plugin; |
|---|
| 113 | #endif |
|---|
| 114 | |
|---|
| 115 | /* Device-specific functions */ |
|---|
| 116 | struct drv |
|---|
| 117 | { |
|---|
| 118 | char const * driver; |
|---|
| 119 | enum caca_driver id; |
|---|
| 120 | struct driver_private *p; |
|---|
| 121 | |
|---|
| 122 | int (* init_graphics) (caca_display_t *); |
|---|
| 123 | int (* end_graphics) (caca_display_t *); |
|---|
| 124 | int (* set_display_title) (caca_display_t *, char const *); |
|---|
| 125 | unsigned int (* get_display_width) (caca_display_t const *); |
|---|
| 126 | unsigned int (* get_display_height) (caca_display_t const *); |
|---|
| 127 | void (* display) (caca_display_t *); |
|---|
| 128 | void (* handle_resize) (caca_display_t *); |
|---|
| 129 | int (* get_event) (caca_display_t *, caca_privevent_t *); |
|---|
| 130 | void (* set_mouse) (caca_display_t *, int); |
|---|
| 131 | void (* set_cursor) (caca_display_t *, int); |
|---|
| 132 | } drv; |
|---|
| 133 | |
|---|
| 134 | /* Mouse position */ |
|---|
| 135 | struct mouse |
|---|
| 136 | { |
|---|
| 137 | unsigned int x, y; |
|---|
| 138 | } mouse; |
|---|
| 139 | |
|---|
| 140 | /* Window resize handling */ |
|---|
| 141 | struct resize |
|---|
| 142 | { |
|---|
| 143 | int resized; /* A resize event was requested */ |
|---|
| 144 | int allow; /* The display driver allows resizing */ |
|---|
| 145 | unsigned w, h; /* Requested width and height */ |
|---|
| 146 | } resize; |
|---|
| 147 | |
|---|
| 148 | /* Framerate handling */ |
|---|
| 149 | unsigned int delay, rendertime; |
|---|
| 150 | caca_timer_t timer; |
|---|
| 151 | int lastticks; |
|---|
| 152 | |
|---|
| 153 | struct events |
|---|
| 154 | { |
|---|
| 155 | #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL) |
|---|
| 156 | caca_privevent_t buf[EVENTBUF_LEN]; |
|---|
| 157 | int queue; |
|---|
| 158 | #endif |
|---|
| 159 | #if defined(USE_SLANG) || defined(USE_NCURSES) |
|---|
| 160 | caca_timer_t key_timer; |
|---|
| 161 | unsigned int last_key_ticks; |
|---|
| 162 | unsigned int autorepeat_ticks; |
|---|
| 163 | caca_privevent_t last_key_event; |
|---|
| 164 | #endif |
|---|
| 165 | #if defined(USE_WIN32) |
|---|
| 166 | unsigned char not_empty_struct; |
|---|
| 167 | #endif |
|---|
| 168 | } events; |
|---|
| 169 | }; |
|---|
| 170 | |
|---|
| 171 | /* Internal timer functions */ |
|---|
| 172 | extern void _caca_sleep(unsigned int); |
|---|
| 173 | extern unsigned int _caca_getticks(caca_timer_t *); |
|---|
| 174 | |
|---|
| 175 | /* Internal event functions */ |
|---|
| 176 | extern void _caca_handle_resize(caca_display_t *); |
|---|
| 177 | #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL) |
|---|
| 178 | extern void _push_event(caca_display_t *, caca_privevent_t *); |
|---|
| 179 | extern int _pop_event(caca_display_t *, caca_privevent_t *); |
|---|
| 180 | #endif |
|---|
| 181 | |
|---|
| 182 | /* Internal window functions */ |
|---|
| 183 | extern void _caca_set_term_title(char const *); |
|---|
| 184 | |
|---|
| 185 | #endif /* __CACA_INTERNALS_H__ */ |
|---|