/* Initialize joystick support. */ int joy_arch_init(void) { ULONG action; // return value from DosOpen APIRET rc; if (SWhGame) return 0; joylog = log_open("Joystick"); archdep_create_mutex_sem(&hmtxJoystick, "Joystick", TRUE); number_joysticks = JOYDEV_NONE; if (rc=DosOpen("GAME$", &SWhGame, &action, 0, FILE_READONLY, OPEN_ACTION_OPEN_IF_EXISTS/*FILE_OPEN*/, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL)) { if (rc==ERROR_OPEN_FAILED) { log_warning(joylog, "Cannot open device 'GAME$'."); log_warning(joylog, "Have you installed a MPPM/2 joystick device driver?\n"); } else log_error(joylog, "DosOpen 'GAME$' (rc=%i)", rc); } else { GAME_PARM_STRUCT parms; ULONG dataLen = sizeof(parms); // length of gameStatus if (rc=DosDevIOCtl(SWhGame, IOCTL_CAT_USER, GAME_GET_PARMS, NULL, 0, NULL, &parms, dataLen, &dataLen)) { log_error(joylog, "DosDevIOCtl (rc=%i)", rc); } else { if (parms.useA) { log_message(joylog, "Joystick A found."); number_joysticks |= JOYDEV_HW1; } if (parms.useB) { log_message(joylog, "Joystick B found."); number_joysticks |= JOYDEV_HW2; } if (number_joysticks==JOYDEV_NONE) log_message(joylog, "Sorry, no joystick found!"); } } DosReleaseMutexSem(hmtxJoystick); return 0; }
int archdep_init(int *argc, char **argv) { /* This is right way to do this in OS/2 (not via argv[0]) */ TIB *pTib; PIB *pPib; DosGetInfoBlocks(&pTib, &pPib); DosQueryModuleName(pPib->pib_hmte, CCHMAXPATH, argv0); orig_workdir = (char *)getcwd(NULL, CCHMAXPATH); atexit(restore_workdir); PM_open(); #if !defined __X1541__ && !defined __PETCAT__ archdep_create_mutex_sem(&hmtxSpawn, "Spawn", FALSE); #endif return 0; }