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