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 2356

Summary: [Android] SDL_JoystickGetAttached does not function
Product: SDL Reporter: David Brady <dbrady>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.1   
Hardware: ARM   
OS: Android (All)   
Attachments: Patch
Patch 2

Description David Brady 2014-01-21 03:25:10 UTC
Created attachment 1527 [details]
Patch

The controller always reports itself as attached.  Patch to fix the problem is attached.  I copied over some relevant stuff from the Linux version of this feature.
Comment 1 David Brady 2014-01-21 03:38:51 UTC
Created attachment 1528 [details]
Patch 2

Fix memory leak...
Comment 2 Gabriel Jacobo 2014-01-21 14:29:43 UTC
How about just changing line 447 from

return !joystick->closed && (joystick->hwdata != NULL);

to

return !joystick->closed
Comment 3 David Brady 2014-01-21 19:13:01 UTC
Because closed is only set when SDL_JoystickClose is called, not when it's removed.
Comment 4 Gabriel Jacobo 2014-01-21 21:22:42 UTC
Should be fixed here: https://hg.libsdl.org/SDL/rev/df0bf33be2ca

Thanks for the report!
Comment 5 David Brady 2014-01-21 21:47:38 UTC
Ah, I didn't read that code carefully enough.  I thought that was a different joystick object in the list.  Thanks for the fix.