Skip to content

Commit

Permalink
Joystick check on Linux is now a lot faster (globally improves the pe…
Browse files Browse the repository at this point in the history
…rformances of pollEvent)
  • Loading branch information
LaurentGomila committed Aug 26, 2012
1 parent d716b36 commit 18f1b62
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/SFML/Window/Linux/JoystickImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <sstream>
#include <cstdio>


namespace sf
Expand All @@ -39,21 +39,21 @@ namespace priv
////////////////////////////////////////////////////////////
bool JoystickImpl::isConnected(unsigned int index)
{
std::ostringstream oss;
oss << "/dev/input/js" << index;
char name[32];
std::sprintf(name, "/dev/input/js%u", index);

struct stat info;
return stat(oss.str().c_str(), &info) == 0;
return stat(name, &info) == 0;
}


////////////////////////////////////////////////////////////
bool JoystickImpl::open(unsigned int index)
{
std::ostringstream oss;
oss << "/dev/input/js" << index;
char name[32];
std::sprintf(name, "/dev/input/js%u", index);

m_file = ::open(oss.str().c_str(), O_RDONLY);
m_file = ::open(name, O_RDONLY);
if (m_file > 0)
{
// Use non-blocking mode
Expand Down

0 comments on commit 18f1b62

Please sign in to comment.