We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2727

Summary: Request for SDL_GameControllerInstanceID
Product: SDL Reporter: JKaniarz <john>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED ABANDONED QA Contact: Sam Lantinga <slouken>
Severity: API change    
Priority: P2 CC: philipp.wiesemann
Version: 2.0.3   
Hardware: All   
OS: All   

Description JKaniarz 2014-09-12 03:13:17 UTC
If the Game Controller API is to be used instead of the Joystick API, it seems odd to me that you still have to call the joystick api to get the ID when handling events. i.e. 
if(event.caxis.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))). 

It's a trivial addition to the GameController API to completely hide the Joystick API.

SDL_JoystickID
SDL_GameControllerInstanceID(SDL_GameController * gamecontroller){
    if ( !gamecontroller )
        return (-1);

    //should the joystick object be validated? The rest of the game controller api doesn't
    return gamecontroller->joystick->instance_id;
}
Comment 1 Philipp Wiesemann 2015-11-15 18:31:07 UTC
With SDL 2.0.4 the function SDL_GameControllerFromInstanceID() may be used instead. It was added here:
https://hg.libsdl.org/SDL/rev/9429bc102632
Comment 2 Ryan C. Gordon 2018-08-06 21:20:23 UTC
Hello, and sorry if you're getting dozens of copies of this message by email.

We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc.

Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report.

So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues.

(please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!)

Thanks,
--ryan.