Example #1
0
static void extract_video_config(running_machine &machine)
{
	windows_options &options = downcast<windows_options &>(machine.options());
	const char *stemp;

	// global options: extract the data
	video_config.windowed      = options.window();
	video_config.prescale      = options.prescale();
	video_config.keepaspect    = options.keep_aspect();
	video_config.numscreens    = options.numscreens();

	// if we are in debug mode, never go full screen
	if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
		video_config.windowed = TRUE;

	// per-window options: extract the data
	const char *default_resolution = options.resolution();
	get_resolution(default_resolution, options.resolution(0), &video_config.window[0], TRUE);
	get_resolution(default_resolution, options.resolution(1), &video_config.window[1], TRUE);
	get_resolution(default_resolution, options.resolution(2), &video_config.window[2], TRUE);
	get_resolution(default_resolution, options.resolution(3), &video_config.window[3], TRUE);

	// video options: extract the data
	stemp = options.video();
	if (strcmp(stemp, "d3d") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "auto") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "ddraw") == 0)
		video_config.mode = VIDEO_MODE_DDRAW;
	else if (strcmp(stemp, "gdi") == 0)
		video_config.mode = VIDEO_MODE_GDI;
	else if (strcmp(stemp, "none") == 0)
	{
		video_config.mode = VIDEO_MODE_NONE;
		if (options.seconds_to_run() == 0)
			osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
	}
	else
	{
		osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
		video_config.mode = VIDEO_MODE_GDI;
	}
	video_config.waitvsync     = options.wait_vsync();
	video_config.syncrefresh   = options.sync_refresh();
	video_config.triplebuf     = options.triple_buffer();
	video_config.switchres     = options.switch_res();

	// ddraw options: extract the data
	video_config.hwstretch     = options.hwstretch();

	// d3d options: extract the data
	video_config.filter        = options.filter();
	if (video_config.prescale == 0)
		video_config.prescale = 1;
}
void Particle_Component::paint(QPainter *painter) {
	painter->setPen(Qt::red);

	for(int i=0; i<particles.num_particles; i++) {
		double x = particles.particles[i].x;
		double y = particles.particles[i].y;

		painter->drawPoint(QPointF(x/get_resolution(), get_heigth()-(y/get_resolution())));
	}
}
Example #3
0
bool sdl_osd_interface::video_init()
{
	int index;

	// extract data from the options
	extract_video_config();

	// set up monitors first
	sdl_monitor_info::init();

	// we need the beam width in a float, contrary to what the core does.
	video_config.beamwidth = options().beam_width_min();

	// initialize the window system so we can make windows
	if (!window_init())
		return false;

	// create the windows
	for (index = 0; index < video_config.numscreens; index++)
	{
		osd_window_config conf;
		memset(&conf, 0, sizeof(conf));
		get_resolution(options().resolution(), options().resolution(index), &conf, TRUE);

		// create window ...
		sdl_window_info *win = global_alloc(sdl_window_info(machine(), index, sdl_monitor_info::pick_monitor(options(), index), &conf));

		if (win->window_init())
			return false;
	}

	return true;
}
Example #4
0
int parse_command(int argc, char *argv[], option_t* opt)
{
	int i;

	for (i =1; i < argc; i++)
	{
		if (strcmp(argv[i], "-rel") == 0)
		{
			if (0 > get_resolution(atoi(argv[++i]), &opt->width, &opt->height))
				return -1;
		}
		else if (strcmp(argv[i], "-q") == 0)
		{
			opt->quality = get_quality(atoi(argv[++i]));
		}
		else if (strcmp(argv[i], "-w") == 0)
		{
			opt->white_balance = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-s") == 0)
		{
			opt->sharpness = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-iso") == 0)
		{
			opt->iso = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-ev") == 0)
		{
			opt->ev = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-c") == 0)
		{
			opt->color = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-timestamp") == 0)
		{
			opt->time_stamp = atoi(argv[++i]);
		}
		else if (strcmp(argv[i], "-o") == 0)
		{
			strcpy(opt->outpath, argv[++i]);
			printf("outpath = %s\n", opt->outpath);
		}
		else if (strcmp(argv[i], "-seq") == 0)
		{
			opt->sequence = atoi(argv[++i]);
			printf("sequence = %d\n", opt->sequence);
		}
	}
	return 0;
}
Example #5
0
int main(int argc, char **argv)
{
  program_name = argv[0];
  int i;
  int found = 0;
  int ok = 1;

#ifdef CAPTURE_MODE
  FILE *dump;
  fprintf(stderr, "%s: invoked with %d arguments ...\n", argv[0], argc);
  for (i = 0; i < argc; i++)
    fprintf(stderr, "%2d: %s\n", i, argv[i]);
  if ((dump = fopen(DEBUG_FILE("pre-html-data"), "wb")) != NULL) {
    while((i = fgetc(stdin)) >= 0)
      fputc(i, dump);
    fclose(dump);
  }
  exit(1);
#endif /* CAPTURE_MODE */
  device = "html";
  if (!font::load_desc())
    fatal("cannot find devhtml/DESC exiting");
  image_gen = font::image_generator;
  if (image_gen == NULL || (strcmp(image_gen, "") == 0))
    fatal("devhtml/DESC must set the image_generator field, exiting");
  postscriptRes = get_resolution();
  i = scanArguments(argc, argv);
  setupAntiAlias();
  checkImageDir();
  makeFileName();
  while (i < argc) {
    if (argv[i][0] != '-') {
      /* found source file */
      ok = do_file(argv[i]);
      if (!ok)
	return 0;
      found = 1;
    }
    i++;
  }

  if (!found)
    do_file("-");
  if (makeTempFiles())
    return 1;
  ok = inputFile.do_image(argc, argv);
  if (ok == 0) {
    generateImages(regionFileName);
    ok = inputFile.do_html(argc, argv);
  }
  return ok;
}
Example #6
0
static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
                        struct sub_bitmaps *res)
{
    struct sd_lavc_priv *priv = sd->priv;
    struct MPOpts *opts = sd->opts;

    struct sub *current = NULL;
    for (int n = 0; n < MAX_QUEUE; n++) {
        struct sub *sub = &priv->subs[n];
        if (!sub->valid)
            continue;
        if (pts == MP_NOPTS_VALUE ||
                ((sub->pts == MP_NOPTS_VALUE || pts >= sub->pts) &&
                 (sub->endpts == MP_NOPTS_VALUE || pts < sub->endpts)))
        {
            // Ignore "trailing" subtitles with unknown length after 1 minute.
            if (sub->endpts == MP_NOPTS_VALUE && pts >= sub->pts + 60)
                break;
            current = sub;
            break;
        }
    }
    if (!current)
        return;

    MP_TARRAY_GROW(priv, priv->outbitmaps, current->count);
    for (int n = 0; n < current->count; n++)
        priv->outbitmaps[n] = current->inbitmaps[n];

    res->parts = priv->outbitmaps;
    res->num_parts = current->count;
    if (priv->displayed_id != current->id)
        res->change_id++;
    priv->displayed_id = current->id;
    res->format = SUBBITMAP_INDEXED;

    double video_par = 0;
    if (priv->avctx->codec_id == AV_CODEC_ID_DVD_SUBTITLE &&
            opts->stretch_dvd_subs) {
        // For DVD subs, try to keep the subtitle PAR at display PAR.
        double par =
            (priv->video_params.d_w / (double)priv->video_params.d_h)
            / (priv->video_params.w   / (double)priv->video_params.h);
        if (isnormal(par))
            video_par = par;
    }
    if (priv->avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE)
        video_par = -1;
    int insize[2];
    get_resolution(sd, insize);
    osd_rescale_bitmaps(res, insize[0], insize[1], d, video_par);
}
Example #7
0
static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
{
    struct sd_lavc_priv *priv = sd->priv;
    switch (cmd) {
    case SD_CTRL_SET_VIDEO_PARAMS:
        priv->video_params = *(struct mp_image_params *)arg;
        return CONTROL_OK;
    case SD_CTRL_GET_RESOLUTION:
        get_resolution(sd, arg);
        return CONTROL_OK;
    default:
        return CONTROL_UNKNOWN;
    }
}
Example #8
0
uint8_t ds18b20_initialize()
{
  sensors.begin();
  n_sensors = sensors.getDeviceCount();
  sprintf(debug_str, "N%d", n_sensors);
  debug(debug_str);
  if(n_sensors > 4) n_sensors = 4; 
  uint8_t resolution = get_resolution(&sensors);
  if(resolution > 12 || resolution < 9) {
    debug("reset");
    sleep_mseconds(100);
    beenode_reset();
  }
  return n_sensors;
}
Example #9
0
/**
 * Returns a config with all partial resolutions of a theme expanded.
 *
 * @param theme                   The original object, whose objects need to be
 *                                expanded.
 *
 * @returns                       A new object with the expanded resolutions in
 *                                a theme. This object no longer contains
 *                                partial resolutions.
 */
static config expand_partialresolution(const config& theme)
{
	config result;

	// Add all the resolutions
	for(const auto& resolution : theme.child_range("resolution")) {
		result.add_child("resolution", resolution);
	}

	// Resolve all the partialresolutions
	for(const auto& part : theme.child_range("partialresolution")) {
		config resolution = get_resolution(result, part["inherits"]);
		resolution.merge_attributes(part);

		for(const auto& remove : part.child_range("remove")) {
			VALIDATE(!remove["id"].empty()
					, missing_mandatory_wml_key(
						  "[theme][partialresolution][remove]"
						, "id"));

			find_ref(remove["id"], resolution, true);
		}

		for(const auto& change : part.child_range("change")) {
			VALIDATE(!change["id"].empty()
					, missing_mandatory_wml_key(
						  "[theme][partialresolution][change]"
						, "id"));

			config& target = find_ref(change["id"], resolution, false);
			target.merge_attributes(change);
		}

		// cannot add [status] sub-elements, but who cares
		for(const auto& add : part.child_range("add")) {
			for(const auto& child : add.all_children_range()) {
				resolution.add_child(child.key, child.cfg);
			}
		}

		result.add_child("resolution", resolution);
	}

	return result;
}
Example #10
0
/** Setup a map generator from configuration.
 * This method reads the config values /plugins/openni/resolution and
 * /plugins/openni/fps and uses it to setup the map output of the given map
 * generator.
 * @param generator generator to setup
 * @param config config to read values from
 */
void
setup_map_generator(xn::MapGenerator &generator,
		    fawkes::Configuration *config)
{
  unsigned int width = 0, height = 0;
  get_resolution(config, width, height);
  unsigned int cfg_fps  = config->get_uint("/plugins/openni/fps");

  XnMapOutputMode output_mode;
  output_mode.nXRes = width;
  output_mode.nYRes = height;
  output_mode.nFPS  = cfg_fps;
  XnStatus st;
  if ((st = generator.SetMapOutputMode(output_mode)) != XN_STATUS_OK) {
    throw Exception("OpenNI: failed to set map output mode: %s",
		    xnGetStatusString(st));
  }
}
Example #11
0
int main(int argc, char **argv)
{
	UNREFERENCED_PARAMETER(argc);
	UNREFERENCED_PARAMETER(argv);

	srand((unsigned int)time(NULL));

	get_resolution();

	// We call the instance for init
	Graphics::GraphicsRenderer::Instance().init("Demo OpenGL", width, height, false);
	Audio::AudioRenderer::Instance();
	
	std::shared_ptr<Demo> demo(new Demo);
	demo->launch();

	return 0;
}
PangoFontDescription *
get_scaled_pango_font_description (KbdFontInfo *font, gfloat x_ratio, gfloat y_ratio)
{
	int dpi_xres, dpi_yres;
	gfloat ratio;

	get_resolution(&dpi_xres, &dpi_yres);

	x_ratio = x_ratio * DEFAULT_DPI / dpi_xres;
	y_ratio = y_ratio * DEFAULT_DPI / dpi_yres;

	ratio = (x_ratio < y_ratio) ? x_ratio : y_ratio;

	return get_pango_font_description_from_info(
				font->family,
				font->weight,
				font->size * ratio);
}
Example #13
0
static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
{
    struct sd_lavc_priv *priv = sd->priv;
    switch (cmd) {
    case SD_CTRL_SUB_STEP: {
        double *a = arg;
        double res = step_sub(sd, a[0], a[1]);
        if (res == MP_NOPTS_VALUE)
            return false;
        a[0] = res;
        return true;
    }
    case SD_CTRL_SET_VIDEO_PARAMS:
        priv->video_params = *(struct mp_image_params *)arg;
        return CONTROL_OK;
    case SD_CTRL_GET_RESOLUTION:
        get_resolution(sd, arg);
        return CONTROL_OK;
    default:
        return CONTROL_UNKNOWN;
    }
}
void Particle_Component::set_particle(carmen_localize_ackerman_particle_message particles) {
	this->particles = particles;

	double min_x, max_x, min_y, max_y;
	min_x = min_y = DBL_MAX;
	max_x = max_y = 0;

	for(int i=0; i<particles.num_particles; i++) {
		if(particles.particles[i].x/get_resolution() > max_x) {
			max_x = particles.particles[i].x/get_resolution();
		}

		if((get_heigth()-(particles.particles[i].y/get_resolution())) > max_y) {
			max_y = get_heigth()-(particles.particles[i].y/get_resolution());
		}

		if(particles.particles[i].x/get_resolution() < min_x) {
			min_x = particles.particles[i].x/get_resolution();
		}

		if((get_heigth()-(particles.particles[i].y/get_resolution())) < min_y) {
			min_y = get_heigth()-(particles.particles[i].y/get_resolution());
		}
	}

	prepareGeometryChange();

	brect.setX(min_x);
	brect.setY(min_y);
	brect.setWidth(max_x - min_x);
	brect.setHeight(max_y - min_y);

	update();


}
Example #15
0
static void
set_system_information(Enna_Buffer *b)
{
    if (!b)
        return;

    enna_buffer_append(b, "<c>");
    enna_buffer_append(b, _("System information"));
    enna_buffer_append(b, "</c><br><br>");
    get_distribution(b);
    get_uname(b);
    get_cpuinfos(b);
    get_loadavg(b);
    get_ram_usage(b);
#ifdef BUILD_LIBSVDRP
    get_vdr(b);
#endif /* BUILD_LIBSVDRP */
#ifdef BUILD_LIBXRANDR
    get_resolution(b);
#endif /* BUILD_LIBXRANDR */
    get_network(b);
    get_default_gw(b);
}
Example #16
0
void windows_osd_interface::extract_video_config()
{
	const char *stemp;

	// global options: extract the data
	video_config.windowed      = options().window();
	video_config.prescale      = options().prescale();
	video_config.filter        = options().filter();
	video_config.keepaspect    = options().keep_aspect();
	video_config.numscreens    = options().numscreens();
	video_config.fullstretch   = options().uneven_stretch();

	// if we are in debug mode, never go full screen
	if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
		video_config.windowed = TRUE;

	// per-window options: extract the data
	const char *default_resolution = options().resolution();
	get_resolution(default_resolution, options().resolution(0), &windows[0], TRUE);
	get_resolution(default_resolution, options().resolution(1), &windows[1], TRUE);
	get_resolution(default_resolution, options().resolution(2), &windows[2], TRUE);
	get_resolution(default_resolution, options().resolution(3), &windows[3], TRUE);

	// video options: extract the data
	stemp = options().video();
	if (strcmp(stemp, "d3d") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "auto") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "gdi") == 0)
		video_config.mode = VIDEO_MODE_GDI;
	else if (strcmp(stemp, "bgfx") == 0)
		video_config.mode = VIDEO_MODE_BGFX;
	else if (strcmp(stemp, "none") == 0)
	{
		video_config.mode = VIDEO_MODE_NONE;
		if (options().seconds_to_run() == 0)
			osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
	}
#if (USE_OPENGL)
	else if (strcmp(stemp, "opengl") == 0)
		video_config.mode = VIDEO_MODE_OPENGL;
#endif
	else
	{
		osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
		video_config.mode = VIDEO_MODE_GDI;
	}
	video_config.waitvsync     = options().wait_vsync();
	video_config.syncrefresh   = options().sync_refresh();
	video_config.triplebuf     = options().triple_buffer();
	video_config.switchres     = options().switch_res();

	if (video_config.prescale < 1 || video_config.prescale > 3)
	{
		osd_printf_warning("Invalid prescale option, reverting to '1'\n");
		video_config.prescale = 1;
	}
	#if (USE_OPENGL)
		// default to working video please
		video_config.forcepow2texture = options().gl_force_pow2_texture();
		video_config.allowtexturerect = !(options().gl_no_texture_rect());
		video_config.vbo         = options().gl_vbo();
		video_config.pbo         = options().gl_pbo();
		video_config.glsl        = options().gl_glsl();
		if ( video_config.glsl )
		{
			int i;

			video_config.glsl_filter = options().glsl_filter();

			video_config.glsl_shader_mamebm_num=0;

			for(i=0; i<GLSL_SHADER_MAX; i++)
			{
				stemp = options().shader_mame(i);
				if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
				{
					video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
					strcpy(video_config.glsl_shader_mamebm[i], stemp);
					video_config.glsl_shader_mamebm_num++;
				} else {
					video_config.glsl_shader_mamebm[i] = NULL;
				}
			}

			video_config.glsl_shader_scrn_num=0;

			for(i=0; i<GLSL_SHADER_MAX; i++)
			{
				stemp = options().shader_screen(i);
				if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
				{
					video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
					strcpy(video_config.glsl_shader_scrn[i], stemp);
					video_config.glsl_shader_scrn_num++;
				} else {
					video_config.glsl_shader_scrn[i] = NULL;
				}
			}
		} else {
			int i;
			video_config.glsl_filter = 0;
			video_config.glsl_shader_mamebm_num=0;
			for(i=0; i<GLSL_SHADER_MAX; i++)
			{
				video_config.glsl_shader_mamebm[i] = NULL;
			}
			video_config.glsl_shader_scrn_num=0;
			for(i=0; i<GLSL_SHADER_MAX; i++)
			{
				video_config.glsl_shader_scrn[i] = NULL;
			}
		}

	#endif /* USE_OPENGL */

}
Example #17
0
int ParseCMDLine(int argc, char *argv[], int paranoia)
{
	extern char *optarg;
	extern int optind, opterr, optopt;
	const char optstring[] = "-tf:pldnrh";
	const struct option longopts[] =
	{
		{"text-mode",               no_argument,       NULL, 't'},
		{"fb-device",               required_argument, NULL, 'f'},
		{"hide-password",           no_argument,       NULL, 'p'},
		{"hide-lastuser",           no_argument,       NULL, 'l'},
		{"disable-lastuser",        no_argument,       NULL, 'd'},
		{"no-shutdown-screen",      no_argument,       NULL, 'n'},
		{"resolution",              required_argument, NULL, 'r'},
		{"help",                    no_argument,       NULL, 'h'},
		{0, 0, 0, 0}
	};
  char *tty;
  int our_tty_number;

	program_name   = argv[0];
	if ((tty = strrchr(argv[0], '/'))) /* we are recycling tty as a temp var here */
		program_name = ++tty;

	if (!paranoia)
		opterr = 0;
	else
		if (argc < 2)	Error(1);

  tty= argv[1];
	if (paranoia)
	{
		if (!strcmp(tty, "-h") || !strcmp(tty, "--help"))
		{
			/*
			 * Print usage info...
			 * I put this here also as it would never have a chance
			 * of being parsed by getopt_long() because of the
			 * checks below (if passed as first argument)
			 */
			PrintUsage();
			exit(EXIT_SUCCESS);
		}
		if (strncmp(tty, "tty", 3)) Error(1);
	}
  our_tty_number= atoi(tty+3);
	if (paranoia)
		if ( (our_tty_number < 1) || (our_tty_number > 63) )
		{
			fprintf(stderr, "tty number must be > 0 and < 64\n");
			Error(1);
		}

	while (1)
	{
		int retval = getopt_long(argc, argv, optstring, longopts, NULL);

		if (retval == -1) break;
		switch (retval)
		{
			case 't': /* text mode login */
				text_mode_login = 1;
				break;
			case 'f': /* use this framebuffer device */
				if (paranoia) fb_device = strdup(optarg);
				break;
			case 'p': /* hide password */
				hide_password = 1;
				break;
			case 'l': /* hide lastuser */
				hide_last_user = 1;
				break;
			case 'd': /* disable lastuder */
				disable_last_user = 1;
				break;
			case 'n': /* no shutdown screen */
				no_shutdown_screen = 1;
				break;
			case 'r': /* use this framebuffer resolution */
				if (paranoia) resolution = get_resolution(optarg);
				break;
			case 'h': /* Print usage info... */
				PrintUsage();
				exit(EXIT_SUCCESS);
				break;
			case 1: /* not an option-like arg... we ignore it */
				break;
			default:
				if (paranoia)
				{
					Switch_TTY;
					fprintf(stderr, "%s: error in command line options: fall back to text mode.\n", program_name);
					Error(0);
				}
		}
	}
  
  return our_tty_number;
}
Example #18
0
static void extract_window_config(running_machine &machine, int index, sdl_window_config *conf)
{
	sdl_options &options = downcast<sdl_options &>(machine.options());
	// per-window options: extract the data
	get_resolution(options.resolution(), options.resolution(index), conf, TRUE);
}
Example #19
0
         short WPgrid_dialog(DBint grw_id)

/*      The grid dialogue.
 *
 *      In: grw_id = ID of WPGWIN that called us.
 *
 *      (C)2007-03-12 J.Kjellander
 *
 ******************************************************!*/

  {
   char     rubrik[81],close[81],help[81],edit[81],pos[81],
            res[81],show[81],hide[81],move[81],movett[81],
            edittt[81],showtt[81],hidett[81],bs1[81],bs2[81],
            closett[81],helptt[81];
   char    *typ[20];
   int      bh,wm_x1,wm_y1,wm_x2,wm_y2,butlen,bl1,bl2,actfunc_org;
   short    status,main_dx,main_dy,alt_x,alt_y,butlen1,butlen2,ly,lm;
   DBint    iwin_id,move_id,edit_id,show_id,hide_id,close_id,
            help_id,but_id;
   unsigned int dum1,dum2;
   DBVector newpos;
   WPWIN   *winptr;
   WPIWIN  *iwinpt;
   WPBUTT  *butptr;
   WPGWIN  *gwinpt;
   XEvent   event;
   XrmValue value;

/*
***Set actfunc during user action, see IG/include/futab.h.
*/
   actfunc_org = actfunc;
   actfunc = 103;
/*
***Is this the first time this function is called ?
***Initial window position.
*/
   if ( premiere )
     {
     iwin_x = iwin_y = 5;

     if ( XrmGetResource(xresDB,"varkon.grid.geometry",
                                "Varkon.Grid.Geometry",
                                 typ,&value) ) 
       XParseGeometry((char *)value.addr,&iwin_x,&iwin_y,&dum1,&dum2);

     premiere = FALSE;
     }
/*
***Get a C ptr to the graphical window that called us.
*/
   gwinpt = (WPGWIN *)wpwtab[grw_id].ptr;
/*
***During user interaction the dialogue window may get deleted
***and created again with new contents. This is where we start
***recreating a new instance.
*/
start:

/*
***Window title, position, resolution, move, edit, show, hide,
***close and help from the ini-file.
*/
   if ( !WPgrst("varkon.grid.title",rubrik) )           strcpy(rubrik,"Grid");
   if ( !WPgrst("varkon.grid.position.text",pos) )      strcpy(pos,"Position");
   if ( !WPgrst("varkon.grid.resolution.text",res) )    strcpy(res,"Resolution");
   if ( !WPgrst("varkon.grid.show.text",show) )         strcpy(show,"Show");
   if ( !WPgrst("varkon.grid.show.tooltip",showtt) )    strcpy(showtt,"");
   if ( !WPgrst("varkon.grid.hide.text",hide) )         strcpy(hide,"Hide");
   if ( !WPgrst("varkon.grid.hide.tooltip",hidett) )    strcpy(hidett,"");
   if ( !WPgrst("varkon.grid.move.text",move) )         strcpy(move,"Move");
   if ( !WPgrst("varkon.grid.move.tooltip",movett) )    strcpy(movett,"");
   if ( !WPgrst("varkon.grid.edit.text",edit) )         strcpy(edit,"Edit");
   if ( !WPgrst("varkon.grid.edit.tooltip",edittt) )    strcpy(edittt,"");
   if ( !WPgrst("varkon.input.close",close) )           strcpy(close,"Close");
   if ( !WPgrst("varkon.input.close.tooltip",closett) ) strcpy(closett,"");
   if ( !WPgrst("varkon.input.help",help) )             strcpy(help,"Help");
   if ( !WPgrst("varkon.input.help.tooltip",helptt) )   strcpy(helptt,"");
/*
***What is the 1.2*length of the longest text ?
***Don't include the title, it will fit anyhow.
*/
   butlen1 = 0;
   if ( WPstrl(pos)    > butlen1 ) butlen1 = WPstrl(pos);
   if ( WPstrl(res)    > butlen1 ) butlen1 = WPstrl(res);
   if ( WPstrl(move)   > butlen1 ) butlen1 = WPstrl(move);
   if ( WPstrl(edit)   > butlen1 ) butlen1 = WPstrl(edit);
   if ( WPstrl(show)   > butlen1 ) butlen1 = WPstrl(show);
   if ( WPstrl(hide)   > butlen1 ) butlen1 = WPstrl(hide);
   butlen1 *= 1.2;

   butlen2 = 0;
   if ( WPstrl(close)  > butlen2 ) butlen2 = WPstrl(close);
   if ( WPstrl(help)   > butlen2 ) butlen2 = WPstrl(help);
   butlen2 *= 1.8;
/*
***Calculate outside air (ly), button height (bh) and air between (lm).
*/
   ly = (short)(1.2*WPstrh());
   bh = (short)(1.8*WPstrh());
   lm = (short)(0.8*WPstrh());
/*
***Calculate the window size in X-direction.
*/
   main_dx = ly + butlen1 + ly + ly + butlen1 + ly;
/*
***Calculate the window size in Y-direction.
*/
   main_dy = ly + bh + lm + bh + 0 + bh + lm + bh + bh + bh + bh + bh + bh + ly;
/*
***Create the dialogue window as a WPIWIN.
*/
   WPwciw((short)iwin_x,(short)iwin_y,main_dx,main_dy,rubrik,&iwin_id);
/*
***Get a C-ptr to the WPIWIN.
*/
   winptr = WPwgwp((wpw_id)iwin_id);
   iwinpt = (WPIWIN *)winptr->ptr;
/*
***A vertical line.
*/
   alt_x  = ly + butlen1 + ly;
   alt_y  = ly + lm;
   WPcreate_3Dline(iwin_id,alt_x,alt_y,alt_x,alt_y + 4*bh + 2*ly - 2*lm);
/*
***Position and resolution texts.
*/
   alt_x  = ly;
   alt_y  = ly;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,pos,&but_id);

   alt_x  = ly + butlen1 + ly + ly;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,res,&but_id);
/*
***X, Y, DX and DY texts.
*/
   sprintf(bs1,"X = %g",gwinpt->grid_x);
   bl1 = WPstrl(bs1);
   sprintf(bs2,"Y = %g",gwinpt->grid_y);
   bl2 = WPstrl(bs2);
   if ( bl1 > bl2 ) butlen = bl1;
   else             butlen = bl2;

   alt_x  = (ly + butlen1 + ly - butlen)/2;
   alt_y  = ly + bh + lm;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,bl1,bh,bs1,&but_id);

   alt_y  = ly + bh + lm + bh;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,bl2,bh,bs2,&but_id);

   sprintf(bs1,"DX = %g",gwinpt->grid_dx);
   bl1 = WPstrl(bs1);
   sprintf(bs2,"DY = %g",gwinpt->grid_dy);
   bl2 = WPstrl(bs2);
   if ( bl1 > bl2 ) butlen = bl1;
   else             butlen = bl2;

   alt_x  = ly + ly + butlen1 + (ly + butlen1 + ly - butlen)/2;
   alt_y  = ly + bh + lm;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,bl1,bh,bs1,&but_id);

   alt_y  = ly + bh + lm + bh;
   WPcrlb((wpw_id)iwin_id,alt_x,alt_y,bl2,bh,bs2,&but_id);
/*
***Move and edit.
*/
   alt_x  = ly;
   alt_y += bh + lm;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,(short)2,
                           move,move,"",WP_BGND2,WP_FGND,&move_id);
   butptr = (WPBUTT *)iwinpt->wintab[move_id].ptr;
   strcpy(butptr->tt_str,movett);

   alt_x  = ly + butlen1 + ly + ly;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,(short)2,
                           edit,edit,"",WP_BGND2,WP_FGND,&edit_id);
   butptr = (WPBUTT *)iwinpt->wintab[edit_id].ptr;
   strcpy(butptr->tt_str,edittt);
/*
***Show and hide.
*/
   alt_x  = ly;
   alt_y  += bh + bh;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,(short)2,
                           show,show,"",WP_BGND2,WP_FGND,&show_id);
   butptr = (WPBUTT *)iwinpt->wintab[show_id].ptr;
   strcpy(butptr->tt_str,showtt);

   alt_x  = ly + butlen1 + ly + ly;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen1,bh,(short)2,
                           hide,hide,"",WP_BGND2,WP_FGND,&hide_id);
   butptr = (WPBUTT *)iwinpt->wintab[hide_id].ptr;
   strcpy(butptr->tt_str,hidett);
/*
***A horizontal line.
*/
   alt_x  = main_dx/8;
   alt_y  += bh + bh;
   WPcreate_3Dline(iwin_id,alt_x,alt_y,alt_x + 6*main_dx/8,alt_y);
/*
***Close and help.
*/
   alt_x  = ly;
   alt_y += bh;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen2,bh,(short)3,
                           close,close,"",WP_BGND2,WP_FGND,&close_id);
   butptr = (WPBUTT *)iwinpt->wintab[close_id].ptr;
   strcpy(butptr->tt_str,closett);

   alt_x  = main_dx - ly - butlen2;
   status = WPcrpb((wpw_id)iwin_id,alt_x,alt_y,butlen2,bh,(short)2,
                           help,help,"",WP_BGND2,WP_FGND,&help_id);
   butptr = (WPBUTT *)iwinpt->wintab[help_id].ptr;
   strcpy(butptr->tt_str,helptt);
/*
***Show the dialogue.
*/
   WPwshw(iwin_id);
   XRaiseWindow(xdisp,iwinpt->id.x_id);
/*
***Where did it actually get positioned ?
***This code copied from WPmsip().
*/
   XWindowEvent(xdisp,iwinpt->id.x_id,ExposureMask,&event);
   XPutBackEvent(xdisp,&event);
   WPgtwp(iwinpt->id.x_id,&wm_x1,&wm_y1);
/*
***Wait for action. SMBPOSM is not an issue in this situation.
*/
   status = 0;
loop:
   if ( WPwwtw(iwin_id,SLEVEL_V3_INP,&but_id) == SMBPOSM ) goto loop;
/*
***Move button.
*/
   if ( but_id == move_id )
     {
     WPaddmess_mcwin(IGgtts(44),WP_PROMPT);
     status = IGcpov(&newpos);
     WPerhg();    
     IGrsma();
     if ( status == 0 )
       {
       WPdelete_grid(grw_id);
       gwinpt->grid_x = newpos.x_gm;
       gwinpt->grid_y = newpos.y_gm;
       WPdraw_grid(grw_id);
       goto update;
       }
     else goto loop;
     }
/*
***Edit button.
*/
   else if ( but_id == edit_id )
     {
     status = get_resolution(gwinpt,&newpos.x_gm,&newpos.y_gm);
     if ( status == 0 )
       {
       WPdelete_grid(grw_id);
       gwinpt->grid_dx = newpos.x_gm;
       gwinpt->grid_dy = newpos.y_gm;
       WPdraw_grid(grw_id);
       goto update;
       }
     else goto loop;
     }
/*
***Show button.
*/
   else if ( but_id == show_id )
     {
     WPgrid_on(grw_id);
     WPdraw_grid(grw_id);
     goto loop;
     }
/*
**Hide button.
*/
   else if ( but_id == hide_id )
     {
     WPdelete_grid(grw_id);
     WPgrid_off(grw_id);
     goto loop;
     }
/*
***Close button.
*/
   else if ( but_id == close_id )
     {
     status = 0;
     goto exit;
     }
/*
***Help button.
*/
   else if ( but_id == help_id )
     {
     IGhelp();
     goto loop;
     }
/*
***Unknown event, should not happen.
*/
   else
     {
     WPbell();
     goto loop;
     }
/*
***A view was added or removed so we need to update the window.
***Before deleting it, update the variables for it's current position.
*/
update:
   WPgtwp(iwinpt->id.x_id,&wm_x2,&wm_y2);
   iwin_x = iwin_x + wm_x2 - wm_x1;
   iwin_y = iwin_y + wm_y2 - wm_y1;
   WPwdel(iwin_id);
   goto start;
/*
***Time to exit. Reset global actfunc. Remeber current position.
*/
exit:
   actfunc = actfunc_org;
   WPgtwp(iwinpt->id.x_id,&wm_x2,&wm_y2);
   iwin_x = iwin_x + wm_x2 - wm_x1;
   iwin_y = iwin_y + wm_y2 - wm_y1;
   WPwdel(iwin_id);

   return(status);
 }
Example #20
0
int main(int argc,char *argv[])
{
	void *handle;
	option_t opt;
	void* csi_attr;
	int restart = 0;
	
	RegisterSigint();
	
	memset(&opt, 0, sizeof(option_t));
	opt.ev = 6;
	opt.sharpness = 1;
	strcpy(opt.outpath, "./");
	if (0 > parse_command(argc, argv, &opt))
		return -1;
		
	dc_pipe_init();
	
//	opt.raw = 1;
start:
	g_bQuit = 0;
	restart = 0;
	gp_IPC_VStream_Open(IPC_COLOR_YUYV, 0, 0, ON2_JPG);

	csi_attr = gp_IPC_VDev_Open(NULL);
	
	gp_IPC_VDev_Set_Exposure(csi_attr, opt.ev);
	set_sharpness(csi_attr, opt.sharpness);
	set_awb(csi_attr, opt.white_balance);
	set_color(csi_attr, opt.color);
	set_iso(csi_attr,opt.iso);
	
	gp_IPC_Enable_Display(1, 0, IPC_SCALE_BILINEAR, (opt.width == 1920) ? 0:1);
	
	gp_IPC_Enable_TimeStamp(opt.time_stamp);
	
	dc_pipemsg_send(CMD_READY_KEY, 0, NULL);
	
	while(1)
	{
		unsigned int msgId;
		void* msgPara;
		unsigned int mode;
		
		if (g_bQuit)
			break;
		
		if(dc_pipemsg_receive(&msgId, &msgPara) > 0)
		{
			printf("msgId=%d\n", msgId);
			if (msgPara)
			{
				mode = *(unsigned int*)msgPara;
				printf("mode = %d\n", mode);
			}
			switch(msgId)
			{
				case CMD_DO_CAPTURE:
					if(opt.raw)
					{
						gp_IPC_VDev_Close(csi_attr);
						gp_IPC_VStream_Close();
						gp_IPC_VStream_Open(IPC_COLOR_RAW, 0, 0, ON2_JPG);
						csi_attr = gp_IPC_VDev_Open(NULL);
						snap_shot(opt.width, opt.height, opt.quality, opt.outpath, opt.sequence, 1);
						restart = 1;
						g_bQuit = 1;
						dc_response_cmd(msgId);
					}
					else
						snap_shot(opt.width, opt.height, opt.quality, opt.outpath, opt.sequence, 0);
				break;
				case CMD_SET_DC_RESOLUTION:
					get_resolution(mode, &opt.width, &opt.height);
					gp_IPC_Enable_Display(0,0,0,0);
					gp_IPC_Enable_Display(1, 2, IPC_SCALE_BILINEAR, (opt.width == 1920) ? 0:1);
				break;
				case CMD_SET_QUALITY:
					opt.quality = get_quality(mode);
				break;
				case CMD_SET_EXPOSURE:
					gp_IPC_VDev_Set_Exposure(csi_attr, mode);
				break;
				case CMD_SET_SHARPNESS:
					set_sharpness(csi_attr, mode);
				break;
				case CMD_SET_AWB:
					set_awb(csi_attr, mode);	
				break;
				case CMD_SET_COLOR:
					set_color(csi_attr, mode);
				break;
				case CMD_SET_ISO:
					set_iso(csi_attr, mode);
				break;
				case CMD_SET_DC_DATE_STAMP:
					opt.time_stamp = mode;
					gp_IPC_Enable_TimeStamp(opt.time_stamp);
				break;
				case CMD_SET_SEQUENCE:
					opt.sequence = mode ? 3:0;
				break;
				case CMD_SET_ZOOM:
					mode = mode ? mode + 10: 0;
					gp_IPC_Set_Zoom(mode);
				break;
				case CMD_SET_EXIT:
					g_bQuit = 1;
				break;
			}
			if (!g_bQuit)
				dc_response_cmd(msgId);
		}
	}
	printf("++++++++++dc exit++++++++++\n");
	gp_IPC_VDev_Close(csi_attr);
	gp_IPC_VStream_Close();
	
	if(restart)
		goto start;

	dc_response_cmd(CMD_SET_EXIT);
}
Example #21
0
static void extract_video_config(void)
{
	const char *stemp;

	// performance options: extract the data
	video_config.autoframeskip = options_get_bool("autoframeskip");
	video_config.frameskip     = options_get_int_range("frameskip", 0, FRAMESKIP_LEVELS);
	video_config.throttle      = options_get_bool("throttle");
	video_config.sleep         = options_get_bool("sleep");

	// misc options: extract the data
	video_config.framestorun   = options_get_int("frames_to_run");

	// global options: extract the data
	video_config.windowed      = options_get_bool("window");
	video_config.prescale      = options_get_int("prescale");
	video_config.keepaspect    = options_get_bool("keepaspect");
	video_config.numscreens    = options_get_int_range("numscreens", 1, MAX_WINDOWS);
#ifdef MAME_DEBUG
	// if we are in debug mode, never go full screen
	if (options.mame_debug)
		video_config.windowed = TRUE;
#endif
	stemp                      = options_get_string("effect");
	if (stemp != NULL && strcmp(stemp, "none") != 0)
		load_effect_overlay(stemp);

	// configure layers
	video_config.layerconfig = LAYER_CONFIG_DEFAULT;
	if (!options_get_bool("use_backdrops")) video_config.layerconfig &= ~LAYER_CONFIG_ENABLE_BACKDROP;
	if (!options_get_bool("use_overlays")) video_config.layerconfig &= ~LAYER_CONFIG_ENABLE_OVERLAY;
	if (!options_get_bool("use_bezels")) video_config.layerconfig &= ~LAYER_CONFIG_ENABLE_BEZEL;
	if (options_get_bool("artwork_crop")) video_config.layerconfig |= LAYER_CONFIG_ZOOM_TO_SCREEN;

	// per-window options: extract the data
	get_resolution("resolution0", &video_config.window[0], TRUE);
	get_resolution("resolution1", &video_config.window[1], TRUE);
	get_resolution("resolution2", &video_config.window[2], TRUE);
	get_resolution("resolution3", &video_config.window[3], TRUE);

	// video options: extract the data
	stemp = options_get_string("video");
	if (strcmp(stemp, "d3d") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "ddraw") == 0)
		video_config.mode = VIDEO_MODE_DDRAW;
	else if (strcmp(stemp, "gdi") == 0)
		video_config.mode = VIDEO_MODE_GDI;
	else if (strcmp(stemp, "none") == 0)
	{
		video_config.mode = VIDEO_MODE_NONE;
		if (video_config.framestorun == 0)
			fprintf(stderr, "Warning: -video none doesn't make much sense without -frames_to_run\n");
	}
	else
	{
		fprintf(stderr, "Invalid video value %s; reverting to gdi\n", stemp);
		video_config.mode = VIDEO_MODE_GDI;
	}
	video_config.waitvsync     = options_get_bool("waitvsync");
	video_config.syncrefresh   = options_get_bool("syncrefresh");
	video_config.triplebuf     = options_get_bool("triplebuffer");
	video_config.switchres     = options_get_bool("switchres");

	// ddraw options: extract the data
	video_config.hwstretch     = options_get_bool("hwstretch");

	// d3d options: extract the data
	video_config.filter        = options_get_bool("filter");
	if (video_config.prescale == 0)
		video_config.prescale = 1;

	// misc options: sanity check values

	// per-window options: sanity check values

	// d3d options: sanity check values
	options_get_int_range("d3dversion", 8, 9);

	options_get_float_range("full_screen_brightness", 0.1f, 2.0f);
	options_get_float_range("full_screen_contrast", 0.1f, 2.0f);
	options_get_float_range("full_screen_gamma", 0.1f, 3.0f);
}
Example #22
0
void Resolution::show(std::ostream &out) const {
  out << "Resolution " << get_resolution() << std::endl;
}
Example #23
0
static void extract_video_config(running_machine *machine)
{
	const char *stemp;

	// global options: extract the data
	video_config.windowed      = options_get_bool(&machine->options(), WINOPTION_WINDOW);
	video_config.prescale      = options_get_int(&machine->options(), WINOPTION_PRESCALE);
	video_config.keepaspect    = options_get_bool(&machine->options(), WINOPTION_KEEPASPECT);
	video_config.numscreens    = options_get_int(&machine->options(), WINOPTION_NUMSCREENS);

	// if we are in debug mode, never go full screen
	if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)
		video_config.windowed = TRUE;

	// per-window options: extract the data
	get_resolution(machine->options(), WINOPTION_RESOLUTION0, &video_config.window[0], TRUE);
	get_resolution(machine->options(), WINOPTION_RESOLUTION1, &video_config.window[1], TRUE);
	get_resolution(machine->options(), WINOPTION_RESOLUTION2, &video_config.window[2], TRUE);
	get_resolution(machine->options(), WINOPTION_RESOLUTION3, &video_config.window[3], TRUE);

	// video options: extract the data
	stemp = options_get_string(&machine->options(), WINOPTION_VIDEO);
	if (strcmp(stemp, "d3d") == 0)
		video_config.mode = VIDEO_MODE_D3D;
	else if (strcmp(stemp, "ddraw") == 0)
		video_config.mode = VIDEO_MODE_DDRAW;
	else if (strcmp(stemp, "gdi") == 0)
		video_config.mode = VIDEO_MODE_GDI;
	else if (strcmp(stemp, "none") == 0)
	{
		video_config.mode = VIDEO_MODE_NONE;
		if (options_get_int(&machine->options(), OPTION_SECONDS_TO_RUN) == 0)
			mame_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
	}
	else
	{
		mame_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
		video_config.mode = VIDEO_MODE_GDI;
	}
	video_config.waitvsync     = options_get_bool(&machine->options(), WINOPTION_WAITVSYNC);
	video_config.syncrefresh   = options_get_bool(&machine->options(), WINOPTION_SYNCREFRESH);
	video_config.triplebuf     = options_get_bool(&machine->options(), WINOPTION_TRIPLEBUFFER);
	video_config.switchres     = options_get_bool(&machine->options(), WINOPTION_SWITCHRES);

	// ddraw options: extract the data
	video_config.hwstretch     = options_get_bool(&machine->options(), WINOPTION_HWSTRETCH);

	// d3d options: extract the data
	video_config.filter        = options_get_bool(&machine->options(), WINOPTION_FILTER);
	if (video_config.prescale == 0)
		video_config.prescale = 1;

	// misc options: sanity check values

	// per-window options: sanity check values

	// d3d options: sanity check values
	options_get_int(&machine->options(), WINOPTION_D3DVERSION);

	options_get_float(&machine->options(), WINOPTION_FULLSCREENBRIGHTNESS);
	options_get_float(&machine->options(), WINOPTION_FULLLSCREENCONTRAST);
	options_get_float(&machine->options(), WINOPTION_FULLSCREENGAMMA);
}
Example #24
0
bool operator == (const H264VideoFormat& a, const H264VideoFormat& b) {
  return (a.type == b.type)
      && (get_resolution(a) == get_resolution(b));
}
Example #25
0
void RectViewport::recompute_cell_properties() {
    // compute the cell height and width
    cell_width = port.get_width()/((float)get_resolution()[0]);
    cell_height = port.get_height()/((float)get_resolution()[1]);

}