Repository: libsdl-org/SDL
File: src/joystick/ps2/SDL_sysjoystick.c (C)

Code before:
static void PS2_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{
}

// Function to return the stable GUID for a plugged in device
static SDL_GUID PS2_JoystickGetDeviceGUID(int device_index)
{
    // the GUID is just the name for now
    const char *name = PS2_JoystickGetDeviceName(device_index);
    return SDL_CreateJoystickGUIDForName(name);
}

// Function to get the current instance id of the joystick located at device_index
static SDL_JoystickID PS2_JoystickGetDeviceInstanceID(int device_index)
{
    return device_index + 1;
}

static void PS2_WaitPadReady(int port, int slot) {
    int state;
    do {
        state = padGetState(port, slot);
    } while ((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1));
}

static void PS2_InitializePad(int port, int slot) {
    int modes;
    int i;
    int actuators;
    char actAlign[6];

    PS2_WaitPadReady(port, slot);

    // How many different modes can this device operate in?
    modes = padInfoMode(port, slot, PAD_MODETABLE, -1);

    // Verify that the controller has a DUAL SHOCK mode
    for (i = 0; i < modes; i++) {
        if (padInfoMode(port, slot, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK) {
            break;
        }
    }
    if (i >= modes) {
        // This is no Dual Shock controller
        return;
    }
    
    // If ExId != 0x0 => This controller has actuator engines
    // This check should always pass if the Dual Shock test above passed
    if (!padInfoMode(port, slot, PAD_MODECUREXID, 0)) {
        // This is no Dual Shock controller??

Review comment (suggestion):
```suggestion
static void PS2_InitializePad(int port, int slot)
{
```

Code after:
static void PS2_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{
}

// Function to return the stable GUID for a plugged in device
static SDL_GUID PS2_JoystickGetDeviceGUID(int device_index)
{
    // the GUID is just the name for now
    const char *name = PS2_JoystickGetDeviceName(device_index);
    return SDL_CreateJoystickGUIDForName(name);
}

// Function to get the current instance id of the joystick located at device_index
static SDL_JoystickID PS2_JoystickGetDeviceInstanceID(int device_index)
{
    return device_index + 1;
}

static void PS2_WaitPadReady(int port, int slot)
{
    int state = padGetState(port, slot);
    while ((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1)) {
        SDL_Delay(1);
        state = padGetState(port, slot);
    }
}

static void PS2_InitializePad(int port, int slot)
{
    int modes;
    int i;
    char actAlign[6];

    PS2_WaitPadReady(port, slot);

    // How many different modes can this device operate in?
    modes = padInfoMode(port, slot, PAD_MODETABLE, -1);

    // Verify that the controller has a DUAL SHOCK mode
    for (i = 0; i < modes; i++) {
        if (padInfoMode(port, slot, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK) {
            break;
        }
    }
    if (i >= modes) {
        // This is no Dual Shock controller
        return;
    }
    
    // If ExId != 0x0 => This controller has actuator engines
    // This check should always pass if the Dual Shock test above passed