int SDL_SYS_JoystickInit(void) { /* First see if the user specified one or more joysticks to use */ if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) { char *envcopy, *envpath, *delim; envcopy = SDL_strdup(SDL_getenv("SDL_JOYSTICK_DEVICE")); envpath = envcopy; while (envpath != NULL) { delim = SDL_strchr(envpath, ':'); if (delim != NULL) { *delim++ = '\0'; } MaybeAddDevice(envpath); envpath = delim; } SDL_free(envcopy); } #if SDL_USE_LIBUDEV return JoystickInitWithUdev(); #endif return JoystickInitWithoutUdev(); }
SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface *display) { SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; const char *yuv_hwaccel; SDL_Overlay *overlay; if ( (display->flags & SDL_OPENGL) == SDL_OPENGL ) { SDL_SetError("YUV overlays are not supported in OpenGL mode"); return NULL; } /* Display directly on video surface, if possible */ if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) { if ( (display == SDL_PublicSurface) && ((SDL_VideoSurface->format->BytesPerPixel == 2) || (SDL_VideoSurface->format->BytesPerPixel == 4)) ) { display = SDL_VideoSurface; } } overlay = NULL; yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL"); if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) { overlay = video->CreateYUVOverlay(this, w, h, format, display); } /* If hardware YUV overlay failed ... */ if ( overlay == NULL ) { overlay = SDL_CreateYUV_SW(this, w, h, format, display); } return overlay; }
static int Audio_Available(void) { pa_sample_spec paspec; pa_simple *connection; int available; available = 0; if ( LoadPulseLibrary() < 0 ) { return available; } /* Connect with a dummy format. */ paspec.format = PA_SAMPLE_U8; paspec.rate = 11025; paspec.channels = 1; connection = SDL_NAME(pa_simple_new)( SDL_getenv("PASERVER"), /* server */ "Test stream", /* application name */ PA_STREAM_PLAYBACK, /* playback mode */ SDL_getenv("PADEVICE"), /* device on the server */ "Simple DirectMedia Layer", /* stream description */ &paspec, /* sample format spec */ NULL, /* channel map */ NULL, /* buffering attributes */ NULL /* error code */ ); if ( connection != NULL ) { available = 1; SDL_NAME(pa_simple_free)(connection); } UnloadPulseLibrary(); return(available); }
static void post_main_loop(void) { /* We want to improve the transitioning from FS-UAE back to e.g. * FS-UAE Game Center - avoid blinking cursor - so we try to move it (to * the bottom right of the screen). This probably requires that the * cursor is not grabbed (SDL often keeps the cursor in the center of the * screen then). */ if (g_fs_emu_video_fullscreen) { if (SDL_getenv("FSGS_RETURN_CURSOR_TO") && SDL_getenv("FSGS_RETURN_CURSOR_TO")[0]) { int x = -1; int y = -1; sscanf(SDL_getenv("FSGS_RETURN_CURSOR_TO"), "%d,%d", &x, &y); if (x != -1 && y != -1) { #if 0 fs_log("trying to move mouse cursor to x=%d y=%d\n", x, y); #endif Uint8 data[] = "\0"; SDL_SetWindowGrab(g_fs_ml_window, SDL_FALSE); /* Setting invisible cursor so we won't see it when we * enable the cursor in order to move it. */ SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0); SDL_SetCursor(cursor); SDL_ShowCursor(SDL_ENABLE); SDL_WarpMouseInWindow(g_fs_ml_window, x, y); } } } }
int PND_gl_loadlibrary(_THIS, const char *path) { SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; /* Check if OpenGL ES library is specified for GF driver */ if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); if (path == NULL) { path = SDL_getenv("SDL_OPENGLES_LIBRARY"); } } /* Check if default library loading requested */ if (path == NULL) { /* Already linked with GF library which provides egl* subset of */ /* functions, use Common profile of OpenGL ES library by default */ path = "/usr/lib/libGLES_CM.so"; } /* Load dynamic library */ _this->gl_config.dll_handle = SDL_LoadObject(path); if (!_this->gl_config.dll_handle) { /* Failed to load new GL ES library */ SDL_SetError("PND: Failed to locate OpenGL ES library"); return -1; } /* Store OpenGL ES library path and name */ SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); /* New OpenGL ES library is loaded */ return 0; }
static int GetVideoDisplay() { const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY"); if (!variable) variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD"); if (variable) return SDL_atoi(variable); else return 0; }
static void SelectVideoDisplay() { const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY"); if ( !variable ) { variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD"); } if ( variable ) { SDL_SelectVideoDisplay(SDL_atoi(variable)); } }
/* Find out what class name we should use * Based on src/video/x11/SDL_x11video.c */ static char * get_classname() { /* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec: "The surface class identifies the general class of applications to which the surface belongs. A common convention is to use the file name (or the full path if it is a non-standard location) of the application's .desktop file as the class." */ char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) char procfile[1024]; char linkfile[1024]; int linksize; #endif /* First allow environment variable override */ spot = SDL_getenv("SDL_VIDEO_WAYLAND_WMCLASS"); if (spot) { return SDL_strdup(spot); } else { /* Fallback to the "old" envvar */ spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); if (spot) { return SDL_strdup(spot); } } /* Next look at the application's executable name */ #if defined(__LINUX__) || defined(__FREEBSD__) #if defined(__LINUX__) SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); #elif defined(__FREEBSD__) SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", getpid()); #else #error Where can we find the executable name? #endif linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); if (linksize > 0) { linkfile[linksize] = '\0'; spot = SDL_strrchr(linkfile, '/'); if (spot) { return SDL_strdup(spot + 1); } else { return SDL_strdup(linkfile); } } #endif /* __LINUX__ || __FREEBSD__ */ /* Finally use the default we've used forever */ return SDL_strdup("SDL_App"); }
/* Check to see if we need to enter or leave mouse relative mode */ void X11_CheckMouseModeNoLock(_THIS) { const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); char *env_override; int enable_relative = 1; /* Allow the user to override the relative mouse mode. They almost never want to do this, as it seriously affects applications that rely on continuous relative mouse motion. */ env_override = SDL_getenv("SDL_MOUSE_RELATIVE"); if ( env_override ) { enable_relative = atoi(env_override); } /* If the mouse is hidden and input is grabbed, we use relative mode */ if ( enable_relative && !(SDL_cursorstate & CURSOR_VISIBLE) && (this->input_grab != SDL_GRAB_OFF) && (SDL_GetAppState() & full_focus) == full_focus ) { if ( ! mouse_relative ) { X11_EnableDGAMouse(this); if ( ! (using_dga & DGA_MOUSE) ) { char *xmouse_accel; SDL_GetMouseState(&mouse_last.x, &mouse_last.y); /* Use as raw mouse mickeys as possible */ XGetPointerControl(SDL_Display, &mouse_accel.numerator, &mouse_accel.denominator, &mouse_accel.threshold); xmouse_accel=SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL"); if ( xmouse_accel ) { SetMouseAccel(this, xmouse_accel); } } mouse_relative = 1; } } else { if ( mouse_relative ) { if ( using_dga & DGA_MOUSE ) { X11_DisableDGAMouse(this); } else { XChangePointerControl(SDL_Display, True, True, mouse_accel.numerator, mouse_accel.denominator, mouse_accel.threshold); } mouse_relative = 0; } } }
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; /* Figure out what our audio device is */ if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) { if ( classic ) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } audio_fd = open(audiodev, flags, 0); /* If the first open fails, look for other devices */ if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) { int exists, instance; struct stat sb; instance = 1; do { /* Don't use errno ENOENT - it may not be thread-safe */ SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance++); exists = 0; if ( stat(audiopath, &sb) == 0 ) { exists = 1; audio_fd = open(audiopath, flags, 0); } } while ( exists && (audio_fd < 0) ); audiodev = audiopath; } if ( path != NULL ) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return(audio_fd); }
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) { if ( classic ) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } audio_fd = open(audiodev, flags, 0); if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) { int exists, instance; struct stat sb; instance = 1; do { SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance++); exists = 0; if ( stat(audiopath, &sb) == 0 ) { exists = 1; audio_fd = open(audiopath, flags, 0); } } while ( exists && (audio_fd < 0) ); audiodev = audiopath; } if ( path != NULL ) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return(audio_fd); }
static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex) { SDL_AudioDevice *this; const char *envr; /* Initialize all variables that we clean on shutdown */ this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { SDL_free(this); } return(0); } SDL_memset(this->hidden, 0, (sizeof *this->hidden)); envr = SDL_getenv(DISKENVR_WRITEDELAY); this->hidden->write_delay = (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY; /* Set the function pointers */ this->OpenAudio = DISKAUD_OpenAudio; this->WaitAudio = DISKAUD_WaitAudio; this->PlayAudio = DISKAUD_PlayAudio; this->GetAudioBuf = DISKAUD_GetAudioBuf; this->CloseAudio = DISKAUD_CloseAudio; this->free = DISKAUD_DeleteDevice; return this; }
static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries) { int i, flagcheck; static Uint32 features = 0xffffffff; /* Get the available CPU features */ if (features == 0xffffffff) { const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES"); features = SDL_CPU_ANY; /* Allow an override for testing .. */ if (override) { SDL_sscanf(override, "%u", &features); } else { if (SDL_HasMMX()) { features |= SDL_CPU_MMX; } if (SDL_HasSSE()) { features |= SDL_CPU_SSE; } if (SDL_HasSSE2()) { features |= SDL_CPU_SSE2; } } }
static int GetDisplayNumber() { const char *display = SDL_getenv("DISPLAY"); const char *p = NULL;; int number = 0; if (display == NULL) return 0; display = SDL_strchr(display, ':'); if (display == NULL) return 0; display++; p = SDL_strchr(display, '.'); if (p == NULL && display != NULL) { number = SDL_strtod(display, NULL); } else { char *buffer = SDL_strdup(display); buffer[p - display] = '\0'; number = SDL_strtod(buffer, NULL); SDL_free(buffer); } return number; }
/** * @brief Gets Naev's cache path (for cached data such as generated textures) * * @return The xdg cache path. */ const char* nfile_cachePath (void) { char *path; if (naev_cachePath[0] == '\0') { #if HAS_UNIX path = xdgGetRelativeHome( "XDG_CACHE_HOME", "/.cache" ); if (path == NULL) { WARN("$XDG_CACHE_HOME isn't set, using current directory."); path = strdup("."); } nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path ); if (path != NULL) { free (path); } #elif HAS_WIN32 path = SDL_getenv("APPDATA"); if (path == NULL) { WARN("%%APPDATA%% isn't set, using current directory."); path = "."; } nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path ); #else #error "Feature needs implementation on this Operating System for Naev to work." #endif } return naev_cachePath; }
static int Audio_Available(void) { long dummy; const char *envr = SDL_getenv("SDL_AUDIODRIVER"); /* Check if user asked a different audio driver */ if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return(0); } /* Cookie _MCH present ? if not, assume ST machine */ if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { cookie_mch = MCH_ST; } /* Cookie _SND present ? if not, assume ST machine */ if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Cookie STFA present ? */ if (Getcookie(C_STFA, &dummy) != C_FOUND) { DEBUG_PRINT((DEBUG_NAME "no STFA audio\n")); return(0); } cookie_stfa = (cookie_stfa_t *) dummy; DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n")); return(1); }
/* Find out what class name we should use * Based on src/video/x11/SDL_x11video.c */ static char * get_classname() { char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) char procfile[1024]; char linkfile[1024]; int linksize; #endif /* First allow environment variable override */ spot = SDL_getenv("SDL_VIDEO_WAYLAND_WMCLASS"); if (spot) { return SDL_strdup(spot); } else { /* Fallback to the "old" envvar */ spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); if (spot) { return SDL_strdup(spot); } } /* Next look at the application's executable name */ #if defined(__LINUX__) || defined(__FREEBSD__) #if defined(__LINUX__) SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); #elif defined(__FREEBSD__) SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", getpid()); #else #error Where can we find the executable name? #endif linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); if (linksize > 0) { linkfile[linksize] = '\0'; spot = SDL_strrchr(linkfile, '/'); if (spot) { return SDL_strdup(spot + 1); } else { return SDL_strdup(linkfile); } } #endif /* __LINUX__ || __FREEBSD__ */ /* Finally use the default we've used forever */ return SDL_strdup("SDL_App"); }
void initSDL() { SDL_DisplayMode mode; int init_flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK; const char *var = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY"); int vm; #ifdef CUSTOM_SIGNAL_HANDLER init_flags |= SDL_INIT_NOPARACHUTE; #endif if(SDL_Init(init_flags) < 0) { printf("SDL Failed to Init!!!! (%s)\n", SDL_GetError()); borExit(0); } SDL_ShowCursor(SDL_DISABLE); atexit(SDL_Quit); if ( !var ) { var = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD"); } if ( var ) { vm = SDL_atoi(var); } else { vm = 0; } // Store the monitor's current resolution before setting the video mode for the first time if(SDL_GetDesktopDisplayMode(vm, &mode) == 0) { nativeWidth = mode.w; nativeHeight = mode.h; } else { nativeWidth = 640; nativeHeight = 480; } savedata.fullscreen = 1; }
int SDL_SYS_CDInit(void) { static char *checklist[] = { #if defined(__OPENBSD__) "?0 cd?c", "cdrom", NULL #elif defined(__NETBSD__) "?0 cd?d", "?0 cd?c", "cdrom", NULL #else "?0 cd?c", "?0 acd?c", "cdrom", NULL #endif }; char *SDLcdrom; int i, j, exists; char drive[32]; struct stat stbuf; /* Fill in our driver capabilities */ SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if ( SDLcdrom != NULL ) { char *cdpath, *delim; size_t len = SDL_strlen(SDLcdrom)+1; cdpath = SDL_stack_alloc(char, len); if ( cdpath != NULL ) { SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { AddDrive(SDLcdrom, &stbuf); } if ( delim ) { SDLcdrom = delim; } else { SDLcdrom = NULL; } } while ( SDLcdrom ); SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ if ( SDL_numcds > 0 ) { return(0); } }
int WIN_GL_LoadLibrary(_THIS, const char *path) { LPTSTR wpath; HANDLE handle; if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); } if (path == NULL) { path = DEFAULT_OPENGL; } wpath = WIN_UTF8ToString(path); _this->gl_config.dll_handle = LoadLibrary(wpath); SDL_free(wpath); if (!_this->gl_config.dll_handle) { char message[1024]; SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", path); WIN_SetError(message); return -1; } SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); /* Allocate OpenGL memory */ _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { SDL_OutOfMemory(); return -1; } /* Load function pointers */ handle = _this->gl_config.dll_handle; _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) GetProcAddress(handle, "wglGetProcAddress"); _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) GetProcAddress(handle, "wglCreateContext"); _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) GetProcAddress(handle, "wglDeleteContext"); _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) GetProcAddress(handle, "wglMakeCurrent"); _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC)) GetProcAddress(handle, "wglShareLists"); if (!_this->gl_data->wglGetProcAddress || !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent) { SDL_SetError("Could not retrieve OpenGL functions"); SDL_UnloadObject(handle); return -1; } return 0; }
/* Audio driver bootstrap functions */ static int ANDROIDAUDIOTRACK_Available(void) { const char *envr = SDL_getenv("SDL_AUDIODRIVER"); if (envr && (SDL_strcmp(envr, ANDROIDAUDIOTRACK_DRIVER_NAME) == 0)) { return(1); } return(0); }
/* Audio driver bootstrap functions */ static int DUMMYAUD_Available(void) { const char *envr = SDL_getenv("SDL_AUDIODRIVER"); if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) { return(1); } return(0); }
int main(int argc, char **argv) { if (!SDL_getenv("SDL_AUDIODRIVER")) { SDL_putenv("SDL_AUDIODRIVER=waveout"); } return game_main(argc, argv); }
int SDL_SYS_CDInit(void) { struct { char *dir; char *name; } checklist[] = { {"/dev/rdisk", "cdrom"}, {"/dev", "rrz"}, {NULL, NULL}}; char drive[32]; char *SDLcdrom; int i, j, exists; struct stat stbuf; SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; SDLcdrom = SDL_getenv("SDL_CDROM"); if ( SDLcdrom != NULL ) { char *cdpath, *delim; size_t len = SDL_strlen(SDLcdrom)+1; cdpath = SDL_stack_alloc(char, len); if ( cdpath != NULL ) { SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { AddDrive(SDLcdrom, &stbuf); } if ( delim ) { SDLcdrom = delim; } else { SDLcdrom = NULL; } } while ( SDLcdrom ); SDL_stack_free(cdpath); } if ( SDL_numcds > 0 ) { return(0); } }
int fs_ml_main_loop() { while (g_fs_ml_running) { fs_ml_event_loop(); process_video_events(); #if defined(WINDOWS) || defined (MACOSX) fs_ml_prevent_power_saving(); #endif fs_ml_render_iteration(); } if (g_fs_emu_video_fullscreen) { if (SDL_getenv("FSGS_RETURN_CURSOR_TO") && SDL_getenv("FSGS_RETURN_CURSOR_TO")[0]) { // we want to improve the transitioning from FS-UAE back to // e.g. FS-UAE Game Center - avoid blinking cursor - so we try // to move it (to the bottom right of the screen). This probably // requires that the cursor is not grabbed (SDL often keeps the // cursor in the center of the screen, then). int x = -1; int y = -1; sscanf(SDL_getenv("FSGS_RETURN_CURSOR_TO"), "%d,%d", &x, &y); if (x != -1 && y != -1) { fs_log("trying to move mouse cursor to x=%d y=%d\n", x, y); Uint8 data[] = "\0"; #ifdef USE_SDL2 SDL_SetWindowGrab(g_fs_ml_window, SDL_FALSE); #else SDL_WM_GrabInput(SDL_GRAB_OFF); #endif // setting invisible cursor so we won't see it when we // enable the cursor in order to move it SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0); SDL_SetCursor(cursor); SDL_ShowCursor(SDL_ENABLE); #ifdef USE_SDL2 SDL_WarpMouseInWindow(g_fs_ml_window, x, y); #else SDL_WarpMouse(x, y); #endif } } } return 0; }
static int DUMMY_Available(void) { const char *envr = SDL_getenv("SDL_VIDEODRIVER"); if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { return(1); } return(0); }
static int get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) { const char *visual_id = SDL_getenv("SDL_VIDEO_X11_VISUALID"); int depth; /* Look for an exact visual, if requested */ if (visual_id) { XVisualInfo *vi, template;
/** * Get value of an environment variable. * Sets @c errno to @c EINVAL if variable is not set or empty. * @param name Name of environment variable. * @return The environment variable or NULL if an error occurs. */ static char* xdgGetEnv(const char *name) { char *env = SDL_getenv(name); if ((env != NULL) && (env[0] != '\0')) return env; /* What errno signifies missing env var? */ errno = EINVAL; return NULL; }
SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority) { const char *env; SDL_Hint *hint; SDL_HintWatch *entry; if (!name || !value) { return SDL_FALSE; } env = SDL_getenv(name); if (env && priority < SDL_HINT_OVERRIDE) { return SDL_FALSE; } for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { if (priority < hint->priority) { return SDL_FALSE; } if (!hint->value || !value || SDL_strcmp(hint->value, value) != 0) { for (entry = hint->callbacks; entry; ) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; entry->callback(entry->userdata, name, hint->value, value); entry = next; } if (hint->value) { SDL_free(hint->value); } if (value) { hint->value = SDL_strdup(value); } else { hint->value = NULL; } } hint->priority = priority; return SDL_TRUE; } } /* Couldn't find the hint, add a new one */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); if (!hint) { return SDL_FALSE; } hint->name = SDL_strdup(name); hint->value = value ? SDL_strdup(value) : NULL; hint->priority = priority; hint->callbacks = NULL; hint->next = SDL_hints; SDL_hints = hint; return SDL_TRUE; }
static void GetEnvironmentWindowPosition(int w, int h, int *x, int *y) { int display = GetVideoDisplay(); const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { if (SDL_sscanf(window, "%d,%d", x, y) == 2) { return; } if (SDL_strcmp(window, "center") == 0) { center = window; } } if (center) { *x = SDL_WINDOWPOS_CENTERED_DISPLAY(display); *y = SDL_WINDOWPOS_CENTERED_DISPLAY(display); } }