static ALLEGRO_AUDIO_DRIVER_ENUM get_config_audio_driver(void) { ALLEGRO_CONFIG *config = al_get_system_config(); const char *value; if (!config) return ALLEGRO_AUDIO_DRIVER_AUTODETECT; value = al_get_config_value(config, "audio", "driver"); if (!value || value[0] == '\0') return ALLEGRO_AUDIO_DRIVER_AUTODETECT; if (0 == _al_stricmp(value, "ALSA")) return ALLEGRO_AUDIO_DRIVER_ALSA; if (0 == _al_stricmp(value, "OPENAL")) return ALLEGRO_AUDIO_DRIVER_OPENAL; if (0 == _al_stricmp(value, "OPENSL")) return ALLEGRO_AUDIO_DRIVER_OPENSL; if (0 == _al_stricmp(value, "OSS")) return ALLEGRO_AUDIO_DRIVER_OSS; if (0 == _al_stricmp(value, "PULSEAUDIO")) return ALLEGRO_AUDIO_DRIVER_PULSEAUDIO; if (0 == _al_stricmp(value, "DSOUND") || 0 == _al_stricmp(value, "DIRECTSOUND")) return ALLEGRO_AUDIO_DRIVER_DSOUND; return ALLEGRO_AUDIO_DRIVER_AUTODETECT; }
static int string_to_depth(const char *s) { // FIXME: fill in the rest if (!_al_stricmp(s, "int16")) { return ALLEGRO_AUDIO_DEPTH_INT16; } else { return ALLEGRO_AUDIO_DEPTH_FLOAT32; } }
/* Checks whether the configured joystick driver is of the given name. * Also returns false if the configuration entry was not set. */ static bool win_configured_joystick_driver_is(const char * name) { const char * driver; ALLEGRO_CONFIG * sysconf = al_get_system_config(); if (!sysconf) return false; driver = al_get_config_value(sysconf, "joystick", "driver"); if (!driver) return false; ALLEGRO_DEBUG("Configuration value joystick.driver = %s\n", driver); return (0 == _al_stricmp(driver, name)); }
static int match_key_name(const char *s) { int i; /* Some key names are not intuitive, but this is all we've got. */ for (i = 1; i < ALLEGRO_KEY_MAX; i++) { if (0 == _al_stricmp(s, _al_keyboard_common_names[i])) return i; } return 0; }
static unsigned int match_modifier(const char *s) { if (0 == _al_stricmp(s, "SHIFT")) return ALLEGRO_KEYMOD_SHIFT; if (0 == _al_stricmp(s, "CTRL")) return ALLEGRO_KEYMOD_CTRL; if (0 == _al_stricmp(s, "ALT")) return ALLEGRO_KEYMOD_ALT; if (0 == _al_stricmp(s, "LWIN")) return ALLEGRO_KEYMOD_LWIN; if (0 == _al_stricmp(s, "RWIN")) return ALLEGRO_KEYMOD_RWIN; if (0 == _al_stricmp(s, "ALTGR")) return ALLEGRO_KEYMOD_ALTGR; if (0 == _al_stricmp(s, "COMMAND")) return ALLEGRO_KEYMOD_COMMAND; return 0; }
static ACODEC_TABLE *find_acodec_table_entry(const char *ext) { ACODEC_TABLE *ent; unsigned i; if (!acodec_inited) { acodec_inited = true; _al_add_exit_func(acodec_shutdown, "acodec_shutdown"); } for (i = 0; i < _al_vector_size(&acodec_table); i++) { ent = _al_vector_ref(&acodec_table, i); if (0 == _al_stricmp(ent->ext, ext)) { return ent; } } return NULL; }
static bool select_pixel_format(ALLEGRO_DISPLAY_WGL *d, HDC dc) { ALLEGRO_EXTRA_DISPLAY_SETTINGS **eds = NULL; ALLEGRO_SYSTEM *system = (void *)al_get_system_driver(); int eds_count = 0; int i; bool force_old = false; if (system->config) { const char *selection_mode; selection_mode = al_get_config_value(system->config, "graphics", "config_selection"); if (selection_mode && selection_mode[0] != '\0') { if (!_al_stricmp(selection_mode, "old")) { ALLEGRO_INFO("Forcing OLD visual selection method.\n"); force_old = true; } else if (!_al_stricmp(selection_mode, "new")) force_old = false; } } if (!force_old) eds = get_available_pixel_formats_ext(&eds_count); if (!eds) eds = get_available_pixel_formats_old(&eds_count, dc); if (!eds || !eds_count) { ALLEGRO_ERROR("Didn't find any suitable pixel format!\n"); return false; } qsort(eds, eds_count, sizeof(eds[0]), _al_display_settings_sorter); for (i = 0; i < eds_count ; i++) { if (SetPixelFormat(d->dc, eds[i]->index, NULL)) { ALLEGRO_INFO("Chose visual no. %i\n\n", eds[i]->index); display_pixel_format(eds[i]); break; } else { ALLEGRO_WARN("Unable to set pixel format! %s\n", get_error_desc(GetLastError())); ALLEGRO_WARN("Trying next one.\n"); } } if (i == eds_count) { ALLEGRO_ERROR("Unable to set any pixel format! %s\n", get_error_desc(GetLastError())); for (i = 0; i < eds_count; i++) al_free(eds[i]); al_free(eds); return false; } memcpy(&d->win_display.display.extra_settings, eds[i], sizeof(ALLEGRO_EXTRA_DISPLAY_SETTINGS)); for (i = 0; i < eds_count; i++) al_free(eds[i]); if (eds) al_free(eds); return true; }
static ALLEGRO_DISPLAY_INTERFACE *win_get_display_driver(void) { const int flags = al_get_new_display_flags(); ALLEGRO_SYSTEM *sys = al_get_system_driver(); ALLEGRO_CONFIG *sys_cfg = al_get_system_config(); ALLEGRO_SYSTEM_WIN *syswin = (ALLEGRO_SYSTEM_WIN *)sys; const char *s; /* Look up the toggle_mouse_grab_key binding. This isn't such a great place * to do it, but the config file is not available in win_initialize, * and this is neutral between the D3D and OpenGL display drivers. */ if (!syswin->toggle_mouse_grab_keycode) { const char *binding = al_get_config_value(sys_cfg, "keyboard", "toggle_mouse_grab_key"); if (binding) { syswin->toggle_mouse_grab_keycode = _al_parse_key_binding(binding, &syswin->toggle_mouse_grab_modifiers); if (syswin->toggle_mouse_grab_keycode) { ALLEGRO_DEBUG("Toggle mouse grab key: '%s'\n", binding); } else { ALLEGRO_WARN("Cannot parse key binding '%s'\n", binding); } } } /* Programmatic selection. */ #ifdef ALLEGRO_CFG_D3D if (flags & ALLEGRO_DIRECT3D_INTERNAL) { ALLEGRO_DISPLAY_INTERFACE* iface = _al_display_d3d_driver(); if (iface == NULL) ALLEGRO_WARN("Direct3D graphics driver not available.\n"); return iface; } #endif #ifdef ALLEGRO_CFG_OPENGL if (flags & ALLEGRO_OPENGL) { return _al_display_wgl_driver(); } #endif /* Selection by configuration file. The configuration value is non-binding. * The user may unknowingly set a value which was configured out at compile * time. The value should have no effect instead of causing a failure. */ s = al_get_config_value(sys_cfg, "graphics", "driver"); if (s) { ALLEGRO_DEBUG("Configuration value graphics.driver = %s\n", s); if (0 == _al_stricmp(s, "DIRECT3D") || 0 == _al_stricmp(s, "D3D")) { #ifdef ALLEGRO_CFG_D3D ALLEGRO_DISPLAY_INTERFACE* iface = _al_display_d3d_driver(); if (iface != NULL) { al_set_new_display_flags(flags | ALLEGRO_DIRECT3D_INTERNAL); return iface; } #endif } else if (0 == _al_stricmp(s, "OPENGL")) { #ifdef ALLEGRO_CFG_OPENGL al_set_new_display_flags(flags | ALLEGRO_OPENGL); return _al_display_wgl_driver(); #endif } else if (0 != _al_stricmp(s, "DEFAULT")) { ALLEGRO_WARN("Graphics driver selection unrecognised: %s\n", s); } } /* Automatic graphics driver selection. */ /* XXX is implicitly setting new_display_flags the desired behaviour? */ #ifdef ALLEGRO_CFG_D3D { ALLEGRO_DISPLAY_INTERFACE* iface = _al_display_d3d_driver(); if (iface != NULL) { al_set_new_display_flags(flags | ALLEGRO_DIRECT3D_INTERNAL); return iface; } } #endif #ifdef ALLEGRO_CFG_OPENGL { al_set_new_display_flags(flags | ALLEGRO_OPENGL); return _al_display_wgl_driver(); } #endif ALLEGRO_WARN("No graphics driver available.\n"); return NULL; }