| Summary: | Haptic feedback no longer works in OS X release builds | ||
|---|---|---|---|
| Product: | SDL | Reporter: | RustyM <rustym> |
| Component: | haptic | Assignee: | Ryan C. Gordon <icculus> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | rustym |
| Version: | 2.0.5 | Keywords: | target-2.0.6 |
| Hardware: | x86 | ||
| OS: | Mac OS X (All) | ||
|
Description
RustyM
2017-05-29 19:51:17 UTC
This works here: - Get the latest SDL sources - Open Xcode/SDL/SDL.xcodeproj - Hit Apple-B to build it. - Quit Xcode - Open Xcode/SDLtest/SDLtest.xcodeproj - Hit Apple-B to build. - Find testrumble in the list of products - Right click, "Show in Finder" - Run it, feel controller vibrate. Am I doing something wrong? This was Xcode 8.3.2, using a wired Xbox360 controller and the 0.16.5 drivers from https://github.com/360Controller/360Controller/releases --ryan. Ahh, yes that test works correctly for me too. I’m remembering the specifics of this bug as I dig deeper. The test uses the “SDL_HapticRumblePlay”, But I'm have specific issues "SDL_HapticEffect.type": SDL_HAPTIC_LEFTRIGHT Works on PC, but has NEVER worked on Mac. (Really just want SDL_HAPTIC_LEFTRIGHT working on Mac) SDL_HAPTIC_CUSTOM I’m using this to get the SDL_HAPTIC_LEFTRIGHT functionality working on Mac. This is what was previously working on in Xcode 7.2.1 and below and stopped after Xcode 7.3 on up. SDL_HAPTIC_CONSTANT Works on Mac and PC, but can’t control the Xbox 360 motors separately. I’m also running Xcode 8.3.2 and the 0.16.5 drivers from https://github.com/360Controller/360Controller/releases Can you post the code you're using with SDL_HAPTIC_CUSTOM? Thanks! Sure! Pasting it below. Let me know if any of this isn't clear.
typedef enum {
kHapticEffectShoot,
kHapticEffectDamage,
kHapticEffectDeath,
kHapticEffectShort
} HapticEffect;
struct HapticStruct {
SDL_Haptic *haptic;
HapticType hapticType;
};
int InputPlayer::createHapticEffect(HapticEffect effectType)
{
SDL_HapticEffect effect;
int id = -1;
memset( &effect, 0, sizeof(SDL_HapticEffect) );
effect.type = SDL_HAPTIC_CUSTOM;
effect.custom.direction.type = SDL_HAPTIC_POLAR;
effect.custom.direction.dir[0] = 0;
effect.custom.length = 5000;
effect.custom.attack_length = 0;
effect.custom.fade_length = 0;
effect.custom.channels = 2;
effect.custom.samples = 2;
effect.custom.period = 0;
switch (effectType) {
case kHapticEffectShoot: {
Uint16 data[] = {0, 32767}; // Small Motor
effect.custom.data = data;
break; }
case kHapticEffectDamage: {
Uint16 data[] = {0, 25700}; // Small Motor
effect.custom.data = data;
break; }
case kHapticEffectDeath: {
Uint16 data[] = {32767, 32767}; // Both Motors
effect.custom.data = data;
break; }
case kHapticEffectShort: {
Uint16 data[] = {32767, 32767}; // Both Motors
effect.custom.data = data;
break; }
}
id = SDL_HapticNewEffect( hapticStruct.haptic, &effect );
if (id < 0) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
return id;
}
void InputPlayer::playHapticEffect(HapticEffect effectType)
{
if (hapticStruct.haptic == nullptr) return;
if (hapticStruct.hapticType == kHapticType_NONE) return;
int effectID = -1;
switch (effectType) {
case kHapticEffectShoot: rumbleTimer = 0.175f; break;
case kHapticEffectDamage: rumbleTimer = 0.35f; break;
case kHapticEffectDeath: rumbleTimer = 0.7f; break;
case kHapticEffectShort: rumbleTimer = 0.25f; break;
}
if (prevEffectID > -1) SDL_HapticDestroyEffect(hapticStruct.haptic, prevEffectID);
effectID = createHapticEffect(effectType);
prevEffectID = effectID;
if (effectID != -1) SDL_HapticRunEffect(hapticStruct.haptic, effectID, 1);
}
// Stop Rumble manually
void InputPlayer::update()
{
if (rumbleTimer > 0) {
rumbleTimer -= 0.0166666667f;
if (rumbleTimer <= 0) {
stopRumble();
}
}
}
void InputPlayer::stopRumble()
{
if (hapticStruct.hapticType == kHapticType_NONE) return;
SDL_HapticStopAll(hapticStruct.haptic);
}
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.6. This means we're in the final stretch for an official SDL 2.0.6 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.6 release, and generally be organized about what we're aiming to ship. After some debate, we might just remove this tag again and deal with it for a later release. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan. The new controller HIDAPI in 2.0.9 provides haptic functionality without using the haptic api. SDL_GameControllerRumble() seems to work properly on new versions of Xcode, so, I think this bug can be closed. |