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

Last change on this file since 819 was 819, checked in by Sam Hocevar, 14 years ago
  • More function mass-renaming: caca_attach -> caca_create_display, etc.
  • 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 *  $Id: caca_internals.h 819 2006-04-19 10:10:58Z 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
28typedef struct caca_timer caca_timer_t;
29
30#if !defined(_DOXYGEN_SKIP_ME)
31#   define EVENTBUF_LEN 10
32#endif
33
34/* Graphics driver */
35enum caca_driver
36{
37    CACA_DRIVER_NONE = 0,
38    CACA_DRIVER_RAW = 1,
39#if defined(USE_CONIO)
40    CACA_DRIVER_CONIO = 2,
41#endif
42#if defined(USE_GL)
43    CACA_DRIVER_GL = 3,
44#endif
45#if defined(USE_NCURSES)
46    CACA_DRIVER_NCURSES = 4,
47#endif
48#if defined(USE_SLANG)
49    CACA_DRIVER_SLANG = 5,
50#endif
51#if defined(USE_VGA)
52    CACA_DRIVER_VGA = 6,
53#endif
54#if defined(USE_WIN32)
55    CACA_DRIVER_WIN32 = 7,
56#endif
57#if defined(USE_X11)
58    CACA_DRIVER_X11 = 8,
59#endif
60};
61
62/* Available external drivers */
63#if defined(USE_CONIO)
64int conio_install(caca_display_t *);
65#endif
66#if defined(USE_GL)
67int gl_install(caca_display_t *);
68#endif
69#if defined(USE_NCURSES)
70int ncurses_install(caca_display_t *);
71#endif
72int raw_install(caca_display_t *);
73#if defined(USE_SLANG)
74int slang_install(caca_display_t *);
75#endif
76#if defined(USE_VGA)
77int vga_install(caca_display_t *);
78#endif
79#if defined(USE_WIN32)
80int win32_install(caca_display_t *);
81#endif
82#if defined(USE_X11)
83int x11_install(caca_display_t *);
84#endif
85
86/* Timer structure */
87struct caca_timer
88{
89    int last_sec, last_usec;
90};
91
92/* Internal caca display context */
93struct caca_display
94{
95    /* A link to our cucul canvas */
96    cucul_canvas_t *cv;
97
98    /* Device-specific functions */
99    struct drv
100    {
101        enum caca_driver driver;
102        struct driver_private *p;
103
104        int (* init_graphics) (caca_display_t *);
105        int (* end_graphics) (caca_display_t *);
106        int (* set_display_title) (caca_display_t *, char const *);
107        unsigned int (* get_display_width) (caca_display_t *);
108        unsigned int (* get_display_height) (caca_display_t *);
109        void (* display) (caca_display_t *);
110        void (* handle_resize) (caca_display_t *);
111        int (* get_event) (caca_display_t *, caca_event_t *);
112        void (* set_mouse) (caca_display_t *, int);
113    } drv;
114
115    /* Mouse position */
116    struct mouse
117    {
118        unsigned int x, y;
119    } mouse;
120
121    /* Window resize handling */
122    struct resize
123    {
124        int resized;   /* A resize event was requested */
125        unsigned w, h; /* Requested width and height */
126    } resize;
127
128    /* Framerate handling */
129    unsigned int delay, rendertime;
130    caca_timer_t timer;
131    int lastticks;
132
133    struct events
134    {
135#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
136        caca_event_t buf[EVENTBUF_LEN];
137        int queue;
138#endif
139#if defined(USE_SLANG) || defined(USE_NCURSES)
140        caca_timer_t key_timer;
141        unsigned int last_key_ticks;
142        unsigned int autorepeat_ticks;
143        caca_event_t last_key_event;
144#endif
145#if defined(USE_WIN32)
146                unsigned char not_empty_struct;
147#endif
148    } events;
149};
150
151/* Internal timer functions */
152extern void _caca_sleep(unsigned int);
153extern unsigned int _caca_getticks(caca_timer_t *);
154
155/* Internal event functions */
156extern void _caca_handle_resize(caca_display_t *);
157#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
158extern void _push_event(caca_display_t *, caca_event_t *);
159extern int _pop_event(caca_display_t *, caca_event_t *);
160#endif
161
162#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.