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 2309

Summary: SDL_JoystickGetButton always returns 0
Product: SDL Reporter: Alexander Mezin <mezin.alexander>
Component: joystickAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: 2.0.0Keywords: target-2.0.4, triage-2.0.4
Hardware: x86_64   
OS: Linux   
Attachments: Update button state even when SDL_GetKeyboardFocus returns NULL

Description Alexander Mezin 2013-12-16 06:56:24 UTC
Created attachment 1497 [details]
Update button state even when SDL_GetKeyboardFocus returns NULL

SDL_GameControllerGetButton returns 0 for XBOX 360 gamepad on Linux (Debian Sid) even when buttons are actually pressed. The exception is only DPAD buttons.
I tried SDL_JoystickGetButton, but it doesn't work too.

After looking into sources, I checked SDL_GetKeyboardFocus. It returns NULL even when the only window in my app is active.

Also, axes and hats work even in that case, so I think buttons should work too. Look at attached patch.
Comment 1 Alexander Mezin 2013-12-18 19:00:10 UTC
Found a workaround:
SDL_HideWindow(window);
SDL_ShowWindow(window);

Also, after switching to other window and switching back, gamepad starts working too
Comment 2 Ryan C. Gordon 2015-02-19 05:22:18 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 3 Ryan C. Gordon 2015-04-07 04:57:56 UTC
(sorry if you get a lot of copies of this email, I'm marking several bugs at once)

Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship.

(Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.)

--ryan.
Comment 4 Ryan C. Gordon 2015-05-27 01:35:31 UTC
By any chance, was this running on a Linux box with no window manager? We have a known bug where it fails to mark a window as focused when there's no window manager running.

--ryan.
Comment 5 Ryan C. Gordon 2015-05-28 06:18:07 UTC
Two bugs in the target-2.0.4 list are the same thing, merging them.

--ryan.

*** This bug has been marked as a duplicate of bug 2438 ***