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

Last change on this file since 700 was 699, checked in by Sam Hocevar, 15 years ago
  • Created a minimal raw driver that outputs stuff to stdout.
  • 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 699 2006-03-27 18:07:18Z sam $
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    CACA_DRIVER_RAW = 1,
43#if defined(USE_CONIO)
44    CACA_DRIVER_CONIO = 2,
45#endif
46#if defined(USE_GL)
47    CACA_DRIVER_GL = 3,
48#endif
49#if defined(USE_NETWORK)
50    CACA_DRIVER_NETWORK = 4,
51#endif
52#if defined(USE_NCURSES)
53    CACA_DRIVER_NCURSES = 5,
54#endif
55#if defined(USE_SLANG)
56    CACA_DRIVER_SLANG = 6,
57#endif
58#if defined(USE_VGA)
59    CACA_DRIVER_VGA = 7,
60#endif
61#if defined(USE_WIN32)
62    CACA_DRIVER_WIN32 = 8,
63#endif
64#if defined(USE_X11)
65    CACA_DRIVER_X11 = 9,
66#endif
67};
68
69/* Available external drivers */
70#if defined(USE_CONIO)
71int conio_install(caca_t *);
72#endif
73#if defined(USE_GL)
74int gl_install(caca_t *);
75#endif
76#if defined(USE_NETWORK)
77int network_install(caca_t *);
78#endif
79#if defined(USE_NCURSES)
80int ncurses_install(caca_t *);
81#endif
82int raw_install(caca_t *);
83#if defined(USE_SLANG)
84int slang_install(caca_t *);
85#endif
86#if defined(USE_VGA)
87int vga_install(caca_t *);
88#endif
89#if defined(USE_WIN32)
90int win32_install(caca_t *);
91#endif
92#if defined(USE_X11)
93int x11_install(caca_t *);
94#endif
95
96/* Timer structure */
97struct caca_timer
98{
99    int last_sec, last_usec;
100};
101
102/* Internal caca context */
103struct caca_context
104{
105    /* A link to our cucul canvas */
106    cucul_t *qq;
107
108    /* Device-specific functions */
109    struct drv
110    {
111        enum caca_driver driver;
112        struct driver_private *p;
113
114        int (* init_graphics) (caca_t *);
115        int (* end_graphics) (caca_t *);
116        int (* set_window_title) (caca_t *, char const *);
117        unsigned int (* get_window_width) (caca_t *);
118        unsigned int (* get_window_height) (caca_t *);
119        void (* display) (caca_t *);
120        void (* handle_resize) (caca_t *);
121        int (* get_event) (caca_t *, struct caca_event *);
122        void (* set_mouse) (caca_t *, int);
123    } drv;
124
125    /* Mouse position */
126    struct mouse
127    {
128        unsigned int x, y;
129    } mouse;
130
131    /* Window resize handling */
132    struct resize
133    {
134        int resized;   /* A resize event was requested */
135        unsigned w, h; /* Requested width and height */
136    } resize;
137
138    /* Framerate handling */
139    unsigned int delay, rendertime;
140    struct caca_timer timer;
141    int lastticks;
142
143    struct events
144    {
145#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
146        struct caca_event buf[EVENTBUF_LEN];
147        int queue;
148#endif
149#if defined(USE_SLANG) || defined(USE_NCURSES)
150        struct caca_timer key_timer;
151        unsigned int last_key_ticks;
152        unsigned int autorepeat_ticks;
153        struct caca_event last_key_event;
154#endif
155    } events;
156};
157
158/* Internal timer functions */
159extern void _caca_sleep(unsigned int);
160extern unsigned int _caca_getticks(struct caca_timer *);
161
162/* Internal event functions */
163extern void _caca_handle_resize(caca_t *);
164#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
165extern void _push_event(caca_t *, struct caca_event *);
166extern int _pop_event(caca_t *, struct caca_event *);
167#endif
168
169#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.