Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Joystick input when out of focus  (Read 1140 times)

0 Members and 1 Guest are viewing this topic.

Russo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Joystick input when out of focus
« 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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Joystick input when out of focus
« Reply #1 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?
Laurent Gomila - SFML developer

Russo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Joystick input when out of focus
« Reply #2 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