void IN_Frame( void ) { qboolean loading; if ( in_xbox360ControllerAvailable->integer ) { IN_Xbox360ControllerMove(); } else { IN_JoyMove(); } IN_ProcessEvents( dropInput ); dropInput = qfalse; // If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading loading = ( cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE ); if ( ( !cls.glconfig.isFullscreen || SDL_VERSION_ATLEAST( 2, 0, 0 ) ) && ( cls.keyCatchers & KEYCATCH_CONSOLE || ( CL_UIOwnsMouse() && !in_uigrab->integer ) ) ) { // Console is down, or UI is up, in windowed mode IN_DeactivateMouse( qfalse ); } else if ( ( !cls.glconfig.isFullscreen || SDL_VERSION_ATLEAST( 2, 0, 0 ) ) && loading ) { // Loading in windowed mode IN_DeactivateMouse( qtrue ); } else if ( !( SDL_GetWindowFlags( window ) & SDL_WINDOW_INPUT_FOCUS ) ) { // Window not got focus IN_DeactivateMouse( qfalse ); } else if ( com_minimized->integer ) { // Minimized IN_DeactivateMouse( qtrue ); } else { IN_ActivateMouse(); } }
/* * SDL.glResetAttributes() * * Returns: * true on success; false if the function is not available */ static int l_glResetAttributes(lua_State *L) { if (!SDL_VERSION_ATLEAST(2, 0, 2)) return commonPush(L, "b", 0); SDL_GL_ResetAttributes(); return commonPush(L, "b", 1); }
/** * Update vo_screenwidth and vo_screenheight. * * This function only works with SDL since 1.2.10 and * even then only when called before the first * SDL_SetVideoMode. * Once there's a better way available implement an * update_xinerama_info function. */ static void get_screensize(void) { const SDL_VideoInfo *vi; // TODO: better to use a check that gets the runtime version instead? if (!SDL_VERSION_ATLEAST(1, 2, 10)) return; // Keep user-provided settings if (vo_screenwidth > 0 || vo_screenheight > 0) return; vi = SDL_GetVideoInfo(); vo_screenwidth = vi->current_w; vo_screenheight = vi->current_h; }
int drawgx_init(sdl_draw_info *callbacks) { // fill in the callbacks callbacks->exit = drawgx_exit; callbacks->attach = drawgx_attach; if (SDL_VERSION_ATLEAST(1,3,0)) mame_printf_verbose("Using SDL multi-window soft driver (SDL 1.3+)\n"); else mame_printf_verbose("Using SDL single-window soft driver (SDL 1.2)\n"); return 0; }
/* =============== IN_DeactivateMouse =============== */ void IN_DeactivateMouse( qboolean showCursor ) { if ( !SDL_WasInit( SDL_INIT_VIDEO ) ) { return; } // Show the cursor when the mouse is disabled, // but not when fullscreen if ( !cls.glconfig.isFullscreen || SDL_VERSION_ATLEAST( 2, 0, 0 ) ) { SDL_ShowCursor( showCursor ); } if ( !mouseAvailable ) { return; } if ( mouseActive ) { IN_GobbleMotionEvents(); SDL_SetWindowGrab( window, SDL_FALSE ); SDL_SetRelativeMouseMode( SDL_FALSE ); if ( uivm ) { // TODO (after no compatibility needed with alpha 9): remove argument int mousepos = VM_Call( uivm, UI_MOUSE_POSITION, 0 ); int cursorx = mousepos & 0xFFFF; int cursory = mousepos >> 16; SDL_WarpMouseInWindow( window, cursorx, cursory ); } mouseActive = qfalse; } }
static void check_osd_inputs(running_machine &machine) { sdl_window_info *window = sdlinput_get_focus_window(machine); // check for toggling fullscreen mode if (ui_input_pressed(machine, IPT_OSD_1)) sdlwindow_toggle_full_screen(machine, window); if (ui_input_pressed(machine, IPT_OSD_2)) { //FIXME: on a per window basis video_config.fullstretch = !video_config.fullstretch; ui_popup_time(1, "Uneven stretch %s", video_config.fullstretch? "enabled":"disabled"); } if (ui_input_pressed(machine, IPT_OSD_4)) { //FIXME: on a per window basis video_config.keepaspect = !video_config.keepaspect; ui_popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled"); } if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0)) { //FIXME: on a per window basis if (ui_input_pressed(machine, IPT_OSD_5)) { video_config.filter = !video_config.filter; ui_popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled"); } } if (ui_input_pressed(machine, IPT_OSD_6)) sdlwindow_modify_prescale(machine, window, -1); if (ui_input_pressed(machine, IPT_OSD_7)) sdlwindow_modify_prescale(machine, window, 1); }
void osd_init(running_machine *machine) { const char *stemp; // Some driver options - must be before audio init! stemp = options_get_string(machine->options(), SDLOPTION_AUDIODRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp); osd_setenv(SDLENV_AUDIODRIVER, stemp, 1); } stemp = options_get_string(machine->options(), SDLOPTION_VIDEODRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp); osd_setenv(SDLENV_VIDEODRIVER, stemp, 1); } if (SDL_VERSION_ATLEAST(1,3,0)) { stemp = options_get_string(machine->options(), SDLOPTION_RENDERDRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp); osd_setenv(SDLENV_RENDERDRIVER, stemp, 1); } } /* Set the SDL environment variable for drivers wanting to load the * lib at startup. */ /* FIXME: move lib loading code from drawogl.c here */ stemp = options_get_string(machine->options(), SDLOPTION_GL_LIB); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1); mame_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp); } /* get number of processors */ stemp = options_get_string(machine->options(), SDLOPTION_NUMPROCESSORS); sdl_num_processors = 0; if (strcmp(stemp, "auto") != 0) { sdl_num_processors = atoi(stemp); if (sdl_num_processors < 1) { mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); sdl_num_processors = 0; } } /* Initialize SDL */ if (!SDLMAME_INIT_IN_WORKER_THREAD) { #if (SDL_VERSION_ATLEAST(1,3,0)) if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #else if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #endif mame_printf_error("Could not initialize SDL %s\n", SDL_GetError()); exit(-1); } osd_sdl_info(); } // must be before sdlvideo_init! machine->add_notifier(MACHINE_NOTIFY_EXIT, osd_exit); defines_verbose(); if (!SDLMAME_HAS_DEBUGGER) if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) { mame_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); osd_exit(*machine); exit(-1); } if (sdlvideo_init(machine)) { osd_exit(*machine); mame_printf_error("sdlvideo_init: Initialization failed!\n\n\n"); fflush(stderr); fflush(stdout); exit(-1); } sdlinput_init(machine); sdlaudio_init(machine); sdloutput_init(machine); if (options_get_bool(machine->options(), SDLOPTION_OSLOG)) machine->add_logerror_callback(output_oslog); #if (SDL_VERSION_ATLEAST(1,3,0)) SDL_EventState(SDL_TEXTINPUT, SDL_TRUE); #else SDL_EnableUNICODE(SDL_TRUE); #endif }
VALUE sdl2r_macro_version_atleast(VALUE klass, VALUE vx, VALUE vy, VALUE vz) { return SDL_VERSION_ATLEAST(NUM2INT(vx), NUM2INT(vy), NUM2INT(vz)) ? Qtrue : Qfalse; }
static void extract_video_config(running_machine &machine) { const char *stemp; sdl_options &options = downcast<sdl_options &>(machine.options()); video_config.perftest = options.video_fps(); // global options: extract the data video_config.windowed = options.window(); video_config.keepaspect = options.keep_aspect(); video_config.numscreens = options.numscreens(); video_config.fullstretch = options.uneven_stretch(); #ifdef SDLMAME_X11 video_config.restrictonemonitor = !options.use_all_heads(); #endif if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) video_config.windowed = TRUE; // default to working video please video_config.novideo = 0; // d3d options: extract the data stemp = options.video(); if (strcmp(stemp, SDLOPTVAL_SOFT) == 0) video_config.mode = VIDEO_MODE_SOFT; else if (strcmp(stemp, SDLOPTVAL_NONE) == 0) { video_config.mode = VIDEO_MODE_SOFT; video_config.novideo = 1; if (options.seconds_to_run() == 0) mame_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n"); } else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0)) video_config.mode = VIDEO_MODE_OPENGL; else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL16) == 0)) { video_config.mode = VIDEO_MODE_OPENGL; video_config.prefer16bpp_tex = 1; } else if (SDL_VERSION_ATLEAST(1,3,0) && (strcmp(stemp, SDLOPTVAL_SDL13) == 0)) { video_config.mode = VIDEO_MODE_SDL13; video_config.prefer16bpp_tex = 1; } else { mame_printf_warning("Invalid video value %s; reverting to software\n", stemp); video_config.mode = VIDEO_MODE_SOFT; } video_config.switchres = options.switch_res(); video_config.centerh = options.centerh(); video_config.centerv = options.centerv(); video_config.waitvsync = options.wait_vsync(); video_config.syncrefresh = options.sync_refresh(); if (!video_config.waitvsync && video_config.syncrefresh) { mame_printf_warning("-syncrefresh specified without -waitsync. Reverting to -nosyncrefresh\n"); video_config.syncrefresh = 0; } if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0)) { video_config.filter = options.filter(); } if (USE_OPENGL) { video_config.prescale = options.prescale(); if (video_config.prescale < 1 || video_config.prescale > 3) { mame_printf_warning("Invalid prescale option, reverting to '1'\n"); video_config.prescale = 1; } // default to working video please video_config.prefer16bpp_tex = 0; 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, SDLOPTVAL_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, SDLOPTVAL_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; } } video_config.glsl_vid_attributes = options.glsl_vid_attr(); { // Disable feature: glsl_vid_attributes, as long we have the gamma calculation // disabled within the direct shaders .. -> too slow. // IMHO the gamma setting should be done global anyways, and for the whole system, // not just MAME .. float gamma = options.gamma(); if (gamma != 1.0 && video_config.glsl_vid_attributes && video_config.glsl) { video_config.glsl_vid_attributes = FALSE; mame_printf_warning("OpenGL: GLSL - disable handling of brightness and contrast, gamma is set to %f\n", gamma); } } } 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; } video_config.glsl_vid_attributes = 0; } } // misc options: sanity check values // global options: sanity check values #if (!SDL_VERSION_ATLEAST(1,3,0)) if (video_config.numscreens < 1 || video_config.numscreens > 1) //MAX_VIDEO_WINDOWS) { mame_printf_warning("Invalid numscreens value %d; reverting to 1\n", video_config.numscreens); video_config.numscreens = 1; } #else if (video_config.numscreens < 1 || video_config.numscreens > MAX_VIDEO_WINDOWS) { mame_printf_warning("Invalid numscreens value %d; reverting to 1\n", video_config.numscreens); video_config.numscreens = 1; } #endif // yuv settings ... stemp = options.scale_mode(); video_config.scale_mode = drawsdl_scale_mode(stemp); if (video_config.scale_mode < 0) { mame_printf_warning("Invalid yuvmode value %s; reverting to none\n", stemp); video_config.scale_mode = VIDEO_SCALE_MODE_NONE; } if ( (video_config.mode != VIDEO_MODE_SOFT) && (video_config.scale_mode != VIDEO_SCALE_MODE_NONE) ) { mame_printf_warning("scalemode is only for -video soft, overriding\n"); video_config.scale_mode = VIDEO_SCALE_MODE_NONE; } }
void sdl_osd_interface::init(running_machine &machine) { // call our parent osd_interface::init(machine); sdl_options &options = downcast<sdl_options &>(machine.options()); const char *stemp; // determine if we are benchmarking, and adjust options appropriately int bench = options.bench(); astring error_string; if (bench > 0) { options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(SDLOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string); assert(!error_string); } // Some driver options - must be before audio init! stemp = options.audio_driver(); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp); osd_setenv(SDLENV_AUDIODRIVER, stemp, 1); } stemp = options.video_driver(); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp); osd_setenv(SDLENV_VIDEODRIVER, stemp, 1); } if (SDL_VERSION_ATLEAST(1,3,0)) { stemp = options.render_driver(); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp); osd_setenv(SDLENV_RENDERDRIVER, stemp, 1); } } /* Set the SDL environment variable for drivers wanting to load the * lib at startup. */ #if USE_OPENGL /* FIXME: move lib loading code from drawogl.c here */ stemp = options.gl_lib(); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1); mame_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp); } #endif /* get number of processors */ stemp = options.numprocessors(); sdl_num_processors = 0; if (strcmp(stemp, "auto") != 0) { sdl_num_processors = atoi(stemp); if (sdl_num_processors < 1) { mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); sdl_num_processors = 0; } } /* Initialize SDL */ if (!SDLMAME_INIT_IN_WORKER_THREAD) { #if (SDL_VERSION_ATLEAST(1,3,0)) if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #else if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #endif mame_printf_error("Could not initialize SDL %s\n", SDL_GetError()); exit(-1); } osd_sdl_info(); } // must be before sdlvideo_init! machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_exit), &machine)); defines_verbose(); if (!SDLMAME_HAS_DEBUGGER) if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) { mame_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); osd_exit(machine); exit(-1); } if (sdlvideo_init(machine)) { osd_exit(machine); mame_printf_error("sdlvideo_init: Initialization failed!\n\n\n"); fflush(stderr); fflush(stdout); exit(-1); } sdlinput_init(machine); sdlaudio_init(machine); sdloutput_init(machine); #ifdef SDLMAME_NETWORK sdlnetdev_init(machine); #endif if (options.oslog()) machine.add_logerror_callback(output_oslog); /* now setup watchdog */ int watchdog_timeout = options.watchdog(); int str = options.seconds_to_run(); /* only enable watchdog if seconds_to_run is enabled *and* relatively short (time taken from ui.c) */ if ((watchdog_timeout != 0) && (str > 0) && (str < 60*5 )) { m_watchdog = auto_alloc(machine, watchdog); m_watchdog->setTimeout(watchdog_timeout); } #if (SDL_VERSION_ATLEAST(1,3,0)) SDL_EventState(SDL_TEXTINPUT, SDL_TRUE); #else SDL_EnableUNICODE(SDL_TRUE); #endif } #ifdef SDLMAME_UNIX #define POINT_SIZE 144.0 #ifdef SDLMAME_MACOSX #define EXTRA_HEIGHT 1.0 #define EXTRA_WIDTH 1.15 //------------------------------------------------- // font_open - attempt to "open" a handle to the // font with the given name //------------------------------------------------- osd_font sdl_osd_interface::font_open(const char *_name, int &height) { CFStringRef font_name = NULL; CTFontRef ct_font = NULL; CTFontDescriptorRef font_descriptor; CGAffineTransform affine_transform = CGAffineTransformIdentity; astring name(_name); if (name == "default") { name = "LucidaGrande"; } /* handle bdf fonts in the core */ if (name.len() > 4) if (name.toupper().substr(name.len()-4,4) == ".BDF" ) return NULL; font_name = CFStringCreateWithCString( NULL, _name, kCFStringEncodingUTF8 ); if( font_name != NULL ) { font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, POINT_SIZE ); if( font_descriptor != NULL ) { ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform ); CFRelease( font_descriptor ); } } CFRelease( font_name ); if (!ct_font) { printf("WARNING: Couldn't find/open font %s, using MAME default\n", name.cstr()); return NULL; } CFStringRef real_name = CTFontCopyPostScriptName( ct_font ); char real_name_c_string[255]; CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 ); mame_printf_verbose("Matching font: %s\n", real_name_c_string); CFRelease( real_name ); CGFloat line_height = 0.0; line_height += CTFontGetAscent(ct_font); line_height += CTFontGetDescent(ct_font); line_height += CTFontGetLeading(ct_font); height = ceilf(line_height * EXTRA_HEIGHT); return (osd_font)ct_font; }