source: libcaca/trunk/caca/caca_internals.h @ 906

Last change on this file since 906 was 859, checked in by Sam Hocevar, 17 years ago
  • Removed duplicate uint*_t defines from *_internal.h and included common.h in all .c files that needed it.
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
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 859 2006-04-24 20:35:59Z sam $
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#endif
20
21typedef struct caca_timer caca_timer_t;
22
23#if !defined(_DOXYGEN_SKIP_ME)
24#   define EVENTBUF_LEN 10
25#endif
26
27/* Graphics driver */
28enum caca_driver
29{
30    CACA_DRIVER_NONE = 0,
31    CACA_DRIVER_RAW = 1,
32#if defined(USE_CONIO)
33    CACA_DRIVER_CONIO = 2,
34#endif
35#if defined(USE_GL)
36    CACA_DRIVER_GL = 3,
37#endif
38#if defined(USE_NCURSES)
39    CACA_DRIVER_NCURSES = 4,
40#endif
41#if defined(USE_SLANG)
42    CACA_DRIVER_SLANG = 5,
43#endif
44#if defined(USE_VGA)
45    CACA_DRIVER_VGA = 6,
46#endif
47#if defined(USE_WIN32)
48    CACA_DRIVER_WIN32 = 7,
49#endif
50#if defined(USE_X11)
51    CACA_DRIVER_X11 = 8,
52#endif
53};
54
55/* Available external drivers */
56#if defined(USE_CONIO)
57int conio_install(caca_display_t *);
58#endif
59#if defined(USE_GL)
60int gl_install(caca_display_t *);
61#endif
62#if defined(USE_NCURSES)
63int ncurses_install(caca_display_t *);
64#endif
65int raw_install(caca_display_t *);
66#if defined(USE_SLANG)
67int slang_install(caca_display_t *);
68#endif
69#if defined(USE_VGA)
70int vga_install(caca_display_t *);
71#endif
72#if defined(USE_WIN32)
73int win32_install(caca_display_t *);
74#endif
75#if defined(USE_X11)
76int x11_install(caca_display_t *);
77#endif
78
79/* Timer structure */
80struct caca_timer
81{
82    int last_sec, last_usec;
83};
84
85/* Internal caca display context */
86struct caca_display
87{
88    /* A link to our cucul canvas */
89    cucul_canvas_t *cv;
90
91    /* Device-specific functions */
92    struct drv
93    {
94        enum caca_driver driver;
95        struct driver_private *p;
96
97        int (* init_graphics) (caca_display_t *);
98        int (* end_graphics) (caca_display_t *);
99        int (* set_display_title) (caca_display_t *, char const *);
100        unsigned int (* get_display_width) (caca_display_t *);
101        unsigned int (* get_display_height) (caca_display_t *);
102        void (* display) (caca_display_t *);
103        void (* handle_resize) (caca_display_t *);
104        int (* get_event) (caca_display_t *, caca_event_t *);
105        void (* set_mouse) (caca_display_t *, int);
106    } drv;
107
108    /* Mouse position */
109    struct mouse
110    {
111        unsigned int x, y;
112    } mouse;
113
114    /* Window resize handling */
115    struct resize
116    {
117        int resized;   /* A resize event was requested */
118        unsigned w, h; /* Requested width and height */
119    } resize;
120
121    /* Framerate handling */
122    unsigned int delay, rendertime;
123    caca_timer_t timer;
124    int lastticks;
125
126    struct events
127    {
128#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
129        caca_event_t buf[EVENTBUF_LEN];
130        int queue;
131#endif
132#if defined(USE_SLANG) || defined(USE_NCURSES)
133        caca_timer_t key_timer;
134        unsigned int last_key_ticks;
135        unsigned int autorepeat_ticks;
136        caca_event_t last_key_event;
137#endif
138#if defined(USE_WIN32)
139                unsigned char not_empty_struct;
140#endif
141    } events;
142};
143
144/* Internal timer functions */
145extern void _caca_sleep(unsigned int);
146extern unsigned int _caca_getticks(caca_timer_t *);
147
148/* Internal event functions */
149extern void _caca_handle_resize(caca_display_t *);
150#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
151extern void _push_event(caca_display_t *, caca_event_t *);
152extern int _pop_event(caca_display_t *, caca_event_t *);
153#endif
154
155#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.