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

Last change on this file since 686 was 686, checked in by Jean-Yves Lamoureux, 15 years ago
  • Added caca_show/hide_cursor, and corresponding GL binding
  • Property svn:keywords set to Id
File size: 4.0 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 *  This library is free software; you can redistribute it and/or
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.
10 */
11
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.
16 *
17 *  This header contains the private types and functions used by \e libcaca.
18 */
19
20#ifndef __CACA_INTERNALS_H__
21#define __CACA_INTERNALS_H__
22
23#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
24#   include <inttypes.h>
25#elif !defined(CUSTOM_INTTYPES) && !defined(_DOXYGEN_SKIP_ME)
26#   define CUSTOM_INTTYPES
27typedef unsigned char uint8_t;
28typedef unsigned short uint16_t;
29typedef unsigned long int uint32_t;
30typedef long int intptr_t;
31typedef long unsigned int uintptr_t;
32#endif
33
34#if !defined(_DOXYGEN_SKIP_ME)
35#   define EVENTBUF_LEN 10
36#endif
37
38/* Graphics driver */
39enum caca_driver
40{
41    CACA_DRIVER_NONE = 0,
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
54#if defined(USE_WIN32)
55    CACA_DRIVER_WIN32 = 5,
56#endif
57#if defined(USE_GL)
58    CACA_DRIVER_GL = 6,
59#endif
60#if defined(USE_NETWORK)
61    CACA_DRIVER_NETWORK = 7,
62#endif
63#if defined(USE_VGA)
64    CACA_DRIVER_VGA = 8,
65#endif
66};
67
68/* Available drivers */
69#if defined(USE_CONIO)
70int conio_install(caca_t *);
71#endif
72#if defined(USE_GL)
73int gl_install(caca_t *);
74#endif
75#if defined(USE_NCURSES)
76int ncurses_install(caca_t *);
77#endif
78#if defined(USE_SLANG)
79int slang_install(caca_t *);
80#endif
81#if defined(USE_WIN32)
82int win32_install(caca_t *);
83#endif
84#if defined(USE_X11)
85int x11_install(caca_t *);
86#endif
87#if defined(USE_NETWORK)
88int network_install(caca_t *);
89#endif
90#if defined(USE_VGA)
91int vga_install(caca_t *);
92#endif
93
94/* Timer structure */
95struct caca_timer
96{
97    int last_sec, last_usec;
98};
99
100/* Internal caca context */
101struct caca_context
102{
103    /* A link to our cucul canvas */
104    cucul_t *qq;
105
106    /* Device-specific functions */
107    struct drv
108    {
109        enum caca_driver driver;
110        struct driver_private *p;
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 *);
118        void (* handle_resize) (caca_t *);
119        int (* get_event) (caca_t *, struct caca_event *);
120        void (* show_cursor) (caca_t *);
121        void (* hide_cursor) (caca_t *);
122    } drv;
123
124    /* Mouse position */
125    struct mouse
126    {
127        unsigned int x, y;
128    } mouse;
129
130    /* Window resize handling */
131    struct resize
132    {
133        int resized;   /* A resize event was requested */
134        unsigned w, h; /* Requested width and height */
135    } resize;
136
137    /* Framerate handling */
138    unsigned int delay, rendertime;
139    struct caca_timer timer;
140    int lastticks;
141
142    struct events
143    {
144#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
145        struct caca_event buf[EVENTBUF_LEN];
146        int queue;
147#endif
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;
152        struct caca_event last_key_event;
153#endif
154    } events;
155};
156
157/* Internal timer functions */
158extern void _caca_sleep(unsigned int);
159extern unsigned int _caca_getticks(struct caca_timer *);
160
161/* Internal event functions */
162extern void _caca_handle_resize(caca_t *);
163#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
164extern void _push_event(caca_t *, struct caca_event *);
165extern int _pop_event(caca_t *, struct caca_event *);
166#endif
167
168#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.