wm.h 5.7 KB

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