-
Notifications
You must be signed in to change notification settings - Fork 12
/
launcher.h
318 lines (293 loc) · 8.04 KB
/
launcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
// Color masking bit logic
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define RMASK 0xff000000
#define GMASK 0x00ff0000
#define BMASK 0x0000ff00
#define AMASK 0x000000ff
#else
#define RMASK 0x000000ff
#define GMASK 0x0000ff00
#define BMASK 0x00ff0000
#define AMASK 0xff000000
#endif
#define COLOR_MASKS RMASK, GMASK, BMASK, AMASK
// Launcher parameters
#define MIN_FPS_LIMIT 10
#define MIN_ICON_SIZE 32
#define MAX_ICON_SIZE 1024
#define MIN_RX_SIZE 0
#define MAX_RX_SIZE 100
#define PERCENT_MAX_CHARS 10
#define GAMEPAD_DEADZONE 10000
#define GAMEPAD_REPEAT_DELAY 500
#define GAMEPAD_REPEAT_INTERVAL 25
#define CLOCK_UPDATE_PERIOD 1000
#define SCROLL_INDICATOR_HEIGHT 0.11F
#define MAX_SCROLL_INDICATOR_OUTLINE 0.01F
#define SCREEN_MARGIN 0.05F
#define MAX_CLOCK_MARGIN 0.1F
#define MIN_VCENTER 0.25F
#define MAX_VCENTER 0.75F
#define MIN_SLIDESHOW_IMAGE_DURATION 5000
#define MAX_SLIDESHOW_IMAGE_DURATION 3600000
#define MAX_SLIDESHOW_TRANSITION_TIME 3000
#define MIN_SCREENSAVER_IDLE_TIME 3
#define MAX_SCREENSAVER_IDLE_TIME 900
#define SCREENSAVER_TRANSITION_TIME 1500
#define APPLICATION_WAIT_PERIOD 100
#define MIN_APPLICATION_TIMEOUT 3
#define MAX_APPLICATION_TIMEOUT 30
// Special commands
#define SCMD_SELECT ":select"
#define SCMD_SUBMENU ":submenu"
#define SCMD_FORK ":fork"
#define SCMD_EXIT ":exit"
#define SCMD_LEFT ":left"
#define SCMD_RIGHT ":right"
#define SCMD_HOME ":home"
#define SCMD_BACK ":back"
#define SCMD_QUIT ":quit"
#define SCMD_SHUTDOWN ":shutdown"
#define SCMD_RESTART ":restart"
#define SCMD_SLEEP ":sleep"
typedef enum {
MODE_SETTING_BACKGROUND,
MODE_SETTING_ON_LAUNCH,
MODE_SETTING_OVERSIZE,
MODE_SETTING_ALIGNMENT,
MODE_SETTING_TIME_FORMAT,
MODE_SETTING_DATE_FORMAT
} ModeSettingType;
typedef enum {
BACKGROUND_COLOR,
BACKGROUND_IMAGE,
BACKGROUND_SLIDESHOW,
BACKGROUND_TRANSPARENT
} ModeBackground;
typedef enum {
ON_LAUNCH_BLANK,
ON_LAUNCH_NONE,
ON_LAUNCH_QUIT
} ModeOnLaunch;
typedef enum {
OVERSIZE_TRUNCATE,
OVERSIZE_SHRINK,
OVERSIZE_NONE
} ModeOversize;
typedef enum {
ALIGNMENT_LEFT,
ALIGNMENT_RIGHT,
} Alignment;
typedef enum {
FORMAT_TIME_24HR,
FORMAT_TIME_12HR,
FORMAT_TIME_AUTO
} TimeFormat;
typedef enum {
FORMAT_DATE_BIG,
FORMAT_DATE_LITTLE,
FORMAT_DATE_AUTO
} DateFormat;
typedef enum {
TYPE_BUTTON,
TYPE_AXIS_POS,
TYPE_AXIS_NEG,
} ControlType;
typedef enum {
DIRECTION_LEFT,
DIRECTION_RIGHT,
} Direction;
// Program states
typedef struct {
bool application_launching;
bool application_running;
bool has_focus;
bool slideshow_transition;
bool slideshow_background_rendering;
bool slideshow_background_ready;
bool slideshow_paused;
bool screensaver_active;
bool screensaver_transition;
bool clock_rendering;
bool clock_ready;
} State;
// Timing information
typedef struct {
Uint32 main;
Uint32 application_launched;
Uint32 slideshow_load;
Uint32 last_input;
Uint32 clock_update;
Uint32 application_exited;
} Ticks;
// Linked list for menu entries
typedef struct entry {
char *title;
char *icon_path;
char *icon_selected_path;
char *cmd;
SDL_Texture *icon;
SDL_Texture *icon_selected;
SDL_Rect icon_rect;
SDL_Texture *title_texture;
SDL_Rect text_rect;
int title_offset;
struct entry *next;
struct entry *previous;
} Entry;
// Linked list for menus
typedef struct menu {
char *name;
unsigned int num_entries;
bool rendered;
unsigned int page;
unsigned int highlight_position;
Entry *first_entry;
Entry *root_entry;
Entry *last_selected_entry;
struct menu *next;
struct menu *back;
} Menu;
typedef struct gamepad {
SDL_GameController *controller;
int device_index;
int id;
struct gamepad *previous;
struct gamepad *next;
} Gamepad;
// Linked list of gamepad controls
typedef struct gamepad_control {
ControlType type;
int index;
Uint32 repeat;
const char *label;
char *cmd;
struct gamepad_control *next;
} GamepadControl;
// Linked list of hotkeys
typedef struct hotkey {
SDL_Keycode keycode;
char *cmd;
struct hotkey *next;
} Hotkey;
// Struct for the geometry parameters of the onscreen buttons
typedef struct {
int screen_width;
int screen_height;
int screen_margin;
int font_height;
int x_margin; // Distance between left edge of screen and x coordinate of root_entry icon
int y_margin; // Distance between top edge of screen and y coordinate of all entry icons
int x_advance; // Distance between icon x coordinate of adjacent entries
int num_buttons; // Number of buttons shown on the screen
} Geometry;
// Struct for highlight
typedef struct {
SDL_Texture *texture;
SDL_Rect rect;
} Highlight;
//Struct for scroll indicators
typedef struct {
SDL_Texture *texture;
SDL_Rect rect_right;
SDL_Rect rect_left;
} Scroll;
// Slideshow
typedef struct {
char **images;
int *order;
int i;
int num_images;
float transition_alpha;
float transition_change_rate;
SDL_Surface *transition_surface;
SDL_Texture *transition_texture;
} Slideshow;
// Screensaver
typedef struct {
float alpha;
float alpha_end_value;
float transition_change_rate;
SDL_Texture *texture;
} Screensaver;
// Configuration settings
typedef struct {
char *default_menu;
unsigned int max_buttons;
bool vsync;
int fps_limit;
Uint32 application_timeout;
ModeBackground background_mode; // Defines image or color background mode
SDL_Color background_color; // Background color
SDL_Color chroma_key_color;
char *background_image; // Path to background image
char *slideshow_directory;
bool background_overlay;
SDL_Color background_overlay_color;
char background_overlay_opacity[PERCENT_MAX_CHARS];
Uint16 icon_size;
int icon_spacing;
char icon_spacing_str[PERCENT_MAX_CHARS];
bool titles_enabled;
char *title_font_path; // Path to title TTF font file
unsigned int title_font_size;
SDL_Color title_font_color; // Color struct for title text
bool title_shadows;
SDL_Color title_shadow_color;
char title_opacity[PERCENT_MAX_CHARS];
ModeOversize title_oversize_mode;
int title_padding;
bool highlight;
SDL_Color highlight_fill_color;
SDL_Color highlight_outline_color;
int highlight_outline_size;
char highlight_fill_opacity[PERCENT_MAX_CHARS];
char highlight_outline_opacity[PERCENT_MAX_CHARS];
unsigned int highlight_rx;
int highlight_vpadding;
int highlight_hpadding;
char vcenter[PERCENT_MAX_CHARS];
bool scroll_indicators;
SDL_Color scroll_indicator_fill_color;
int scroll_indicator_outline_size;
SDL_Color scroll_indicator_outline_color;
char scroll_indicator_opacity[PERCENT_MAX_CHARS];
bool wrap_entries;
bool reset_on_back;
bool mouse_select;
bool inhibit_os_screensaver;
char *startup_cmd;
char *quit_cmd;
ModeOnLaunch on_launch;
bool screensaver_enabled;
Uint32 screensaver_idle_time;
char screensaver_intensity_str[PERCENT_MAX_CHARS];
bool screensaver_pause_slideshow;
bool gamepad_enabled;
int gamepad_device;
char *gamepad_mappings_file;
bool debug;
char *exe_path;
Menu *first_menu;
size_t num_menus;
bool clock_enabled;
bool clock_show_date;
Alignment clock_alignment;
char *clock_font_path;
char clock_margin_str[PERCENT_MAX_CHARS];
int clock_margin;
SDL_Color clock_font_color;
char clock_opacity[PERCENT_MAX_CHARS];
unsigned int clock_font_size;
bool clock_shadows;
SDL_Color clock_shadow_color;
TimeFormat clock_time_format;
DateFormat clock_date_format;
bool clock_include_weekday;
Uint32 slideshow_image_duration;
Uint32 slideshow_transition_time;
} Config;
void quit_slideshow(void);
void set_draw_color(void);
void quit(int status);
void print_version(FILE *stream);