global: basic kiosk mode support
This commit is contained in:
parent
f99ea11bd2
commit
ee2bb877bc
4 changed files with 37 additions and 2 deletions
11
src/global.c
11
src/global.c
|
@ -29,6 +29,12 @@ void init_global(CLIAction *cli) {
|
|||
log_warn("FPS limiter disabled. Gotta go fast! (frameskip = %i)", global.frameskip);
|
||||
}
|
||||
|
||||
global.is_kiosk_mode = env_get("TAISEI_KIOSK", false);
|
||||
|
||||
if(global.is_kiosk_mode) {
|
||||
SDL_SetHintWithPriority(SDL_HINT_NO_SIGNAL_HANDLERS, 0, SDL_HINT_DEFAULT);
|
||||
}
|
||||
|
||||
fpscounter_reset(&global.fps.logic);
|
||||
fpscounter_reset(&global.fps.render);
|
||||
fpscounter_reset(&global.fps.busy);
|
||||
|
@ -44,6 +50,11 @@ bool gamekeypressed(KeyIndex key) {
|
|||
static SDL_atomic_t quitting;
|
||||
|
||||
void taisei_quit(void) {
|
||||
if(global.is_kiosk_mode) {
|
||||
log_info("Running in kiosk mode; exit request ignored");
|
||||
return;
|
||||
}
|
||||
|
||||
if(SDL_AtomicCAS(&quitting, 0, 1)) {
|
||||
log_info("Exit requested");
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ typedef struct {
|
|||
uint is_practice_mode : 1;
|
||||
uint is_headless : 1;
|
||||
uint is_replay_verification : 1;
|
||||
uint is_kiosk_mode : 1;
|
||||
} Global;
|
||||
|
||||
extern Global global;
|
||||
|
|
|
@ -78,7 +78,7 @@ static bool main_menu_input_handler(SDL_Event *event, void *arg) {
|
|||
TaiseiEvent te = TAISEI_EVENT(event->type);
|
||||
static hrtime_t last_abort_time = 0;
|
||||
|
||||
if(te == TE_MENU_ABORT) {
|
||||
if(te == TE_MENU_ABORT && dynarray_get(&m->entries, m->entries.num_elements - 1).action) {
|
||||
play_sfx_ui("hit");
|
||||
m->cursor = m->entries.num_elements - 1;
|
||||
hrtime_t t = time_get();
|
||||
|
@ -125,7 +125,7 @@ MenuData* create_main_menu(void) {
|
|||
add_menu_entry(m, "Media Room", menu_action_enter_media, NULL);
|
||||
add_menu_entry(m, "Options", menu_action_enter_options, NULL);
|
||||
#ifndef __EMSCRIPTEN__
|
||||
add_menu_entry(m, "Quit", menu_action_close, NULL)->transition = TransFadeBlack;
|
||||
add_menu_entry(m, "Quit", global.is_kiosk_mode ? NULL : menu_action_close, NULL)->transition = TransFadeBlack;
|
||||
m->input = main_menu_input;
|
||||
#endif
|
||||
|
||||
|
|
23
src/video.c
23
src/video.c
|
@ -151,6 +151,24 @@ static VideoCapabilityState video_query_capability_webcanvas(VideoCapability cap
|
|||
}
|
||||
}
|
||||
|
||||
static VideoCapabilityState (*video_query_capability_kiosk_fallback)(VideoCapability cap);
|
||||
|
||||
static VideoCapabilityState video_query_capability_kiosk(VideoCapability cap) {
|
||||
switch(cap) {
|
||||
case VIDEO_CAP_FULLSCREEN:
|
||||
return VIDEO_ALWAYS_ENABLED;
|
||||
|
||||
case VIDEO_CAP_CHANGE_RESOLUTION:
|
||||
return VIDEO_NEVER_AVAILABLE;
|
||||
|
||||
case VIDEO_CAP_EXTERNAL_RESIZE:
|
||||
return VIDEO_NEVER_AVAILABLE;
|
||||
|
||||
default:
|
||||
return video_query_capability_kiosk_fallback(cap);
|
||||
}
|
||||
}
|
||||
|
||||
static void video_add_mode(VideoModeArray *mode_array, IntExtent mode_screen, IntExtent min_screen, IntExtent max_screen, const char *mode_type) {
|
||||
if(
|
||||
(mode_screen.w > max_screen.w && max_screen.w > 0) ||
|
||||
|
@ -844,6 +862,11 @@ void video_init(void) {
|
|||
video.backend = VIDEO_BACKEND_OTHER;
|
||||
}
|
||||
|
||||
if(global.is_kiosk_mode) {
|
||||
video_query_capability_kiosk_fallback = video_query_capability;
|
||||
video_query_capability = video_query_capability_kiosk;
|
||||
}
|
||||
|
||||
video.scaling_factor = 0;
|
||||
|
||||
r_init();
|
||||
|
|
Loading…
Reference in a new issue