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

Last change on this file since 554 was 554, checked in by Jean-Yves Lamoureux, 14 years ago
  • Added very preliminary network driver
  • Property svn:keywords set to Id
File size: 3.5 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 554 2006-03-08 20:03:24Z 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(_DOXYGEN_SKIP_ME)
24#   include <inttypes.h>
25#elif !defined(CUSTOM_INTTYPES)
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    CACA_DRIVER_NONE = 0
61};
62
63/* Available drivers */
64#if defined(USE_CONIO)
65void conio_init_driver(caca_t *);
66#endif
67#if defined(USE_GL)
68void gl_init_driver(caca_t *);
69#endif
70#if defined(USE_NCURSES)
71void ncurses_init_driver(caca_t *);
72#endif
73#if defined(USE_SLANG)
74void slang_init_driver(caca_t *);
75#endif
76#if defined(USE_WIN32)
77void win32_init_driver(caca_t *);
78#endif
79#if defined(USE_X11)
80void x11_init_driver(caca_t *);
81#endif
82#if defined(USE_NETWORK)
83void network_init_driver(caca_t *);
84#endif
85/* Timer structure */
86struct caca_timer
87{
88    int last_sec, last_usec;
89};
90
91/* Internal caca context */
92struct caca_context
93{
94    /* A link to our cucul canvas */
95    cucul_t *qq;
96
97    /* Device-specific functions */
98    struct drv
99    {
100        enum caca_driver driver;
101        struct driver_private *p;
102
103        int (* init_graphics) (caca_t *);
104        int (* end_graphics) (caca_t *);
105        int (* set_window_title) (caca_t *, char const *);
106        unsigned int (* get_window_width) (caca_t *);
107        unsigned int (* get_window_height) (caca_t *);
108        void (* display) (caca_t *);
109        void (* handle_resize) (caca_t *);
110        unsigned int (* get_event) (caca_t *);
111    } drv;
112
113    /* Mouse position */
114    struct mouse
115    {
116        unsigned int x, y;
117    } mouse;
118
119    /* Window resize handling */
120    struct resize
121    {
122        int resized;   /* A resize event was requested */
123        //int acked;     /* The event has been acknowledged by the user */
124        unsigned w, h; /* Requested width and height */
125    } resize;
126
127    /* Framerate handling */
128    unsigned int delay, rendertime;
129    struct caca_timer timer;
130    int lastticks;
131
132    struct events
133    {
134#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
135        unsigned int buf[EVENTBUF_LEN];
136        int queue;
137#endif
138#if defined(USE_SLANG) || defined(USE_NCURSES)
139        struct caca_timer key_timer;
140        unsigned int last_key_ticks;
141        unsigned int autorepeat_ticks;
142        unsigned int last_key;
143#endif
144    } events;
145};
146
147/* Timer functions */
148extern void _caca_sleep(unsigned int);
149extern unsigned int _caca_getticks(struct caca_timer *);
150
151#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.