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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pyhax

Pages: [1]
1
Window / Re: [Linux] pollEvent is slow / disable joystick
« on: August 21, 2012, 09:40:15 pm »
Woops, sry, in the posted code is an error:
 char filename[13 /* For /dev/input/js */ + std::numeric_limits<unsigned int>::digits10 + 1 /* Null termination */];
 std::sprintf(filename + 13, "/dev/input/js%u", index);
must be
 char filename[13 /* For /dev/input/js */ + std::numeric_limits<unsigned int>::digits10 + 2 /* Null termination */];
 std::sprintf(filename, "/dev/input/js%u", index);
 

The + 13 was left over from some experiments. +2 instead of +1 for array size is because of http://stackoverflow.com/a/5926044 (See comments),

2
Window / [Linux] pollEvent is slow / disable joystick
« on: August 21, 2012, 08:53:44 pm »
Hi,

I just wrote a little program using SFML and profiled it, because it was lagging a bit. The profiler said the 20% of the time is spent in sf::Window::pollEvent. I found out that the slow part of it is in sf::prov::JoystickImpl::isConnected. In that function, there is an ostringstream created everytime it is called (42% of the time in that function is spent in std::basic_ios<>::init), so I tried replacing JoystickImpl::isConnected with the following code:
bool JoystickImpl::isConnected(unsigned int index)
{
    char filename[13 /* For /dev/input/js */ + std::numeric_limits<unsigned int>::digits10 + 1 /* Null termination */];
    std::sprintf(filename + 13, "/dev/input/js%u", index);

    struct stat info;
    return stat(filename, &info) == 0;
}
 

With this modification the lags disappeared. But with that change, the user would have to install the sfml libraries with the changed code too. So, is there any way to just disable joystick support in SFML? I don't need it.

Pages: [1]
anything