Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const char* app_releases_address = "https://github.com/X65/emu/releases";
const char full_name[] = FULL_NAME;

struct arguments arguments = {
NULL, "-", false, false, false, false, false, false, NULL, NULL,
NULL, "-", false, false, false, false, false, false, false, NULL, NULL,
};
static char args_doc[] = "[ROM.xex]";

Expand All @@ -32,6 +32,7 @@ static struct argp_option options[] = {
OPTION_ARG_OPTIONAL, "Enable CRT post-process effect; optional VALUES is a comma-separated "
"list of up to 6 floats: scanlines,mask,curvature,vignette,blur,gamma "
"(empty positions keep current values)" },
{ "fullscreen", 'f', 0, 0, "Start in fullscreen mode" },
{ 0 }
};

Expand All @@ -53,6 +54,7 @@ static error_t parse_opt(int key, char* arg, struct argp_state* argp_state) {
args->crt_values = arg;
}
break;
case 'f': args->fullscreen = true; break;

case 'l': app_load_labels(arg, false); break;

Expand Down Expand Up @@ -92,4 +94,7 @@ void args_parse(int argc, char* argv[]) {
arguments.crt_values = val;
}
}
if (sargs_exists("fullscreen")) {
arguments.fullscreen = true;
}
}
2 changes: 1 addition & 1 deletion src/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern char program_version[];
extern struct arguments {
const char* rom;
const char* output_file;
bool silent, verbose, zeromem, joy, dap, crt;
bool silent, verbose, zeromem, joy, dap, crt, fullscreen;
const char* dap_port;
const char* crt_values;
} arguments;
Expand Down
8 changes: 8 additions & 0 deletions src/ui/ui_x65.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ static void _ui_x65_draw_menu(ui_x65_t* ui) {
}
ImGui::EndMenu();
}
#ifdef __EMSCRIPTEN__
const char* fullscreen_shortcut = "F11";
#else
const char* fullscreen_shortcut = "Alt+Enter";
#endif
if (ImGui::MenuItem(ICON_LC_FULLSCREEN " Fullscreen", fullscreen_shortcut, sapp_is_fullscreen())) {
sapp_toggle_fullscreen();
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu(ICON_LC_MICROCHIP " Hardware")) {
Expand Down
21 changes: 21 additions & 0 deletions src/x65.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,26 @@ void app_input(const sapp_event* event) {
if (event->type == SAPP_EVENTTYPE_FILES_DROPPED) {
fs_load_dropped_file_async(FS_CHANNEL_IMAGES);
}
// Fullscreen toggle hotkey. Intercepted before the UI so it fires even
// when ImGui has keyboard focus. On desktop ALT+Enter toggles and is
// swallowed (Enter+Alt is not a meaningful X65 input). On web F11 toggles
// and still reaches the emulated machine after toggling.
#ifdef __EMSCRIPTEN__
if (event->type == SAPP_EVENTTYPE_KEY_DOWN && event->key_code == SAPP_KEYCODE_F11) {
sapp_toggle_fullscreen();
}
#else
if (event->type == SAPP_EVENTTYPE_KEY_DOWN || event->type == SAPP_EVENTTYPE_KEY_UP) {
const bool is_alt_enter = event->key_code == SAPP_KEYCODE_ENTER
&& (event->modifiers & SAPP_MODIFIER_ALT);
if (is_alt_enter) {
if (event->type == SAPP_EVENTTYPE_KEY_DOWN) {
sapp_toggle_fullscreen();
}
return;
}
}
#endif
#ifdef CHIPS_USE_UI
if (ui_input(event)) {
// input was handled by UI
Expand Down Expand Up @@ -903,6 +923,7 @@ sapp_desc sokol_main(int argc, char* argv[]) {
.cleanup_cb = app_cleanup,
.width = window_width >= default_width ? window_width : default_width,
.height = window_height >= default_height ? window_height : default_height,
.fullscreen = arguments.fullscreen,
.window_title = app_name,
.icon.images = {
{
Expand Down
Loading