ui part 1
[voxelands-alt.git] / inc / wm.h
blob3ca2f31f2f1471e23e6f6121e6b9dbd0d2708a90
1 #ifndef _WM_H_
2 #define _WM_H_
4 #include "common.h"
6 #ifdef _WM_EXPOSE_ALL
8 #define GL_GLEXT_PROTOTYPES
9 #include <GL/gl.h>
10 #include <GL/glext.h>
12 #ifndef WIN32
13 #include <X11/Xlib.h>
14 #include <GL/glx.h>
15 #include <X11/extensions/xf86vmode.h>
16 #else
17 #include <windows.h>
18 #endif
20 #define SYM_TYPE_NONE 0x00
21 #define SYM_TYPE_MOUSE 0x01
22 #define SYM_TYPE_KEY 0x02
23 #define SYM_TYPE_SKEY 0x03
24 #define SYM_TYPE_MOD 0x04
26 #define EVENT_NONE 0x00
27 #define EVENT_BUTTON_DOWN 0x01
28 #define EVENT_BUTTON_UP 0x02
29 #define EVENT_KEY_DOWN 0x03
30 #define EVENT_KEY_UP 0x04
31 #define EVENT_MOUSE_MOTION 0x05
33 #define MOUSE_BUTTON_LEFT 0x00
34 #define MOUSE_BUTTON_RIGHT 0x01
35 #define MOUSE_BUTTON_CENTRE 0x02
36 #define MOUSE_BUTTON_UP 0x03
37 #define MOUSE_BUTTON_DOWN 0x04
38 #define MOUSE_MOTION 0x05
40 #define SYM_MOD_CTRL 0x01
41 #define SYM_MOD_ALT 0x02
42 #define SYM_MOD_SHIFT 0x04
43 #define SYM_MOD_SUPER 0x08
45 #define SYM_KEY_SPACE 0x01
46 #define SYM_KEY_ESCAPE 0x02
47 #define SYM_KEY_TAB 0x03
48 #define SYM_KEY_KP0 0x04
49 #define SYM_KEY_KP1 0x05
50 #define SYM_KEY_KP2 0x06
51 #define SYM_KEY_KP3 0x07
52 #define SYM_KEY_KP4 0x08
53 #define SYM_KEY_KP5 0x09
54 #define SYM_KEY_KP6 0x0A
55 #define SYM_KEY_KP7 0x0B
56 #define SYM_KEY_KP8 0x0C
57 #define SYM_KEY_KP9 0x0D
58 #define SYM_KEY_UP 0x0E
59 #define SYM_KEY_DOWN 0x0F
60 #define SYM_KEY_LEFT 0x10
61 #define SYM_KEY_RIGHT 0x11
62 #define SYM_KEY_F1 0x12
63 #define SYM_KEY_F2 0x13
64 #define SYM_KEY_F3 0x14
65 #define SYM_KEY_F4 0x15
66 #define SYM_KEY_F5 0x16
67 #define SYM_KEY_F6 0x17
68 #define SYM_KEY_F7 0x18
69 #define SYM_KEY_F8 0x19
70 #define SYM_KEY_F9 0x1A
71 #define SYM_KEY_F10 0x1B
72 #define SYM_KEY_F11 0x1C
73 #define SYM_KEY_F12 0x1D
74 #define SYM_KEY_BCKSPC 0x1E
75 #define SYM_KEY_DELETE 0x1F
76 #define SYM_KEY_ENTER 0x20
77 #define SYM_KEY_RETURN SYM_KEY_ENTER
78 #define SYM_KEY_KPEQ 0x21
79 #define SYM_KEY_KPMUL 0x22
80 #define SYM_KEY_KPADD 0x23
81 #define SYM_KEY_KPSUB 0x24
82 #define SYM_KEY_KPDOT 0x25
83 #define SYM_KEY_KPDIV 0x26
85 #ifndef _HAVE_CURSOR_TYPE
86 #define _HAVE_CURSOR_TYPE
87 struct material_s;
88 typedef struct cursor_s {
89 struct material_s *mat;
90 int w;
91 int h;
92 int x;
93 int y;
94 } cursor_t;
95 #endif
97 #ifndef _HAVE_WM_TYPE
98 #define _HAVE_WM_TYPE
99 typedef struct wm_s {
100 struct {
101 int height;
102 int width;
103 int max_height;
104 int max_width;
105 } size;
107 int fullscreen;
108 int frame_cap;
109 int fps;
110 char* title;
111 GLfloat distance;
112 int isinit;
113 cursor_t cursor;
115 #ifndef WIN32
116 Display *dpy;
117 int screen;
118 Window win;
119 GLXWindow glxwin;
120 GLXContext ctx;
121 GLXFBConfig fb_cfg;
122 XSetWindowAttributes attr;
123 int dblbuff;
124 XF86VidModeModeInfo deskMode;
125 XF86VidModeModeInfo **modes;
126 XVisualInfo *vi;
127 int mode;
128 int mode_count;
129 XIM im;
130 XIC ic;
131 XIMStyle style;
132 #else
133 HDC hDC;
134 HGLRC hRC;
135 HWND hWnd;
136 HINSTANCE hInstance;
137 #endif
138 } wm_t;
139 #endif
141 #ifndef _HAVE_CAMERA_TYPE
142 #define _HAVE_CAMERA_TYPE
143 typedef struct camera_s {
144 float x;
145 float y;
146 float z;
147 float yaw;
148 float pitch;
149 } camera_t;
150 #endif
152 #ifndef _HAVE_SYM_TYPE
153 #define _HAVE_SYM_TYPE
154 typedef struct sym_s {
155 uint8_t type;
156 uint32_t sym;
157 uint32_t ch;
158 } sym_t;
159 #endif
161 #ifndef _HAVE_BIND_TYPE
162 #define _HAVE_BIND_TYPE
163 typedef struct bind_s {
164 char str[256];
165 sym_t sym;
166 uint8_t mods;
167 } bind_t;
168 #endif
170 #ifndef _HAVE_EVENT_TYPE
171 #define _HAVE_EVENT_TYPE
172 typedef struct event_s {
173 uint8_t type;
174 sym_t sym;
175 int x;
176 int y;
177 int rx;
178 int ry;
179 } event_t;
180 #endif
182 #ifndef _HAVE_ACTION_TYPE
183 #define _HAVE_ACTION_TYPE
184 typedef struct action_s {
185 struct action_s *prev;
186 struct action_s *next;
187 char name[256];
188 uint32_t h;
189 bind_t bind;
190 void (*func)(event_t *e);
191 void (*r_func)(event_t *e);
192 void (*a_func)(event_t *e);
193 char* com;
194 } action_t;
195 #endif
197 /* defined in wm.c */
198 extern wm_t wm_data;
200 /* defined in wm.c */
201 void wm_capture(char* file);
203 /* defined in wm_x11.c and wm_w32.c */
204 int wm_init(void);
205 void wm_exit(void);
206 int wm_create(void);
207 int wm_resize(void);
208 int wm_update(void);
209 void wm_destroy(void);
210 void wm_toggle_fullscreen(int fs);
211 void wm_cursor(char* file, int width, int height, int offset_x, int offset_y);
212 void wm_grab(void);
213 void wm_ungrab(void);
214 void wm_title(char* title);
216 /* defined in camera.c */
217 void camera_view_matrix(matrix_t *mat);
218 camera_t *camera_get(void);
219 void camera_set_pos(v3_t *p);
220 void camera_set_yaw(GLfloat yaw);
221 void camera_set_pitch(GLfloat pitch);
223 /* defined in kmap.c */
224 int kmap_strtobind(bind_t *bind, char* str);
225 int kmap_bindtostr(char* str, int size, bind_t *bind);
226 int kmap_equal(bind_t *b1, bind_t *b2);
227 int kmap_triggers(bind_t *eb, bind_t *ab);
229 /* defined in events.c */
230 int events_init(void);
231 void events_exit(void);
232 void events_set_mousegrab(uint8_t g);
233 uint8_t events_get_mousegrab(void);
234 void events_get_mouse(int p[2]);
235 void event_set_bind(char* name, char* value);
236 void event_set_func(char* name, void (*func)(event_t *e));
237 void event_set_r_func(char* name, void (*func)(event_t *e));
238 void event_set_a_func(char* name, void (*func)(event_t *e));
239 void event_set_com(char* name, char* com);
240 void event_remove(char* name);
241 void event_create(char* name, char* bind, char* com, void (*func)(event_t *e), void (*r_func)(event_t *e), void (*a_func)(event_t *e));
242 void events_trigger_active(void);
243 void events_handle(event_t *e);
245 /* defined in wm_x11.c and wm_w32.c */
246 void events_main(void);
248 #endif
250 /* defined in wm.c and dummy.c */
251 int wm_width_setter(char* value);
252 int wm_height_setter(char* value);
253 int wm_cap_setter(char* value);
254 int wm_fullscreen_setter(char* value);
256 /* defined in opengl.c and dummy.c */
257 int opengl_anisotropic_setter(char* value);
258 int opengl_bilinear_setter(char* value);
259 int opengl_trilinear_setter(char* value);
260 int opengl_mipmap_setter(char* value);
261 int opengl_particles_setter(char* value);
262 int opengl_particles_max_setter(char* value);
263 int opengl_bumpmap_setter(char* value);
265 /* defined in events.c and dummy.c */
266 void events_save(file_t *f);
267 int event_bind(array_t *a);
269 /* defined in ui.c and dummy.c */
270 int ui_scale_setter(char* value);
271 int ui_autoscale_setter(char* value);
273 #endif