Exemple #1
0
/* Note: this is not the first ui function to be called.
 *       Display modes are registered prior to this 
 *       function being called.
 *       In fact, all display modes must be registered
 *       before this function is called. */
task_t *ui_task_create(u8 start_mode)
{
#if 0
    /* These modes are not enabled by default */
    set_mode_disable_bit_cb(MODE_OILPRES);
    set_mode_disable_bit_cb(MODE_EGT_INSTANT);
    set_mode_disable_bit_cb(MODE_EGT_PEAK);
#endif
    
    if (start_mode == MODE_MODE_SELECT)
    {
        current.mnum = MODE_MODE_SELECT;
        display_modes[MODE_MODE_SELECT].displayfunc = mode_select_display_func;
        ui_in_config_flag = 1;
        do_config_word(0);
    }
    else
    {
        load_configuration_words();
        if (start_mode == MODE_ATMOSPHERIC)
        {
            /* Do not validate if we are starting up in atmospheric mode.
             * Even if it is disabled it should be displayed after measurement. */
            current.mnum = start_mode;
        }
        else
        {
            current.mnum = validate_mode(start_mode);
        }
    }

    ui_display_callback(NULL);

    return setup_task(&ui_taskinfo, TASK_ID_UI, ui_task, ui_mailbox_buf, sizeof(ui_mailbox_buf));
}
Exemple #2
0
void switch_to_mode(ui_mode_t mode)
{
    ui_mode_t last_mode = load_persist_data(PDATA_LAST_MODE);
    if (last_mode != current.mnum)
    {
        /* we "jumped" to this mode from e.g. the atmospheric
         * measurement.  Return to the previous mode. */
        mode = last_mode;
    }
    
    current.mnum = validate_mode(mode);

    current.mode_just_changed = 1;
}    
void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
    __GLXcontext *gc = __glXGetCurrentContext();
    const __GLXattribute * state = 
       (const __GLXattribute *)(gc->client_state_private);
    struct array_state_vector * arrays = state->array_state;
    

    if ( validate_mode(gc, mode) && validate_count(gc, count) ) {
	if ( ! arrays->array_info_cache_valid ) {
	    fill_array_info_cache( arrays );
	}

	arrays->DrawArrays(mode, first, count);
    }
}
void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
		    const GLvoid *indices)
{
    __GLXcontext *gc = __glXGetCurrentContext();
    const __GLXattribute * state = 
       (const __GLXattribute *)(gc->client_state_private);
    struct array_state_vector * arrays = state->array_state;


    if ( validate_mode(gc, mode) && validate_count(gc, count)
	 && validate_type(gc, type) ) {
	if ( ! arrays->array_info_cache_valid ) {
	    fill_array_info_cache( arrays );
	}

	arrays->DrawElements(mode, count, type, indices);
    }
}
void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count,
		       GLsizei primcount)
{
    __GLXcontext *gc = __glXGetCurrentContext();
    const __GLXattribute * state = 
       (const __GLXattribute *)(gc->client_state_private);
    struct array_state_vector * arrays = state->array_state;
    GLsizei  i;


    if ( validate_mode(gc, mode) ) {
	if ( ! arrays->array_info_cache_valid ) {
	    fill_array_info_cache( arrays );
	}

	for ( i = 0 ; i < primcount ; i++ ) {
	    if ( validate_count( gc, count[i] ) ) {
		arrays->DrawArrays(mode, first[i], count[i]);
	    }
	}
    }
}
Exemple #6
0
static int parse_fbmode_cfg(char *cfgfile)
{
#define CHECK_IN_MODE_DEF\
    if (!in_mode_def) {\
        mp_msg(MSGT_VO, MSGL_V, "'needs 'mode' first");\
        goto err_out_print_linenum;\
    }
    fb_mode_t *mode = NULL;
    char *endptr;    // strtoul()...
    int in_mode_def = 0;
    int tmp, i;

    /* If called more than once, reuse parsed data */
    if (nr_modes)
        return nr_modes;

    mp_msg(MSGT_VO, MSGL_V, "Reading %s: ", cfgfile);

    if ((fp = fopen(cfgfile, "r")) == NULL) {
        mp_msg(MSGT_VO, MSGL_V, "can't open '%s': %s\n", cfgfile, strerror(errno));
        return -1;
    }

    if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
        mp_msg(MSGT_VO, MSGL_V, "can't get memory for 'line': %s\n", strerror(errno));
        return -2;
    }

    /*
     * check if the cfgfile starts with 'mode'
     */
    while ((tmp = get_token(1)) == RET_EOL)
        /* NOTHING */;
    if (tmp == RET_EOF)
        goto out;
    if (!strcmp(token[0], "mode"))
        goto loop_enter;
    goto err_out_parse_error;

    while ((tmp = get_token(1)) != RET_EOF) {
        if (tmp == RET_EOL)
            continue;
        if (!strcmp(token[0], "mode")) {
            if (in_mode_def) {
                mp_msg(MSGT_VO, MSGL_V, "'endmode' required");
                goto err_out_print_linenum;
            }
            if (!validate_mode(mode))
                goto err_out_not_valid;
        loop_enter:
            if (!(fb_modes =
                  realloc(fb_modes, sizeof(fb_mode_t) * (nr_modes + 1)))) {
                mp_msg(MSGT_VO, MSGL_V, "can't realloc 'fb_modes' (nr_modes = %d):"
                       " %s\n", nr_modes, strerror(errno));
                goto err_out;
            }
            mode = fb_modes + nr_modes;
            ++nr_modes;
            memset(mode, 0, sizeof(fb_mode_t));

            if (get_token(1) < 0)
                goto err_out_parse_error;
            for (i = 0; i < nr_modes - 1; i++) {
                if (!strcmp(token[0], fb_modes[i].name)) {
                    mp_msg(MSGT_VO, MSGL_V, "mode name '%s' isn't unique", token[0]);
                    goto err_out_print_linenum;
                }
            }
            if (!(mode->name = strdup(token[0]))) {
                mp_msg(MSGT_VO, MSGL_V, "can't strdup -> 'name': %s\n", strerror(errno));
                goto err_out;
            }
            in_mode_def = 1;
        } else if (!strcmp(token[0], "geometry")) {
            CHECK_IN_MODE_DEF;
            if (get_token(5) < 0)
                goto err_out_parse_error;
            mode->xres = strtoul(token[0], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->yres = strtoul(token[1], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->vxres = strtoul(token[2], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->vyres = strtoul(token[3], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->depth = strtoul(token[4], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "timings")) {
            CHECK_IN_MODE_DEF;
            if (get_token(7) < 0)
                goto err_out_parse_error;
            mode->pixclock = strtoul(token[0], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->left = strtoul(token[1], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->right = strtoul(token[2], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->upper = strtoul(token[3], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->lower = strtoul(token[4], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->hslen = strtoul(token[5], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
            mode->vslen = strtoul(token[6], &endptr, 0);
            if (*endptr)
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "endmode")) {
            CHECK_IN_MODE_DEF;
            in_mode_def = 0;
        } else if (!strcmp(token[0], "accel")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            /*
             * it's only used for text acceleration
             * so we just ignore it.
             */
        } else if (!strcmp(token[0], "hsync")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "low"))
                mode->sync &= ~FB_SYNC_HOR_HIGH_ACT;
            else if (!strcmp(token[0], "high"))
                mode->sync |= FB_SYNC_HOR_HIGH_ACT;
            else
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "vsync")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "low"))
                mode->sync &= ~FB_SYNC_VERT_HIGH_ACT;
            else if (!strcmp(token[0], "high"))
                mode->sync |= FB_SYNC_VERT_HIGH_ACT;
            else
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "csync")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "low"))
                mode->sync &= ~FB_SYNC_COMP_HIGH_ACT;
            else if (!strcmp(token[0], "high"))
                mode->sync |= FB_SYNC_COMP_HIGH_ACT;
            else
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "extsync")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "false"))
                mode->sync &= ~FB_SYNC_EXT;
            else if (!strcmp(token[0], "true"))
                mode->sync |= FB_SYNC_EXT;
            else
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "laced")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "false"))
                mode->vmode = FB_VMODE_NONINTERLACED;
            else if (!strcmp(token[0], "true"))
                mode->vmode = FB_VMODE_INTERLACED;
            else
                goto err_out_parse_error;
        } else if (!strcmp(token[0], "double")) {
            CHECK_IN_MODE_DEF;
            if (get_token(1) < 0)
                goto err_out_parse_error;
            if (!strcmp(token[0], "false"))
                ;
            else if (!strcmp(token[0], "true"))
                mode->vmode = FB_VMODE_DOUBLE;
            else
                goto err_out_parse_error;
        } else
            goto err_out_parse_error;
    }
    if (!validate_mode(mode))
        goto err_out_not_valid;
out:
    mp_msg(MSGT_VO, MSGL_V, "%d modes\n", nr_modes);
    free(line);
    fclose(fp);
    return nr_modes;
err_out_parse_error:
    mp_msg(MSGT_VO, MSGL_V, "parse error");
err_out_print_linenum:
    mp_msg(MSGT_VO, MSGL_V, " at line %d\n", line_num);
err_out:
    free(fb_modes);
    fb_modes = NULL;
    nr_modes = 0;
    free(line);
    free(fp);
    return -2;
err_out_not_valid:
    mp_msg(MSGT_VO, MSGL_V, "previous mode is not correct");
    goto err_out_print_linenum;
}
Exemple #7
0
static void init_fullscreen_dialog(HWND hwnd)
{
    HWND setting_hwnd;
    DirectDrawDeviceList *dev;
    ValueList *value;
    int xpos;
    int xstart;
    int xend;
    int distance;
    int size;
    double fval;
    TCHAR newval[64];
    video_canvas_t *canvas;
    uilib_localize_dialog_param *fullscreen_dialog_trans = (video_dx9_enabled()) ? fullscreen_dialog_dx9_trans : fullscreen_dialog_ddraw_trans;
    uilib_dialog_group *fullscreen_left_group = (video_dx9_enabled()) ? fullscreen_left_dx9_group : fullscreen_left_ddraw_group;
    uilib_dialog_group *fullscreen_right_group = (video_dx9_enabled()) ? fullscreen_right_dx9_group : fullscreen_right_ddraw_group;

    canvas = video_canvas_for_hwnd(GetParent(GetParent(hwnd)));
    fullscreen_getmodes();

    /* translate all dialog items */
    uilib_localize_dialog(hwnd, fullscreen_dialog_trans);

    /* adjust the size of the elements in the left group */
    uilib_adjust_group_width(hwnd, fullscreen_left_group);

    /* adjust the size of the elements in the rest group */
    uilib_adjust_group_width(hwnd, fullscreen_rest_group);

    /* get the max x of the right group */
    uilib_get_group_max_x(hwnd, fullscreen_right_group, &xend);

    /* get the min x of the right group */
    uilib_get_group_min_x(hwnd, fullscreen_right_group, &xstart);

    /* get the max x of the left group */
    uilib_get_group_max_x(hwnd, fullscreen_left_group, &xpos);

    if (xpos + 10 > xstart) {
        /* set the position of the right group */
        uilib_move_group(hwnd, fullscreen_right_group, xpos + 10);

        /* get the max x of the right group */
        uilib_get_group_max_x(hwnd, fullscreen_right_group, &xpos);

        /* calculate the distance between the old and new max x of the right group */
        distance = xpos - xend;

        /* get the size of the driver element */
        uilib_get_element_size(hwnd, IDC_FULLSCREEN_DEVICE, &size);

        /* set the size of the driver element */
        uilib_set_element_width(hwnd, IDC_FULLSCREEN_DEVICE, size + distance);
    }

    validate_mode(&fullscreen_device, &fullscreen_width, &fullscreen_height, &fullscreen_bitdepth, &fullscreen_refreshrate);
    setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_DEVICE);
    SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0);
    dev = devices;
    while (dev != NULL) {
        SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)dev->desc);
        dev = dev->next;
    }
    SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)fullscreen_device, 0);

    get_bitdepthlist(fullscreen_device);
    setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_BITDEPTH);
    SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0);
    value = bitdepthlist;
    while (value != NULL) {
        SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text);
        value = value->next;
    }
    SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(bitdepthlist, fullscreen_bitdepth), 0);

    get_resolutionlist(fullscreen_device, fullscreen_bitdepth);
    setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_RESOLUTION);
    SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0);
    value = resolutionlist;
    while (value != NULL) {
        SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text);
        value = value->next;
    }
    SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(resolutionlist, (fullscreen_width << 16) + fullscreen_height), 0);

    get_refreshratelist(fullscreen_device, fullscreen_bitdepth, fullscreen_width, fullscreen_height);
    setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_REFRESHRATE);
    SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0);
    value = refresh_rates;
    while (value != NULL) {
        SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text);
        value = value->next;
    }
    SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(refresh_rates, fullscreen_refreshrate), 0);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_VIDEO_VBLANK_SYNC), !video_dx9_enabled());
    CheckDlgButton(hwnd, IDC_TOGGLE_VIDEO_VBLANK_SYNC, vblank_sync ? BST_CHECKED : BST_UNCHECKED);
    CheckDlgButton(hwnd, IDC_TOGGLE_VIDEO_DX_PRIMARY, dx_primary ? BST_CHECKED : BST_UNCHECKED);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_KEEP_ASPECT_RATIO), video_dx9_enabled());
    if (video_dx9_enabled()) {
        CheckDlgButton(hwnd, IDC_TOGGLE_KEEP_ASPECT_RATIO, keep_aspect_ratio ? BST_CHECKED : BST_UNCHECKED);
        CheckDlgButton(hwnd, IDC_TOGGLE_TRUE_ASPECT_RATIO, true_aspect_ratio ? BST_CHECKED : BST_UNCHECKED);
        enable_aspect_ratio(hwnd);

        fval = ((double)aspect_ratio) / 1000.0;
        _stprintf(newval, TEXT("%.3f"), (float)fval);
        SetDlgItemText(hwnd, IDC_ASPECT_RATIO, newval);

        fval = canvas->geometry->pixel_aspect_ratio;
        _stprintf(newval, TEXT("%.3f"), (float)fval);
        SetDlgItemText(hwnd, IDC_GEOMETRY_ASPECT_RATIO, newval);
    }
}