/* Function to scan the system for joysticks. * Joystick 0 should be the system default joystick. * This function should return the number of available joysticks, or -1 * on an unrecoverable fatal error. */ int SDL_SYS_JoystickInit(void) { static ISpDeviceClass classes[4] = { kISpDeviceClass_Joystick, kISpDeviceClass_Gamepad, kISpDeviceClass_Wheel, 0 }; OSErr err; int i; UInt32 count, numJoysticks; if ( (Ptr)0 == (Ptr)ISpStartup ) { SDL_SetError("InputSprocket not installed"); return -1; // InputSprocket not installed } if( (Ptr)0 == (Ptr)ISpGetVersion ) { SDL_SetError("InputSprocket not version 1.1 or newer"); return -1; // old version of ISp (not at least 1.1) } ISpStartup(); /* Get all the joysticks */ numJoysticks = 0; for ( i=0; classes[i]; ++i ) { count = 0; err = ISpDevices_ExtractByClass( classes[i], MAX_JOYSTICKS-numJoysticks, &count, &SYS_Joysticks[numJoysticks]); numJoysticks += count; } for(i = 0; i < numJoysticks; i++) { ISpDevice_GetDefinition( SYS_Joysticks[i], sizeof(ISpDeviceDefinition), &SYS_DevDef[i]); err = ISpElementList_New( 0, NULL, &SYS_Elements[i], 0); if (err) { SDL_OutOfMemory(); return -1; } ISpDevice_GetElementList( SYS_Joysticks[i], &SYS_Elements[i]); } ISpDevices_Deactivate(numJoysticks, SYS_Joysticks); return numJoysticks; }
Word BURGERCALL MacInputInit(MacInput_t *Input,Word Flags) { if (!Input->InputSprocketInited) { /* Not started? */ if (MacOSGetInputSprocketVersion()>=0x130) { /* 1.3 or better? */ if (Input->InputSprocketInited || !ISpStartup()) { /* Start up input sprocket */ Input->Flags |= Flags; /* Set the requester */ Input->InputSprocketInited = TRUE; /* Set the flag for later shutdown */ Input->InputSprocketActive = TRUE; /* Enable sprockets */ return FALSE; /* I'm ok */ } } return TRUE; /* Error in startup */ } Input->Flags |= Flags; /* Set the requester */ return FALSE; /* I'm ok */ }