Exemplo n.º 1
0
/* Function: al_install_mouse
 */
bool al_install_mouse(void)
{
   if (new_mouse_driver)
      return true;
   
   //FIXME: seems A4/A5 driver list stuff doesn't quite agree right now
   if (al_get_system_driver()->vt->get_mouse_driver) {
       new_mouse_driver = al_get_system_driver()->vt->get_mouse_driver();
       if (!new_mouse_driver->init_mouse()) {
          new_mouse_driver = NULL;
          return false;
       }
       _al_add_exit_func(al_uninstall_mouse, "al_uninstall_mouse");
       return true;
   }


   return false;
#if 0

   if (system_driver && system_driver->mouse_drivers)
      driver_list = system_driver->mouse_drivers();
   else
      driver_list = _al_mouse_driver_list;

   ASSERT(driver_list);

   for (i=0; driver_list[i].driver; i++) {
      new_mouse_driver = driver_list[i].driver;
      //name = get_config_text(new_mouse_driver->msedrv_ascii_name);
	  name = new_mouse_driver->msedrv_ascii_name;
      new_mouse_driver->msedrv_name = name;
      new_mouse_driver->msedrv_desc = name;
      if (new_mouse_driver->init_mouse()) {
	 break;
      }
   }

   if (!driver_list[i].driver) {
      new_mouse_driver = NULL;
      return false;
   }
   _al_add_exit_func(al_uninstall_mouse, "al_uninstall_mouse");


   return true;
#endif

}
Exemplo n.º 2
0
/* Function: al_install_haptic
 */
bool al_install_haptic(void)
{
   ALLEGRO_SYSTEM *sysdrv;
   ALLEGRO_HAPTIC_DRIVER *hapdrv;

   if (haptic_driver)
      return true;

   sysdrv = al_get_system_driver();
   ASSERT(sysdrv);

   /* Currently every platform only has at most one haptic driver. */
   if (sysdrv->vt->get_haptic_driver) {
      hapdrv = sysdrv->vt->get_haptic_driver();
      /* Avoid race condition in case the haptic driver generates an
       * event right after ->init_haptic.
       */
      if (hapdrv && hapdrv->init_haptic()) {
         haptic_driver = hapdrv;
         _al_add_exit_func(al_uninstall_haptic, "al_uninstall_haptic");
         return true;
      }
   }

   return false;
}
Exemplo n.º 3
0
void _al_sdl_event_hack(void)
{
   if (thread)
      return;
   _al_add_exit_func(_uninstall_sdl_event_hack, "uninstall_sdl_event_hack");
   thread = al_create_thread(wakeup_thread, NULL);
   al_start_thread(thread);
}
Exemplo n.º 4
0
static bool init_dynlib(void)
{
#ifdef ALLEGRO_CFG_ACODEC_VORBISFILE_DLL
   if (ov_dll) {
      return true;
   }

   if (!ov_virgin) {
      return false;
   }

   ov_virgin = false;

   ov_dll = _al_open_library(ALLEGRO_CFG_ACODEC_VORBISFILE_DLL);
   if (!ov_dll) {
      ALLEGRO_WARN("Could not load " ALLEGRO_CFG_ACODEC_VORBISFILE_DLL "\n");
      return false;
   }

   _al_add_exit_func(shutdown_dynlib, "shutdown_dynlib");

   #define INITSYM(x)                                                         \
      do                                                                      \
      {                                                                       \
         lib.x = _al_import_symbol(ov_dll, #x);                               \
         if (lib.x == 0) {                                                    \
            ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n");     \
            return false;                                                     \
         }                                                                    \
      } while(0)
#else
   #define INITSYM(x)   (lib.x = (x))
#endif

   memset(&lib, 0, sizeof(lib));

   INITSYM(ov_clear);
   INITSYM(ov_open_callbacks);
   INITSYM(ov_pcm_total);
   INITSYM(ov_info);
#ifndef TREMOR
   INITSYM(ov_time_total);
   INITSYM(ov_time_seek_lap);
   INITSYM(ov_time_tell);
   INITSYM(ov_read);
#else
   INITSYM(ov_time_total);
   INITSYM(ov_time_seek);
   INITSYM(ov_time_tell);
   INITSYM(ov_read);
#endif

   return true;

#undef INITSYM
}
Exemplo n.º 5
0
/* Function: al_init_native_dialog_addon
 */
bool al_init_native_dialog_addon(void)
{
   if (!inited_addon) {
      if (!_al_init_native_dialog_addon()) {
         ALLEGRO_ERROR("_al_init_native_dialog_addon failed.\n");
         return false;
      }
      inited_addon = true;
      _al_add_exit_func(al_shutdown_native_dialog_addon,
         "al_shutdown_native_dialog_addon");
   }
   return true;
}
Exemplo n.º 6
0
/* Function: al_init_native_dialog_addon
 */
bool al_init_native_dialog_addon(void)
{
   if (!inited_addon) {
      if (!_al_init_native_dialog_addon()) {
         ALLEGRO_ERROR("_al_init_native_dialog_addon failed.\n");
         return false;
      }
      inited_addon = true;
      al_init_user_event_source(al_get_default_menu_event_source());
      _al_add_exit_func(al_shutdown_native_dialog_addon,
         "al_shutdown_native_dialog_addon");
   }
   return true;
}
Exemplo n.º 7
0
/* Function: al_install_audio
 */
bool al_install_audio(void)
{
    if (_al_kcm_driver)
        return true;

    /* The destructors are initialised even if the audio driver fails to install
     * because the user may still create samples.
     */
    _al_kcm_init_destructors();
    _al_add_exit_func(al_uninstall_audio, "al_uninstall_audio");

    al_init_user_event_source((ALLEGRO_EVENT_SOURCE *)&audio_event_source);

    return do_install_audio(ALLEGRO_AUDIO_DRIVER_AUTODETECT);
}
Exemplo n.º 8
0
static bool init_dynlib(void)
{
#ifdef ALLEGRO_CFG_ACODEC_OPUSFILE_DLL
   if (op_dll) {
      return true;
   }

   if (!op_virgin) {
      return false;
   }

   op_virgin = false;

   op_dll = _al_open_library(ALLEGRO_CFG_ACODEC_OPUSFILE_DLL);
   if (!op_dll) {
      ALLEGRO_WARN("Could not load " ALLEGRO_CFG_ACODEC_OPUSFILE_DLL "\n");
      return false;
   }

   _al_add_exit_func(shutdown_dynlib, "shutdown_dynlib");

   #define INITSYM(x)                                                         \
      do                                                                      \
      {                                                                       \
         lib.x = _al_import_symbol(op_dll, #x);                               \
         if (lib.x == 0) {                                                    \
            ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n");     \
            return false;                                                     \
         }                                                                    \
      } while(0)
#else
   #define INITSYM(x)   (lib.x = (x))
#endif

   memset(&lib, 0, sizeof(lib));

   INITSYM(op_free);
   INITSYM(op_channel_count);
   INITSYM(op_open_callbacks);
   INITSYM(op_pcm_total);
   INITSYM(op_pcm_seek);
   INITSYM(op_pcm_tell);
   INITSYM(op_read);

   return true;

#undef INITSYM
}
Exemplo n.º 9
0
/* Function: al_install_keyboard
 */
bool al_install_keyboard(void)
{
   if (new_keyboard_driver)
      return true;

   //FIXME: seems A4/A5 driver list stuff doesn't quite agree right now
   if (al_get_system_driver()->vt->get_keyboard_driver) {
       new_keyboard_driver = al_get_system_driver()->vt->get_keyboard_driver();
       if (!new_keyboard_driver->init_keyboard()) {
          new_keyboard_driver = NULL;
          return false;
       }
       _al_add_exit_func(al_uninstall_keyboard, "al_uninstall_keyboard");
       return true;
   }
   
   return false;

   /*
   if (system_driver->keyboard_drivers)
      driver_list = system_driver->keyboard_drivers();
   else
      driver_list = _al_keyboard_driver_list;

   for (i=0; driver_list[i].driver; i++) {
      new_keyboard_driver = driver_list[i].driver;
      name = get_config_text(new_keyboard_driver->keydrv_ascii_name);
      new_keyboard_driver->keydrv_name = name;
      new_keyboard_driver->keydrv_desc = name;
      if (new_keyboard_driver->init_keyboard())
	 break;
   }

   if (!driver_list[i].driver) {
      new_keyboard_driver = NULL;
      return false;
   }

   //set_leds(-1);

   _al_add_exit_func(al_uninstall_keyboard, "al_uninstall_keyboard");


   return true;
   */
}
Exemplo n.º 10
0
/* Function: al_init_video_addon
 */
bool al_init_video_addon(void)
{
   if (video_inited)
      return true;

#ifdef ALLEGRO_CFG_VIDEO_HAVE_OGV
   add_handler(".ogv", _al_video_ogv_vtable());
#endif

   if (handlers == NULL) {
      ALLEGRO_WARN("No video handlers available!\n");
      return false;
   }

   _al_add_exit_func(al_shutdown_video_addon, "al_shutdown_video_addon");

   return true;
}
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;
}
Exemplo n.º 12
0
static void acodec_ensure_init(void)
{
   if (acodec_inited) {
      return;
   }

   /* Must be before register calls to avoid recursion. */
   acodec_inited = true;

   al_register_sample_loader(".wav", al_load_wav);
   al_register_sample_saver(".wav", al_save_wav);
   al_register_audio_stream_loader(".wav", al_load_wav_audio_stream);
   
   al_register_sample_loader_f(".wav", al_load_wav_f);
   al_register_sample_saver_f(".wav", al_save_wav_f);
   al_register_audio_stream_loader_f(".wav", al_load_wav_audio_stream_f);

   _al_add_exit_func(acodec_shutdown, "acodec_shutdown");
}
Exemplo n.º 13
0
/* _al_init_events:
 *  Initialise globals for the event system.
 */
void _al_init_events(void)
{
   _al_mutex_init(&user_event_refcount_mutex);
   _al_add_exit_func(shutdown_events, "shutdown_events");
}
Exemplo n.º 14
0
static bool init_libdumb(void)
{
   if (libdumb_loaded) {
      return true;
   }

#ifdef ALLEGRO_CFG_ACODEC_DUMB_DLL
   dumb_dll = _al_open_library(ALLEGRO_CFG_ACODEC_DUMB_DLL);
   if (!dumb_dll) {
      ALLEGRO_ERROR("Could not load " ALLEGRO_CFG_ACODEC_DUMB_DLL "\n");
      return false;
   }

   #define INITSYM(x)                                                         \
      do                                                                      \
      {                                                                       \
         lib.x = _al_import_symbol(dumb_dll, #x);                             \
         if (lib.x == 0) {                                                    \
            ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n");     \
            return false;                                                     \
         }                                                                    \
      } while(0)
#else
   #define INITSYM(x)   (lib.x = (x))
#endif

   _al_add_exit_func(shutdown_libdumb, "shutdown_libdumb");

   memset(&lib, 0, sizeof(lib));

   INITSYM(duh_render); /* see comment on duh_render deprecation above */
   INITSYM(duh_sigrenderer_get_position);
   INITSYM(duh_end_sigrenderer);
   INITSYM(unload_duh);
   INITSYM(duh_start_sigrenderer);
   INITSYM(dumbfile_open_ex);
   INITSYM(duh_get_length);
   INITSYM(dumb_exit);
   INITSYM(register_dumbfile_system);
   INITSYM(duh_get_it_sigrenderer);
   INITSYM(dumb_it_set_loop_callback);
   INITSYM(dumb_it_set_xm_speed_zero_callback);
   INITSYM(dumb_it_callback_terminate);

   dfs.open = dfs_open;
   dfs.skip = dfs_skip;
   dfs.getc = dfs_getc;
   dfs.getnc = dfs_getnc;
   dfs.close = dfs_close;

#if (DUMB_MAJOR_VERSION) >= 2
   INITSYM(dumb_read_any);

   dfs.seek = dfs_seek;
   dfs.get_size = dfs_get_size;
#else
   INITSYM(dumb_read_it);
   INITSYM(dumb_read_xm);
   INITSYM(dumb_read_s3m);
   INITSYM(dumb_read_mod);
#endif

   /* Set up DUMB's default I/O to go through Allegro... */
   lib.register_dumbfile_system(&dfs);

   /* But we'll actually use them through this version: */
   dfs_f = dfs;
   dfs_f.open = NULL;
   dfs_f.close = NULL;

   libdumb_loaded = true;
   return true;
}
Exemplo n.º 15
0
/* Function: al_install_system
 */
bool al_install_system(int version, int (*atexit_ptr)(void (*)(void)))
{
   ALLEGRO_SYSTEM bootstrap;
   ALLEGRO_SYSTEM *real_system;
   int library_version = al_get_allegro_version();

   if (active_sysdrv) {
      return true;
   }

   /* Note: We cannot call logging functions yet.
    * TODO: Maybe we want to do the check after the "bootstrap" system
    * is available at least?
    */
   if (!compatible_versions(version, library_version))
      return false;

   _al_tls_init_once();

   _al_vector_init(&_al_system_interfaces, sizeof(ALLEGRO_SYSTEM_INTERFACE *));

   /* Set up a bootstrap system so the calls expecting it don't freak out */
   memset(&bootstrap, 0, sizeof(bootstrap));
   active_sysdrv = &bootstrap;
   read_allegro_cfg();

#ifdef ALLEGRO_BCC32
   /* This supresses exceptions on floating point divide by zero */
   _control87(MCW_EM, MCW_EM);
#endif

   /* Register builtin system drivers */
   _al_register_system_interfaces();

   /* Check for a user-defined system driver first */
   real_system = find_system(&_user_system_interfaces);

   /* If a user-defined driver is not found, look for a builtin one */
   if (real_system == NULL) {
      real_system = find_system(&_al_system_interfaces);
   }

   if (real_system == NULL) {
      active_sysdrv = NULL;
      return false;
   }
   
   active_sysdrv = real_system;
   active_sysdrv->mouse_wheel_precision = 1;

   ALLEGRO_INFO("Allegro version: %s\n", ALLEGRO_VERSION_STR);

   if (strcmp(al_get_app_name(), "") == 0) {
      al_set_app_name(NULL);
   }

   _al_add_exit_func(shutdown_system_driver, "shutdown_system_driver");

   _al_dtor_list = _al_init_destructors();

   _al_init_events();

   _al_init_pixels();

   _al_init_iio_table();
   
   _al_init_convert_bitmap_list();

   _al_init_timers();

#ifdef ALLEGRO_CFG_SHADER_GLSL
   _al_glsl_init_shaders();
#endif

   if (active_sysdrv->vt->heartbeat_init)
      active_sysdrv->vt->heartbeat_init();

   if (atexit_ptr && atexit_virgin) {
#ifndef ALLEGRO_ANDROID
      atexit_ptr(al_uninstall_system);
#endif
      atexit_virgin = false;
   }

   /* Clear errnos set while searching for config files. */
   al_set_errno(0);

   active_sysdrv->installed = true;

   _al_srand(time(NULL));

   return true;
}