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

Last change on this file since 703 was 703, checked in by Sam Hocevar, 15 years ago
  • Removed the network driver and replaced it with a cacaserver executable that has all the functionality, except it does not work yet (the stdin reading routine is missing).
  • Property svn:keywords set to Id
File size: 3.9 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 703 2006-03-27 21:37:52Z 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_NCURSES)
50    CACA_DRIVER_NCURSES = 4,
51#endif
52#if defined(USE_SLANG)
53    CACA_DRIVER_SLANG = 5,
54#endif
55#if defined(USE_VGA)
56    CACA_DRIVER_VGA = 6,
57#endif
58#if defined(USE_WIN32)
59    CACA_DRIVER_WIN32 = 7,
60#endif
61#if defined(USE_X11)
62    CACA_DRIVER_X11 = 8,
63#endif
64};
65
66/* Available external drivers */
67#if defined(USE_CONIO)
68int conio_install(caca_t *);
69#endif
70#if defined(USE_GL)
71int gl_install(caca_t *);
72#endif
73#if defined(USE_NCURSES)
74int ncurses_install(caca_t *);
75#endif
76int raw_install(caca_t *);
77#if defined(USE_SLANG)
78int slang_install(caca_t *);
79#endif
80#if defined(USE_VGA)
81int vga_install(caca_t *);
82#endif
83#if defined(USE_WIN32)
84int win32_install(caca_t *);
85#endif
86#if defined(USE_X11)
87int x11_install(caca_t *);
88#endif
89
90/* Timer structure */
91struct caca_timer
92{
93    int last_sec, last_usec;
94};
95
96/* Internal caca context */
97struct caca_context
98{
99    /* A link to our cucul canvas */
100    cucul_t *qq;
101
102    /* Device-specific functions */
103    struct drv
104    {
105        enum caca_driver driver;
106        struct driver_private *p;
107
108        int (* init_graphics) (caca_t *);
109        int (* end_graphics) (caca_t *);
110        int (* set_window_title) (caca_t *, char const *);
111        unsigned int (* get_window_width) (caca_t *);
112        unsigned int (* get_window_height) (caca_t *);
113        void (* display) (caca_t *);
114        void (* handle_resize) (caca_t *);
115        int (* get_event) (caca_t *, struct caca_event *);
116        void (* set_mouse) (caca_t *, int);
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        unsigned w, h; /* Requested width and height */
130    } resize;
131
132    /* Framerate handling */
133    unsigned int delay, rendertime;
134    struct caca_timer timer;
135    int lastticks;
136
137    struct events
138    {
139#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
140        struct caca_event buf[EVENTBUF_LEN];
141        int queue;
142#endif
143#if defined(USE_SLANG) || defined(USE_NCURSES)
144        struct caca_timer key_timer;
145        unsigned int last_key_ticks;
146        unsigned int autorepeat_ticks;
147        struct caca_event last_key_event;
148#endif
149    } events;
150};
151
152/* Internal timer functions */
153extern void _caca_sleep(unsigned int);
154extern unsigned int _caca_getticks(struct caca_timer *);
155
156/* Internal event functions */
157extern void _caca_handle_resize(caca_t *);
158#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
159extern void _push_event(caca_t *, struct caca_event *);
160extern int _pop_event(caca_t *, struct caca_event *);
161#endif
162
163#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.