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

Last change on this file since 769 was 769, checked in by Sam Hocevar, 15 years ago
  • Removed \file directives from all files except caca.h and cucul.h, to remove redundencies in the Doxygen documentation.
  • Property svn:keywords set to Id
File size: 3.7 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 *  $Id: caca_internals.h 769 2006-04-14 07:30:53Z sam $
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#ifndef __CACA_INTERNALS_H__
15#define __CACA_INTERNALS_H__
16
17#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
18#   include <inttypes.h>
19#elif !defined(CUSTOM_INTTYPES) && !defined(_DOXYGEN_SKIP_ME)
20#   define CUSTOM_INTTYPES
21typedef unsigned char uint8_t;
22typedef unsigned short uint16_t;
23typedef unsigned long int uint32_t;
24typedef long int intptr_t;
25typedef long unsigned int uintptr_t;
26#endif
27
28#if !defined(_DOXYGEN_SKIP_ME)
29#   define EVENTBUF_LEN 10
30#endif
31
32/* Graphics driver */
33enum caca_driver
34{
35    CACA_DRIVER_NONE = 0,
36    CACA_DRIVER_RAW = 1,
37#if defined(USE_CONIO)
38    CACA_DRIVER_CONIO = 2,
39#endif
40#if defined(USE_GL)
41    CACA_DRIVER_GL = 3,
42#endif
43#if defined(USE_NCURSES)
44    CACA_DRIVER_NCURSES = 4,
45#endif
46#if defined(USE_SLANG)
47    CACA_DRIVER_SLANG = 5,
48#endif
49#if defined(USE_VGA)
50    CACA_DRIVER_VGA = 6,
51#endif
52#if defined(USE_WIN32)
53    CACA_DRIVER_WIN32 = 7,
54#endif
55#if defined(USE_X11)
56    CACA_DRIVER_X11 = 8,
57#endif
58};
59
60/* Available external drivers */
61#if defined(USE_CONIO)
62int conio_install(caca_t *);
63#endif
64#if defined(USE_GL)
65int gl_install(caca_t *);
66#endif
67#if defined(USE_NCURSES)
68int ncurses_install(caca_t *);
69#endif
70int raw_install(caca_t *);
71#if defined(USE_SLANG)
72int slang_install(caca_t *);
73#endif
74#if defined(USE_VGA)
75int vga_install(caca_t *);
76#endif
77#if defined(USE_WIN32)
78int win32_install(caca_t *);
79#endif
80#if defined(USE_X11)
81int x11_install(caca_t *);
82#endif
83
84/* Timer structure */
85struct caca_timer
86{
87    int last_sec, last_usec;
88};
89
90/* Internal caca context */
91struct caca_context
92{
93    /* A link to our cucul canvas */
94    cucul_t *qq;
95
96    /* Device-specific functions */
97    struct drv
98    {
99        enum caca_driver driver;
100        struct driver_private *p;
101
102        int (* init_graphics) (caca_t *);
103        int (* end_graphics) (caca_t *);
104        int (* set_window_title) (caca_t *, char const *);
105        unsigned int (* get_window_width) (caca_t *);
106        unsigned int (* get_window_height) (caca_t *);
107        void (* display) (caca_t *);
108        void (* handle_resize) (caca_t *);
109        int (* get_event) (caca_t *, struct caca_event *);
110        void (* set_mouse) (caca_t *, int);
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        unsigned w, h; /* Requested width and height */
124    } resize;
125
126    /* Framerate handling */
127    unsigned int delay, rendertime;
128    struct caca_timer timer;
129    int lastticks;
130
131    struct events
132    {
133#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
134        struct caca_event buf[EVENTBUF_LEN];
135        int queue;
136#endif
137#if defined(USE_SLANG) || defined(USE_NCURSES)
138        struct caca_timer key_timer;
139        unsigned int last_key_ticks;
140        unsigned int autorepeat_ticks;
141        struct caca_event last_key_event;
142#endif
143    } events;
144};
145
146/* Internal timer functions */
147extern void _caca_sleep(unsigned int);
148extern unsigned int _caca_getticks(struct caca_timer *);
149
150/* Internal event functions */
151extern void _caca_handle_resize(caca_t *);
152#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
153extern void _push_event(caca_t *, struct caca_event *);
154extern int _pop_event(caca_t *, struct caca_event *);
155#endif
156
157#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.