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

Author Topic: SFML Input not working when PS3 controller plugged in.  (Read 4080 times)

0 Members and 1 Guest are viewing this topic.

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
SFML Input not working when PS3 controller plugged in.
« on: June 23, 2009, 01:06:35 am »
I didn't put this in the "sfml input" section, as it didn't seem to be a problem with sfml, but a problem with the ps3 controller.

When trying out the gamepad support of SFML today, I noticed something very weird.

As soon as I connected the PS3 Controller to my PC (using a standard USB to mini USB adapter, so no blue tooth), the sfml input system seemed to stop working.

I'm polling GetEvent() of the sf::Window i'm using within the "game-loop" of my gamestate management class:

the relevant code looks like this:

Code: [Select]

void Game::Run()
{
sf::Event e;
while(m_running)
{
while(Application::inst().GetWindow()->GetEvent(e))
{
m_current_gamestate->Input(e);
}
m_current_gamestate->Update();
m_current_gamestate->Render();
}

m_gamestates.clear();
Application::inst().GetWindow()->Close();
}


so it seems that the ps3 controller seems to be sending random events to windows, which results in my game loop getting "stuck" in the polling, as Application::inst().GetWindow()->GetEvent(e) constantly returns true.

furthermore, those random events from the ps3 seem to be blocking my standard keyboard input, as the application will no longer react to inputs from my keyboard while the ps3 controller is plugged in (this only counts for sfml-using applications, in other games its no problem using both at the same time).

does anyone know where the problem is here?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML Input not working when PS3 controller plugged in.
« Reply #1 on: June 23, 2009, 07:47:21 am »
Which version of SFML are you using? And which OS?
Laurent Gomila - SFML developer

auriplane

  • Newbie
  • *
  • Posts: 6
    • MSN Messenger - crystal@panix.com
    • AOL Instant Messenger - auriplane
    • Yahoo Instant Messenger - auriplane
    • View Profile
    • http://www.xtalcy.com/
SFML Input not working when PS3 controller plugged in.
« Reply #2 on: November 16, 2009, 03:50:00 am »
Hi!

I'm developing with SFML on Linux and Windows.  The first thing I did was attempt to build and run a friend's project (two days ago, using SFML 1.5) on Linux, and I discovered this problem.

When I have a PS3 controller attached under Linux, the event loop never finishes.  It has an endless supply of events showing two of the axes are moving to zero.  When I place a call like this:

app.SetJoystickThreshold(2);

It fixes the problem.  (Setting it to 1 didn't work, I think.)

So, I put that in the startup of my project.  I can confirm that on Windows, the PS3 controller works fine without the above line though.

I can supply more details if you wish, though I am happy with my workaround personally.  I am on day two of making a game with SFML, and I'm loving it!  Long time SDL user here.