[159] | 1 | /* |
---|
[672] | 2 | * libcaca Colour ASCII-Art library |
---|
[527] | 3 | * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> |
---|
[268] | 4 | * All Rights Reserved |
---|
[159] | 5 | * |
---|
[268] | 6 | * This library is free software; you can redistribute it and/or |
---|
[522] | 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. |
---|
[159] | 10 | */ |
---|
| 11 | |
---|
[268] | 12 | /** \file caca_internals.h |
---|
| 13 | * \version \$Id: caca_internals.h 686 2006-03-24 15:00:47Z jylam $ |
---|
| 14 | * \author Sam Hocevar <sam@zoy.org> |
---|
| 15 | * \brief The \e libcaca private header. |
---|
[205] | 16 | * |
---|
[268] | 17 | * This header contains the private types and functions used by \e libcaca. |
---|
[205] | 18 | */ |
---|
| 19 | |
---|
[193] | 20 | #ifndef __CACA_INTERNALS_H__ |
---|
| 21 | #define __CACA_INTERNALS_H__ |
---|
[159] | 22 | |
---|
[565] | 23 | #if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__) |
---|
[540] | 24 | # include <inttypes.h> |
---|
[565] | 25 | #elif !defined(CUSTOM_INTTYPES) && !defined(_DOXYGEN_SKIP_ME) |
---|
[543] | 26 | # define CUSTOM_INTTYPES |
---|
[540] | 27 | typedef unsigned char uint8_t; |
---|
| 28 | typedef unsigned short uint16_t; |
---|
[573] | 29 | typedef unsigned long int uint32_t; |
---|
| 30 | typedef long int intptr_t; |
---|
| 31 | typedef long unsigned int uintptr_t; |
---|
[540] | 32 | #endif |
---|
| 33 | |
---|
[541] | 34 | #if !defined(_DOXYGEN_SKIP_ME) |
---|
| 35 | # define EVENTBUF_LEN 10 |
---|
| 36 | #endif |
---|
| 37 | |
---|
[265] | 38 | /* Graphics driver */ |
---|
| 39 | enum caca_driver |
---|
| 40 | { |
---|
[684] | 41 | CACA_DRIVER_NONE = 0, |
---|
[265] | 42 | #if defined(USE_CONIO) |
---|
| 43 | CACA_DRIVER_CONIO = 1, |
---|
| 44 | #endif |
---|
| 45 | #if defined(USE_NCURSES) |
---|
| 46 | CACA_DRIVER_NCURSES = 2, |
---|
| 47 | #endif |
---|
| 48 | #if defined(USE_SLANG) |
---|
| 49 | CACA_DRIVER_SLANG = 3, |
---|
| 50 | #endif |
---|
| 51 | #if defined(USE_X11) |
---|
| 52 | CACA_DRIVER_X11 = 4, |
---|
| 53 | #endif |
---|
[335] | 54 | #if defined(USE_WIN32) |
---|
| 55 | CACA_DRIVER_WIN32 = 5, |
---|
| 56 | #endif |
---|
[483] | 57 | #if defined(USE_GL) |
---|
| 58 | CACA_DRIVER_GL = 6, |
---|
| 59 | #endif |
---|
[554] | 60 | #if defined(USE_NETWORK) |
---|
| 61 | CACA_DRIVER_NETWORK = 7, |
---|
| 62 | #endif |
---|
[565] | 63 | #if defined(USE_VGA) |
---|
| 64 | CACA_DRIVER_VGA = 8, |
---|
| 65 | #endif |
---|
[265] | 66 | }; |
---|
| 67 | |
---|
[539] | 68 | /* Available drivers */ |
---|
| 69 | #if defined(USE_CONIO) |
---|
[684] | 70 | int conio_install(caca_t *); |
---|
[539] | 71 | #endif |
---|
| 72 | #if defined(USE_GL) |
---|
[684] | 73 | int gl_install(caca_t *); |
---|
[539] | 74 | #endif |
---|
| 75 | #if defined(USE_NCURSES) |
---|
[684] | 76 | int ncurses_install(caca_t *); |
---|
[539] | 77 | #endif |
---|
| 78 | #if defined(USE_SLANG) |
---|
[684] | 79 | int slang_install(caca_t *); |
---|
[539] | 80 | #endif |
---|
| 81 | #if defined(USE_WIN32) |
---|
[684] | 82 | int win32_install(caca_t *); |
---|
[539] | 83 | #endif |
---|
| 84 | #if defined(USE_X11) |
---|
[684] | 85 | int x11_install(caca_t *); |
---|
[539] | 86 | #endif |
---|
[554] | 87 | #if defined(USE_NETWORK) |
---|
[684] | 88 | int network_install(caca_t *); |
---|
[554] | 89 | #endif |
---|
[565] | 90 | #if defined(USE_VGA) |
---|
[684] | 91 | int vga_install(caca_t *); |
---|
[565] | 92 | #endif |
---|
[684] | 93 | |
---|
[331] | 94 | /* Timer structure */ |
---|
| 95 | struct caca_timer |
---|
| 96 | { |
---|
| 97 | int last_sec, last_usec; |
---|
| 98 | }; |
---|
| 99 | |
---|
[524] | 100 | /* Internal caca context */ |
---|
| 101 | struct caca_context |
---|
| 102 | { |
---|
[551] | 103 | /* A link to our cucul canvas */ |
---|
[524] | 104 | cucul_t *qq; |
---|
[265] | 105 | |
---|
[551] | 106 | /* Device-specific functions */ |
---|
[550] | 107 | struct drv |
---|
[539] | 108 | { |
---|
| 109 | enum caca_driver driver; |
---|
[550] | 110 | struct driver_private *p; |
---|
[539] | 111 | |
---|
| 112 | int (* init_graphics) (caca_t *); |
---|
| 113 | int (* end_graphics) (caca_t *); |
---|
| 114 | int (* set_window_title) (caca_t *, char const *); |
---|
| 115 | unsigned int (* get_window_width) (caca_t *); |
---|
| 116 | unsigned int (* get_window_height) (caca_t *); |
---|
| 117 | void (* display) (caca_t *); |
---|
[553] | 118 | void (* handle_resize) (caca_t *); |
---|
[681] | 119 | int (* get_event) (caca_t *, struct caca_event *); |
---|
[686] | 120 | void (* show_cursor) (caca_t *); |
---|
| 121 | void (* hide_cursor) (caca_t *); |
---|
[550] | 122 | } drv; |
---|
[539] | 123 | |
---|
[551] | 124 | /* Mouse position */ |
---|
| 125 | struct mouse |
---|
| 126 | { |
---|
| 127 | unsigned int x, y; |
---|
| 128 | } mouse; |
---|
[524] | 129 | |
---|
[551] | 130 | /* Window resize handling */ |
---|
[553] | 131 | struct resize |
---|
| 132 | { |
---|
| 133 | int resized; /* A resize event was requested */ |
---|
| 134 | unsigned w, h; /* Requested width and height */ |
---|
| 135 | } resize; |
---|
[524] | 136 | |
---|
[551] | 137 | /* Framerate handling */ |
---|
[524] | 138 | unsigned int delay, rendertime; |
---|
[527] | 139 | struct caca_timer timer; |
---|
| 140 | int lastticks; |
---|
[524] | 141 | |
---|
[527] | 142 | struct events |
---|
| 143 | { |
---|
[681] | 144 | #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL) |
---|
| 145 | struct caca_event buf[EVENTBUF_LEN]; |
---|
[541] | 146 | int queue; |
---|
| 147 | #endif |
---|
[527] | 148 | #if defined(USE_SLANG) || defined(USE_NCURSES) |
---|
| 149 | struct caca_timer key_timer; |
---|
| 150 | unsigned int last_key_ticks; |
---|
| 151 | unsigned int autorepeat_ticks; |
---|
[681] | 152 | struct caca_event last_key_event; |
---|
[527] | 153 | #endif |
---|
| 154 | } events; |
---|
[524] | 155 | }; |
---|
| 156 | |
---|
[645] | 157 | /* Internal timer functions */ |
---|
[335] | 158 | extern void _caca_sleep(unsigned int); |
---|
[331] | 159 | extern unsigned int _caca_getticks(struct caca_timer *); |
---|
| 160 | |
---|
[645] | 161 | /* Internal event functions */ |
---|
| 162 | extern void _caca_handle_resize(caca_t *); |
---|
[681] | 163 | #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL) |
---|
| 164 | extern void _push_event(caca_t *, struct caca_event *); |
---|
| 165 | extern int _pop_event(caca_t *, struct caca_event *); |
---|
[645] | 166 | #endif |
---|
| 167 | |
---|
[193] | 168 | #endif /* __CACA_INTERNALS_H__ */ |
---|