void JE_tyrianHalt( JE_byte code ) { deinit_audio(); deinit_video(); deinit_joysticks(); /* TODO: NETWORK */ free_main_shape_tables(); free_sprite2s(&shapes6); for (int i = 0; i < SAMPLE_COUNT; i++) { free(digiFx[i]); } if (code != 9) { /* TODO? JE_drawANSI("exitmsg.bin"); JE_gotoXY(1,22);*/ JE_saveConfiguration(); } /* endkeyboard; */ if (code == 9) { /* OutputString('call=file0002.EXE' + #0'); TODO? */ } if (code == 5) { code = 0; } if (trentWin) { printf("\n" "\n" "\n" "\n" "Sleep well, Trent, you deserve the rest.\n" "You now have permission to borrow my ship on your next mission.\n" "\n" "Also, you might want to try out the YESXMAS parameter.\n" " Type: File0001 YESXMAS\n" "\n" "You'll need the 2.1 patch, though!\n" "\n"); } SDL_Quit(); exit(code); }
void md::init_joysticks() { int n; unsigned int i; SDL_Joystick *(*tmp)[]; deinit_joysticks(); // Initialize the joystick support // Thanks to Cameron Moore <*****@*****.**> if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "joystick: Unable to initialize joystick system\n"); return; } n = SDL_NumJoysticks(); if (n <= 0) { fprintf(stderr, "joystick: no joystick found\n"); return; } fprintf(stderr, "joystick: %d joystick(s) found\n", n); tmp = (SDL_Joystick *(*)[])malloc(sizeof((*tmp)[0]) * n); if (tmp == NULL) { fprintf(stderr, "joystick: unable to allocate memory\n"); return; } // Open all of them. for (i = 0; (i != (unsigned int)n); ++i) { SDL_Joystick *handle = SDL_JoystickOpen(i); if (handle == NULL) fprintf(stderr, "joystick: can't open joystick %u: %s", i, SDL_GetError()); else fprintf(stderr, "joystick #%u:, %d %s, %d button(s)," " %d hat(s), name: \"%s\"\n", i, SDL_JoystickNumAxes(handle), ((SDL_JoystickNumAxes(handle) == 1) ? "axis" : "axes"), SDL_JoystickNumButtons(handle), SDL_JoystickNumHats(handle), SDL_JoystickName(i)); (*tmp)[i] = handle; } handles = tmp; handles_n = i; // Enable joystick events SDL_JoystickEventState(SDL_ENABLE); }