fix multiple joystick support
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8562 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: e6a7280db67c36b7dab68a7d400823a41a6f5063 Former-commit-id: e8ffb0f2fb62be88626681023792a66bfc751a49
This commit is contained in:
parent
6f910ed7eb
commit
50be557219
1 changed files with 27 additions and 26 deletions
|
@ -310,35 +310,36 @@ gfctrlJoyInit(void)
|
|||
Joysticks[index] = SDL_JoystickOpen(index);
|
||||
}
|
||||
|
||||
// Don't configure the joystick if it doesn't work
|
||||
if (Joysticks[index] == NULL) {
|
||||
GfLogError("Couldn't open joystick %d: %s\n", index, SDL_GetError());
|
||||
} else {
|
||||
names[index] = SDL_JoystickName(Joysticks[index]);
|
||||
// Don't configure the joystick if it doesn't work
|
||||
if (Joysticks[index] == NULL) {
|
||||
GfLogError("Couldn't open joystick %d: %s\n", index, SDL_GetError());
|
||||
continue;
|
||||
}
|
||||
|
||||
cfx_timeout[index] = 0;
|
||||
rfx_timeout[index] = 0;
|
||||
|
||||
// Find which Haptic device relates to this joystick
|
||||
Haptics[index] = SDL_HapticOpenFromJoystick(Joysticks[index]);
|
||||
names[index] = SDL_JoystickName(Joysticks[index]);
|
||||
|
||||
if (!Haptics[index]) {
|
||||
GfLogInfo("Joystick %d does not support haptic\n", index);
|
||||
break;
|
||||
} else {
|
||||
// add an CF effect on startup
|
||||
gfctrlJoyConstantForce(index, 0, 0);
|
||||
}
|
||||
cfx_timeout[index] = 0;
|
||||
rfx_timeout[index] = 0;
|
||||
|
||||
// Check for Rumble capability
|
||||
if (SDL_HapticRumbleSupported(Haptics[index]) == SDL_TRUE) {
|
||||
if (SDL_HapticRumbleInit(Haptics[index]) != 0)
|
||||
GfLogError("Couldn't init rumble on joystick %d: %s\n", index, SDL_GetError());
|
||||
else
|
||||
gfctrlJoyRumble(index, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Find which Haptic device relates to this joystick
|
||||
Haptics[index] = SDL_HapticOpenFromJoystick(Joysticks[index]);
|
||||
|
||||
if (!Haptics[index]) {
|
||||
GfLogInfo("Joystick %d does not support haptic\n", index);
|
||||
continue;
|
||||
}
|
||||
|
||||
// add an CF effect on startup
|
||||
gfctrlJoyConstantForce(index, 0, 0);
|
||||
|
||||
// Check for Rumble capability
|
||||
if (SDL_HapticRumbleSupported(Haptics[index]) == SDL_TRUE) {
|
||||
if (SDL_HapticRumbleInit(Haptics[index]) != 0)
|
||||
GfLogError("Couldn't init rumble on joystick %d: %s\n", index, SDL_GetError());
|
||||
else
|
||||
gfctrlJoyRumble(index, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue