Пример #1
0
static void event_handler(int line)
{
    // printf("%d\n", line);
    if (line >= 0) {
        input_handler_loop(line);
        return;
    }
    //static int busy = 0;
    //static int idle = 0;
    //static int64_t last_time = 0;
    g_fs_uae_frame = g_fs_uae_frame + 1;

#if 0
    if (g_fs_uae_frame != amiga_get_vsync_counter()) {
        printf("g_fs_uae_frame %d amiga_get_vsync_count %d\n", g_fs_uae_frame, amiga_get_vsync_counter());
    }
#endif
    //printf("event_handler frame=%d\n", frame);

    fs_uae_record_frame(g_fs_uae_frame);

    /*
    int64_t t = fs_emu_monotonic_time();
    if (last_time > 0) {
        int dt = (t - last_time) / 1000;
        printf("%d\n", dt);
    }
    */

    //fs_emu_lua_run_handler("on_fs_uae_frame_start");

    fs_emu_wait_for_frame(g_fs_uae_frame);
    if (g_fs_uae_frame == 1) {
        // we configure input ports after first frame are confirmed,
        // because otherwise configure events would get lost if initially
        // connected to the server (for net play game), but aborted connection
        // before game started
        fs_uae_reconfigure_input_ports_amiga();
    }

    if (fs_emu_is_quitting()) {
        if (fs_emu_is_paused()) {
            fs_emu_pause(0);
        }
        static int quit_called = 0;
        if (quit_called == 0) {
            fs_log("calling amiga_quit\n");
            amiga_quit();
            quit_called = 1;
        }
        //return;
    }
    while (fs_emu_is_paused()) {
        /*
        if (!event_handler_loop()) {
            break;
        }
        */
        pause_throttle();
        if (fs_emu_is_quitting()) {
            break;
        }
    }

    //last_time = fs_emu_monotonic_time();

}
Пример #2
0
static int pause_function(fs_emu_menu_item *item, void **data) {
    fs_emu_log("pause_function\n");
    //return FS_EMU_MENU_RESULT_CLOSE;
    fs_emu_pause(!fs_emu_is_paused());
    return FS_EMU_MENU_RESULT_UPDATE;
}
Пример #3
0
void fs_emu_handle_libfsemu_action(int action, int state)
{
    if (g_fs_log_input)
        fs_log("fs_emu_handle_libfsemu_action %d %d\n", action, state);

    switch (action) {
    case FS_EMU_ACTION_FULL_KEYBOARD:
        if (state) {
            fs_emu_set_full_keyboard_emulation(
                !fs_emu_full_keyboard_emulation(), true);
        }
        break;
    case FS_EMU_ACTION_FULLSCREEN:
        if (state)
            fs_emu_toggle_fullscreen();
        break;
    case FS_EMU_ACTION_GRAB_INPUT:
        if (state) {
            if (g_fs_emu_grab_input_on_mod_release) {
                /* We had grapped the input, but is holding the modifier
                 * key. So we just don't ungrab on release. */
                g_fs_emu_grab_input_on_mod_release = false;
                fs_emu_show_cursor_msec(FS_EMU_MOUSE_DEFAULT_DURATION);
            } else {
                fs_emu_set_input_grab(!fs_emu_input_grab());
            }
        }
        break;
    case FS_EMU_ACTION_MENU_ALT:
        if (state)
            fs_emu_menu_toggle();
        break;
    case FS_EMU_ACTION_PAUSE:
        if (state)
            fs_emu_pause(!fs_emu_is_paused());
        break;
    case FS_EMU_ACTION_QUIT:
        if (state)
            fs_emu_quit();
        break;
    case FS_EMU_ACTION_SCREENSHOT:
        if (state)
            g_fs_emu_screenshot = 1;
        break;
    case FS_EMU_ACTION_SPECIAL:
        if (state)
            special_function();
        break;
    case FS_EMU_ACTION_SWITCH_WINDOW:
        if (state)
            switch_window();
        break;
    case FS_EMU_ACTION_TAUNT:
        if (state)
            taunt();
        break;
    case FS_EMU_ACTION_VOLUME_DOWN:
        if (state)
            fs_emu_volume_control(-2);
        break;
    case FS_EMU_ACTION_VOLUME_MUTE:
        if (state)
            fs_emu_volume_control(-1);
        break;
    case FS_EMU_ACTION_VOLUME_UP:
        if (state)
            fs_emu_volume_control(-3);
        break;
    case FS_EMU_ACTION_WARP:
        if (state) {
            /* FIXME: UAE-specific hot key hack for warp function,
             * should be moved out of libfsemu. */
            fs_emu_queue_input_event(0x00010000 | 275);
        }
        break;
    case FS_EMU_ACTION_ZOOM:
        if (state) {
            fs_emu_toggle_zoom(0);
        }
        break;
    case FS_EMU_ACTION_ZOOM_BORDER:
        if (state) {
            fs_emu_toggle_zoom(1);
        }
        break;
    case FSE_ACTION_CYCLE_STRETCH_MODE:
        if (state) {
            fse_cycle_stretch_mode();
        }
        break;
    }
}
Пример #4
0
static void update_main_menu(fs_emu_menu *menu) {
    fs_emu_log("update_main_menu\n");
    fs_emu_menu_item *item = menu->items[PAUSE_ITEM_INDEX];
    if (fs_emu_is_paused()) {
        fs_emu_menu_item_set_title(item, _("Resume"));
    }
    else {
        fs_emu_menu_item_set_title(item, _("Pause"));
    }
    update_input_item(menu->items[INPUT_ITEM_INDEX], 1);
    update_input_item(menu->items[INPUT_ITEM_INDEX + 1], 0);
    int media_item_first_index = MEDIA_ITEM_INDEX;

    int drive, type;
    for (int i = 0; i < 4; i++) {
        item = menu->items[media_item_first_index + i];
        get_drive_for_index(i, &type, &drive);
        //printf("index %d => %d %d\n", i, type, drive);
        if (type == 0) { // floppy
            if (amiga_floppy_get_drive_type(
                        drive) == AMIGA_FLOPPY_DRIVE_NONE) {
                fs_emu_menu_item_set_title(item, _("Disabled"));
                fs_emu_menu_item_set_enabled(item, 0);
            }
            else {
                const char *path = amiga_floppy_get_file(drive);
                fs_emu_log("floppy in %d: %s\n", drive, path);
                if (path == NULL || *path == 0) {
                    /// TRANSLATORS: Empty or nothing
                    char *title = g_strdup_printf(_("DF%d: Empty"), drive);
                    fs_emu_menu_item_set_title(item, title);
                    free(title);
                }
                else {
                    char *label = get_floppy_label(path);
                    fs_emu_menu_item_set_title(item, label);
                    free(label);
                }
                fs_emu_menu_item_set_enabled(item, 1);
            }
        }
        else if (type == 1) { // CD
            const char *path = amiga_cdrom_get_file(drive);
            fs_emu_log("CD in %d: %s\n", drive, path);
            if (path == NULL || *path == 0) {
                /// TRANSLATORS: Empty or nothing
                char *title = g_strdup_printf(_("CD%d: Empty"), drive);
                fs_emu_menu_item_set_title(item, title);
                free(title);
            }
            else {
                // FIXME: not really that useful for CDs
                char *label = get_floppy_label(path);
                fs_emu_menu_item_set_title(item, label);
                free(label);
            }
            fs_emu_menu_item_set_enabled(item, 1);
        }
        else {
            fs_emu_menu_item_set_title(item, _("Disabled"));
            fs_emu_menu_item_set_enabled(item, 0);
        }
    }
}