stop appending repeat keys to the input buffer
[retroray] / src / app.h
1 /*
2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023  John Tsiombikas <nuclear@mutantstargoat.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef APP_H_
19 #define APP_H_
20
21 #include "sizeint.h"
22 #include "logger.h"
23 #include "scene.h"
24
25 #define CFGFILE "retroray.cfg"
26
27 enum {
28         KEY_BACKSP = 8,
29         KEY_ESC = 27,
30         KEY_DEL = 127,
31
32         KEY_NUM_0 = 256, KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_4,
33         KEY_NUM_5, KEY_NUM_6, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9,
34         KEY_NUM_DOT, KEY_NUM_DIV, KEY_NUM_MUL, KEY_NUM_MINUS, KEY_NUM_PLUS, KEY_NUM_ENTER, KEY_NUM_EQUALS,
35         KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT,
36         KEY_INS, KEY_HOME, KEY_END, KEY_PGUP, KEY_PGDN,
37         KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
38         KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
39         KEY_F13, KEY_F14, KEY_F15,
40         KEY_NUMLK, KEY_CAPSLK, KEY_SCRLK,
41         KEY_RSHIFT, KEY_LSHIFT, KEY_RCTRL, KEY_LCTRL, KEY_RALT, KEY_LALT,
42         KEY_RMETA, KEY_LMETA, KEY_LSUPER, KEY_RSUPER, KEY_MODE, KEY_COMPOSE,
43         KEY_HELP, KEY_PRINT, KEY_SYSRQ, KEY_BREAK
44 };
45
46 #ifndef KEY_ANY
47 #define KEY_ANY         (-1)
48 #define KEY_ALT         (-2)
49 #define KEY_CTRL        (-3)
50 #define KEY_SHIFT       (-4)
51 #endif
52
53 enum {
54         KEY_MOD_SHIFT   = 1,
55         KEY_MOD_CTRL    = 4,
56         KEY_MOD_ALT     = 8
57 };
58
59
60 struct app_screen {
61         const char *name;
62
63         int (*init)(void);
64         void (*destroy)(void);
65         int (*start)(void);
66         void (*stop)(void);
67         void (*display)(void);
68         void (*reshape)(int, int);
69         void (*keyboard)(int, int);
70         void (*mouse)(int, int, int, int);
71         void (*motion)(int, int);
72         void (*sball_motion)(int, int, int);
73         void (*sball_rotate)(int, int, int);
74         void (*sball_button)(int, int);
75 };
76
77 extern int mouse_x, mouse_y, mouse_state[3];
78 extern unsigned int modkeys;
79 extern int win_width, win_height;
80 extern float win_aspect;
81 extern int fullscr;
82
83 extern long time_msec;
84 extern struct app_screen *cur_scr;
85 extern struct app_screen scr_model, scr_rend;
86
87 struct font;
88 extern struct font *uifont;
89
90 extern uint32_t *framebuf, *rendbuf;
91
92 extern struct scene *scn;
93
94
95 int app_init(void);
96 void app_shutdown(void);
97
98 void app_display(void);
99 void app_reshape(int x, int y);
100 void app_keyboard(int key, int press);
101 void app_mouse(int bn, int st, int x, int y);
102 void app_motion(int x, int y);
103 void app_sball_motion(int x, int y, int z);
104 void app_sball_rotate(int x, int y, int z);
105 void app_sball_button(int bn, int st);
106
107 void app_chscr(struct app_screen *scr);
108
109 /* defined in main.c */
110 void app_redisplay(int x, int y, int w, int h);
111 void app_swap_buffers(void);
112 void app_quit(void);
113 void app_resize(int x, int y);
114 void app_fullscreen(int fs);
115 void app_vsync(int vsync);
116 void app_rband(int x, int y, int w, int h);
117
118 /* defined in scr_mod.c for convenience */
119 void primray(cgm_ray *ray, int x, int y);
120
121 #endif  /* APP_H_ */