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

Last change on this file since 541 was 541, checked in by Sam Hocevar, 15 years ago
  • Got rid of static variables in the event code.
  • Property svn:keywords set to Id
File size: 4.6 KB
RevLine 
[159]1/*
[268]2 *  libcaca       ASCII-Art library
[527]3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
[268]4 *                All Rights Reserved
[159]5 *
[268]6 *  This library is free software; you can redistribute it and/or
[522]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.
[159]10 */
11
[268]12/** \file caca_internals.h
13 *  \version \$Id: caca_internals.h 541 2006-03-07 10:37:59Z sam $
14 *  \author Sam Hocevar <sam@zoy.org>
15 *  \brief The \e libcaca private header.
[205]16 *
[268]17 *  This header contains the private types and functions used by \e libcaca.
[205]18 */
19
[193]20#ifndef __CACA_INTERNALS_H__
21#define __CACA_INTERNALS_H__
[159]22
[540]23#if defined(HAVE_INTTYPES_H) || defined(_DOXYGEN_SKIP_ME)
24#   include <inttypes.h>
25#else
26typedef unsigned char uint8_t;
27typedef unsigned short uint16_t;
28typedef unsigned int uint32_t;
29#endif
30
[539]31#if defined(USE_GL)
32#   include <GL/glut.h>
33#endif
34#if defined(USE_NCURSES)
35#   if defined(HAVE_NCURSES_H)
36#       include <ncurses.h>
37#   else
38#       include <curses.h>
39#   endif
40#endif
41#if defined(USE_WIN32)
42#   include <windows.h>
43#endif
[524]44#if defined(USE_X11)
[539]45#   include <X11/Xlib.h>
[524]46#endif
47
[541]48#if !defined(_DOXYGEN_SKIP_ME)
49#   define EVENTBUF_LEN 10
50#endif
51
[265]52/* Graphics driver */
53enum caca_driver
54{
55#if defined(USE_CONIO)
56    CACA_DRIVER_CONIO = 1,
57#endif
58#if defined(USE_NCURSES)
59    CACA_DRIVER_NCURSES = 2,
60#endif
61#if defined(USE_SLANG)
62    CACA_DRIVER_SLANG = 3,
63#endif
64#if defined(USE_X11)
65    CACA_DRIVER_X11 = 4,
66#endif
[335]67#if defined(USE_WIN32)
68    CACA_DRIVER_WIN32 = 5,
69#endif
[483]70#if defined(USE_GL)
71    CACA_DRIVER_GL = 6,
72#endif
[265]73    CACA_DRIVER_NONE = 0
74};
75
[539]76/* Available drivers */
77#if defined(USE_CONIO)
78void conio_init_driver(caca_t *);
79#endif
80#if defined(USE_GL)
81void gl_init_driver(caca_t *);
82#endif
83#if defined(USE_NCURSES)
84void ncurses_init_driver(caca_t *);
85#endif
86#if defined(USE_SLANG)
87void slang_init_driver(caca_t *);
88#endif
89#if defined(USE_WIN32)
90void win32_init_driver(caca_t *);
91#endif
92#if defined(USE_X11)
93void x11_init_driver(caca_t *);
94#endif
95
[331]96/* Timer structure */
97struct caca_timer
98{
99    int last_sec, last_usec;
100};
101
[524]102/* Internal caca context */
103struct caca_context
104{
105    cucul_t *qq;
[265]106
[539]107    struct driver
108    {
109        enum caca_driver driver;
110
111        int (* init_graphics) (caca_t *);
112        int (* end_graphics) (caca_t *);
113        int (* set_window_title) (caca_t *, char const *);
114        unsigned int (* get_window_width) (caca_t *);
115        unsigned int (* get_window_height) (caca_t *);
116        void (* display) (caca_t *);
[540]117        void (* handle_resize) (caca_t *, unsigned int *, unsigned int *);
[539]118    } driver;
119
[541]120    //unsigned int width, height;
121    unsigned int mouse_x, mouse_y;
[524]122
123    int resize;
124    int resize_event;
125
126    unsigned int delay, rendertime;
[527]127    struct caca_timer timer;
128    int lastticks;
[524]129
[527]130    struct events
131    {
[541]132#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
133        unsigned int buf[EVENTBUF_LEN];
134        int queue;
135#endif
[527]136#if defined(USE_SLANG) || defined(USE_NCURSES)
137        struct caca_timer key_timer;
138        unsigned int last_key_ticks;
139        unsigned int autorepeat_ticks;
140        unsigned int last_key;
141#endif
142    } events;
143
[540]144    /* FIXME: maybe this should go away */
[524]145#if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
146    struct x11
147    {
148        Display *dpy;
149        Window window;
150        Pixmap pixmap;
151        GC gc;
152        long int event_mask;
153        int font_width, font_height;
154        unsigned int new_width, new_height;
155        int colors[16];
156        Font font;
157        XFontStruct *font_struct;
158        int font_offset;
159#if defined(HAVE_X11_XKBLIB_H)
[527]160        Bool autorepeat;
[524]161#endif
162    } x11;
163#endif
[527]164#if defined(USE_NCURSES)
165    struct ncurses
166    {
167        int attr[16*16];
[539]168        mmask_t oldmask;
[527]169    } ncurses;
170#endif
171#if defined(USE_CONIO)
172    struct conio
173    {
174        struct text_info ti;
175        char *screen;
176    } conio;
177#endif
178#if defined(USE_WIN32)
179    struct win32
180    {
181        HANDLE hin, hout;
182        HANDLE front, back;
183        CHAR_INFO *buffer;
[540]184        CONSOLE_CURSOR_INFO cci;
[527]185    } win32;
186#endif
187#if defined(USE_GL)
188    struct gl
189    {
190        int window;
191        unsigned int width, height;
192        float font_width, font_height;
193        float incx, incy;
194        int id[94];
195        unsigned char resized, bit;
196        unsigned char mouse_changed, mouse_clicked;
197        unsigned int mouse_x, mouse_y;
198        unsigned int mouse_button, mouse_state;
199
200        unsigned char key;
201        int special_key;
202        int new_width;
203        int new_height;
204
205        float sw, sh;
206    } gl;
207#endif
[524]208};
209
[331]210/* Timer functions */
[335]211extern void _caca_sleep(unsigned int);
[331]212extern unsigned int _caca_getticks(struct caca_timer *);
213
[193]214#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.