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

Last change on this file since 565 was 565, checked in by Sam Hocevar, 15 years ago
  • Pure VGA output driver.
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/*
2 *  libcaca       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 565 2006-03-09 12:41:02Z 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 int uint32_t;
30#endif
31
32#if !defined(_DOXYGEN_SKIP_ME)
33#   define EVENTBUF_LEN 10
34#endif
35
36/* Graphics driver */
37enum caca_driver
38{
39#if defined(USE_CONIO)
40    CACA_DRIVER_CONIO = 1,
41#endif
42#if defined(USE_NCURSES)
43    CACA_DRIVER_NCURSES = 2,
44#endif
45#if defined(USE_SLANG)
46    CACA_DRIVER_SLANG = 3,
47#endif
48#if defined(USE_X11)
49    CACA_DRIVER_X11 = 4,
50#endif
51#if defined(USE_WIN32)
52    CACA_DRIVER_WIN32 = 5,
53#endif
54#if defined(USE_GL)
55    CACA_DRIVER_GL = 6,
56#endif
57#if defined(USE_NETWORK)
58    CACA_DRIVER_NETWORK = 7,
59#endif
60#if defined(USE_VGA)
61    CACA_DRIVER_VGA = 8,
62#endif
63    CACA_DRIVER_NONE = 0
64};
65
66/* Available drivers */
67#if defined(USE_CONIO)
68void conio_init_driver(caca_t *);
69#endif
70#if defined(USE_GL)
71void gl_init_driver(caca_t *);
72#endif
73#if defined(USE_NCURSES)
74void ncurses_init_driver(caca_t *);
75#endif
76#if defined(USE_SLANG)
77void slang_init_driver(caca_t *);
78#endif
79#if defined(USE_WIN32)
80void win32_init_driver(caca_t *);
81#endif
82#if defined(USE_X11)
83void x11_init_driver(caca_t *);
84#endif
85#if defined(USE_NETWORK)
86void network_init_driver(caca_t *);
87#endif
88#if defined(USE_VGA)
89void vga_init_driver(caca_t *);
90#endif
91/* Timer structure */
92struct caca_timer
93{
94    int last_sec, last_usec;
95};
96
97/* Internal caca context */
98struct caca_context
99{
100    /* A link to our cucul canvas */
101    cucul_t *qq;
102
103    /* Device-specific functions */
104    struct drv
105    {
106        enum caca_driver driver;
107        struct driver_private *p;
108
109        int (* init_graphics) (caca_t *);
110        int (* end_graphics) (caca_t *);
111        int (* set_window_title) (caca_t *, char const *);
112        unsigned int (* get_window_width) (caca_t *);
113        unsigned int (* get_window_height) (caca_t *);
114        void (* display) (caca_t *);
115        void (* handle_resize) (caca_t *);
116        unsigned int (* get_event) (caca_t *);
117    } drv;
118
119    /* Mouse position */
120    struct mouse
121    {
122        unsigned int x, y;
123    } mouse;
124
125    /* Window resize handling */
126    struct resize
127    {
128        int resized;   /* A resize event was requested */
129        //int acked;     /* The event has been acknowledged by the user */
130        unsigned w, h; /* Requested width and height */
131    } resize;
132
133    /* Framerate handling */
134    unsigned int delay, rendertime;
135    struct caca_timer timer;
136    int lastticks;
137
138    struct events
139    {
140#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
141        unsigned int buf[EVENTBUF_LEN];
142        int queue;
143#endif
144#if defined(USE_SLANG) || defined(USE_NCURSES)
145        struct caca_timer key_timer;
146        unsigned int last_key_ticks;
147        unsigned int autorepeat_ticks;
148        unsigned int last_key;
149#endif
150    } events;
151};
152
153/* Timer functions */
154extern void _caca_sleep(unsigned int);
155extern unsigned int _caca_getticks(struct caca_timer *);
156
157#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.