Exemplo n.º 1
0
Arquivo: video.c Projeto: miton/taisei
void video_init(void) {
	SDL_Rect **modes;
	int i;
	
	memset(&video, 0, sizeof(video));
	
	// First register all resolutions that are available in fullscreen
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
	if(!modes) {
		warnx("video_init(): no available fullscreen modes");
		tconfig.intval[FULLSCREEN] = False;
	} else if(modes == (SDL_Rect**)-1) {
		warnx("video_init(): you seem to have a weird video driver");
	} else {
		for(i = 0; modes[i]; ++i) {
			video_add_mode(modes[i]->w, modes[i]->h);
		}
	}
	
	// Then, add some common 4:3 modes for the windowed mode if they are not there yet.
	// This is required for some multihead setups.
	for(i = 0; common_modes[i].width; ++i)
		video_add_mode(common_modes[i].width, common_modes[i].height);
	
	// sort it, mainly for the options menu
	qsort(video.modes, video.mcount, sizeof(VideoMode), video_compare_modes);
	
	video_setmode(tconfig.intval[VID_WIDTH], tconfig.intval[VID_HEIGHT], tconfig.intval[FULLSCREEN]);
	SDL_WM_SetCaption("TaiseiProject", NULL); 
}
Exemplo n.º 2
0
/* Called by x11input whenever a window's size changes, 
 * even in response to x11_window_set_size 
 */
void x11_acknowledge_resize(hwrbitmap window, int w, int h) {
  if (XB(window)->sb.w != w || XB(window)->sb.h != h) {
    XB(window)->sb.w = w;
    XB(window)->sb.h = h;
    
    /* Resize the backbuffer if we're using one */
    if (XB(window)->frontbuffer) {
      /* FIXME: can't deal with errors here! */
      x11_internal_bitmap_free(XB(window));
      XB(window)->sb.w = XB(window)->frontbuffer->sb.w = w;
      XB(window)->sb.h = XB(window)->frontbuffer->sb.h = h;
      x11_new_bitmap_pixmap(XB(window));
    }
    
    /* Resize the divtree */
    if (XB(window)->dt) {
      XB(window)->dt->head->r.w = w;
      XB(window)->dt->head->r.h = h;
      XB(window)->dt->head->calc.w = w;
      XB(window)->dt->head->calc.h = h;
      XB(window)->dt->head->flags |= DIVNODE_NEED_RECALC | DIVNODE_FORCE_CHILD_RECALC | DIVNODE_NEED_REBUILD;
      XB(window)->dt->flags |= DIVTREE_NEED_RECALC | DIVTREE_ALL_REDRAW;
    }

    /* If this is monolithic mode, we need to set the video mode to match */
    if ((!VID(is_rootless)()) && (vid->xres!=w || vid->yres!=h))
      video_setmode(w, h, vid->bpp, PG_FM_ON,0); 
  }
}
Exemplo n.º 3
0
/* Let the driver register itself, and initialize things */
g_error load_vidlib(g_error (*regfunc)(struct vidlib *v),
		    s16 xres,s16 yres,s16 bpp,u32 flags) {
  g_error e;

  /* Unload */
  if (vid) 
    VID(close) ();

  /* Clear it */
  vid = &vidlib_static;
  vidwrap = vid;         /* No transforms */
  memset(vid,0,sizeof(struct vidlib));
  vid->close = &emulate_dos;
  vid->update = &def_update;
  vid->setmode = &def_setmode;
   
  /* Device registration */
  e = (*regfunc)(vid);
  if (iserror(e)) {
    vid = NULL;
    return e;
  }

  inlib_main = NULL;

  /* By default use a static vid->display */
  vid->display = (hwrbitmap) &static_display; 

  /* Load new driver */
  e = VID(init)();
  if (iserror(e)) {
    vid = NULL;
    return e;
  }

  /* Set the initial mode */
  return video_setmode(xres,yres,bpp,PG_FM_SET,flags);
}
Exemplo n.º 4
0
void destroy_options_menu(void *menu)
{
	MenuData *m = (MenuData*)menu;
	OptionBinding *binds = (OptionBinding*)m->context;
	int i;
	
	for(i = 0; i < m->ecount; ++i) {
		if(binds[i].type == BT_Resolution) {
			if(binds[i].selected != -1) {
#ifndef WIN32
				VideoMode *m = &(video.modes[binds[i].selected]);
				video_setmode(m->width, m->height, tconfig.intval[FULLSCREEN]);
#endif
				
				tconfig.intval[VID_WIDTH]  = video.intended.width;
				tconfig.intval[VID_HEIGHT] = video.intended.height;
			}
			break;
		}
	}
	
	config_save(CONFIG_FILE);
	free_bindings(menu);
}
Exemplo n.º 5
0
void sdlinput_poll(void) {
  SDL_Event evt;
  int ox=-1,oy=-1;
  int newx, newy;
  static int btnstate = 0;
  int pgx, pgy;

  while (SDL_PollEvent(&evt)) {

#ifdef CONFIG_SDLSKIN
    /* check hotspot map */
    {
      int i;
      for (i=0;i<sdlinput_mapsize;i++)
	if (evt.button.x >= sdlinput_map[i].x1 &&
	    evt.button.y >= sdlinput_map[i].y1 &&
	    evt.button.x <= sdlinput_map[i].x2 &&
	    evt.button.y <= sdlinput_map[i].y2) {
	  
	  /* FIXME: This doesn't handle modifiers or anything
	   * fancy like that yet. It would also be nice to have some specialized
	   * button codes, like power or backlight.
	   */
	  if (evt.type == SDL_MOUSEBUTTONDOWN)
	    infilter_send_key(PG_TRIGGER_KEY,sdlinput_map[i].key,0);
	  
	  return;
	}
    }
#endif
    
    if (!sdlinput_nomouse) {
      
      /* Process changes in the mouse position. We were using SDL's mouse events for this, but
       * that tends to create mouse 'lag' due to the buffering of events. This method should
       * always use the most up-to-date mouse data even if we're behind in the queue of events.
       */
      
      SDL_GetMouseState(&newx, &newy);
      
      /* Calculate the transformed coordinates we'll give picogui */
      pgx = (-sdlfb_display_x + newx) / sdlfb_scale;
      pgy = (-sdlfb_display_y + newy) / sdlfb_scale;
      
      /* The mouse might have moved... the input filters will sort it out */
      if (sdlinput_upmove || btnstate)
	infilter_send_pointing(PG_TRIGGER_MOVE, pgx, pgy, btnstate, sdlinput_cursor);
      
      switch (evt.type) {
	
      case SDL_MOUSEBUTTONDOWN:
	/* Scroll wheel events */
	if (evt.button.button == 4)
	  infilter_send_pointing(PG_TRIGGER_SCROLLWHEEL,0,-sdlinput_scroll_distance,0,sdlinput_cursor);
	else if (evt.button.button == 5)
	  infilter_send_pointing(PG_TRIGGER_SCROLLWHEEL,0,sdlinput_scroll_distance,0,sdlinput_cursor);
	else {
	  /* Normal button */
	  if (sdlinput_foldbuttons)
	    evt.button.button = evt.button.button!=0;

	  infilter_send_pointing(PG_TRIGGER_DOWN, pgx, pgy, 
				 btnstate |= 1<<(evt.button.button-1), sdlinput_cursor);
	}
	break;
	
      case SDL_MOUSEBUTTONUP:      
	/* Ignore up events for the scroll wheel if we get them */
	if (evt.button.button == 4 || evt.button.button == 5)
	  break;
	if (sdlinput_foldbuttons)
	  evt.button.button = evt.button.button!=0;
	infilter_send_pointing(PG_TRIGGER_UP, pgx, pgy,
			       btnstate &= ~(1<<(evt.button.button-1)), sdlinput_cursor);
	break;
      }
    }
    
    switch (evt.type) {
    case SDL_KEYDOWN:
      if (!sdlinput_nokeyboard) {
	if (evt.key.keysym.unicode)
	  infilter_send_key(PG_TRIGGER_CHAR,evt.key.keysym.unicode,evt.key.keysym.mod);
	infilter_send_key(PG_TRIGGER_KEYDOWN,evt.key.keysym.sym,evt.key.keysym.mod);
      }
      break;
      
    case SDL_KEYUP:
      if (!sdlinput_nokeyboard)
	infilter_send_key(PG_TRIGGER_KEYUP,evt.key.keysym.sym,evt.key.keysym.mod);
      break;
      
    case SDL_QUIT:
      pgserver_mainloop_stop();
      break;
      
    case SDL_VIDEORESIZE:
      if (evt.resize.w != vid->xres || evt.resize.h != vid->yres) {
	video_setmode(evt.resize.w,evt.resize.h,vid->bpp,PG_FM_ON,0);
	update(NULL,1);
      }
      break;
    }
  }
}
Exemplo n.º 6
0
Arquivo: video.c Projeto: miton/taisei
void video_toggle_fullscreen(void) {
	video_setmode(video.intended.width, video.intended.height, !video_isfullscreen());
}