/* ljoy_exit_joystick: [primary thread] * Shut down the joystick driver. */ static void ljoy_exit_joystick(void) { int i; #ifdef SUPPORT_HOTPLUG if (inotify_fd != -1) { _al_unix_stop_watching_fd(inotify_fd); close(inotify_fd); inotify_fd = -1; } hotplug_ended = true; al_signal_cond(hotplug_cond); al_join_thread(hotplug_thread, NULL); #endif al_destroy_mutex(config_mutex); config_mutex = NULL; for (i = 0; i < (int)_al_vector_size(&joysticks); i++) { ALLEGRO_JOYSTICK_LINUX **slot = _al_vector_ref(&joysticks, i); inactivate_joy(*slot); al_free(*slot); } _al_vector_free(&joysticks); num_joysticks = 0; }
/* ljoy_release_joystick: [primary thread] * * Close the device for a joystick then free the joystick structure. */ static void ljoy_release_joystick(ALLEGRO_JOYSTICK *joy_) { ALLEGRO_JOYSTICK_LINUX *joy = (ALLEGRO_JOYSTICK_LINUX *) joy_; int i; _al_unix_stop_watching_fd(joy->fd); _al_event_source_free(&joy->parent.es); close(joy->fd); for (i = 0; i < joy->parent.info.num_sticks; i++) _AL_FREE((void *)joy->parent.info.stick[i].name); for (i = 0; i < joy->parent.info.num_buttons; i++) _AL_FREE((void *)joy->parent.info.button[i].name); _AL_FREE(joy); }
/* lkeybd_exit_keyboard: [primary thread] * Shut down the keyboard driver. */ static void lkeybd_exit_keyboard(void) { _al_unix_stop_watching_fd(the_keyboard.fd); _al_event_source_free(&the_keyboard.parent.es); /* Restore terminal attrs, keyboard mode, and reset the LED mode. */ tcsetattr(the_keyboard.fd, TCSANOW, &the_keyboard.startup_termio); ioctl(the_keyboard.fd, KDSKBMODE, the_keyboard.startup_kbmode); ioctl(the_keyboard.fd, KDSETLED, 8); close(the_keyboard.fd); //__al_linux_leave_console(); /* This may help catch bugs in the user program, since the pointer * we return to the user is always the same. */ memset(&the_keyboard, 0, sizeof the_keyboard); }
static void inactivate_joy(ALLEGRO_JOYSTICK_LINUX *joy) { int i; if (joy->config_state == LJOY_STATE_UNUSED) return; joy->config_state = LJOY_STATE_UNUSED; _al_unix_stop_watching_fd(joy->fd); close(joy->fd); joy->fd = -1; for (i = 0; i < joy->parent.info.num_sticks; i++) al_free((void *)joy->parent.info.stick[i].name); for (i = 0; i < joy->parent.info.num_buttons; i++) al_free((void *)joy->parent.info.button[i].name); memset(&joy->parent.info, 0, sizeof(joy->parent.info)); memset(&joy->joystate, 0, sizeof(joy->joystate)); al_ustr_free(joy->device_name); joy->device_name = NULL; }