Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haptic feedback no longer works in OS X release builds #2462

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Haptic feedback no longer works in OS X release builds #2462

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.5
Reported for operating system, platform: Mac OS X (All), x86

Comments on the original bug report:

On 2017-05-29 19:51:17 +0000, RustyM wrote:

Haptic feedback no longer works when built with modern versions of Xcode. Haptic feedback works normally in debug builds, but release builds without a debugger attached no longer work.

Xcode 7.2.1 and previous versions work correctly.
Xcode 7.3 and onward all exhibit this issue.

On 2017-06-06 19:37:26 +0000, Ryan C. Gordon wrote:

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.

On 2017-06-06 20:41:40 +0000, RustyM wrote:

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

On 2017-06-07 18:45:59 +0000, Sam Lantinga wrote:

Can you post the code you're using with SDL_HAPTIC_CUSTOM?

Thanks!

On 2017-06-08 12:24:57 +0000, RustyM wrote:

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);
}

On 2017-08-09 05:38:15 +0000, Ryan C. Gordon wrote:

(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.

On 2019-01-06 16:22:14 +0000, RustyM wrote:

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.

@slouken slouken removed the bug label May 11, 2022
@slouken slouken closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants