SFML community forums

Help => Window => Topic started by: Russo on November 13, 2020, 04:48:17 pm

Title: Joystick input when out of focus
Post by: Russo on November 13, 2020, 04:48:17 pm
The function
sf::Joystick::isButtonPressed(joy, button)
was supposed to return the joystick input even when the window is out of focus, right? I'm asking because this doesn't seem to work for me. I tried using
sf::Joystick::update()
too, and it still doesn't work. I also tried using events and the result was the same (not surprisingly since events can only be handled by an active window as far as I know). Am I doing something wrong? Is there another way to get a joystick input when the window is out of focus?

Oh by the way I tried using the keyboard as well and it was fine, I could get the out of focus input. The only issue is the joystick.
sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)
Title: Re: Joystick input when out of focus
Post by: Laurent on November 14, 2020, 09:19:20 am
Does everything work as expected when the window has focus?

Also, what's your OS and joystick model? Version of SFML?
Title: Re: Joystick input when out of focus
Post by: Russo on November 14, 2020, 07:04:21 pm
Does everything work as expected when the window has focus?

Also, what's your OS and joystick model? Version of SFML?

Yes, everything works fine on focus, but the goal of the application was to work on the background. I tried the SDL library and it has a function to fix this:
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");

Is there anything similar to that in SFML? I'm on Windows 10 using a Xbox One Controller, and SFML version is 2.5.1. Also I'm using MinGW