From 18f1b6263a06e66ede18fe2741eb7dec49cbddd2 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 26 Aug 2012 14:57:43 +0200 Subject: [PATCH] Joystick check on Linux is now a lot faster (globally improves the performances of pollEvent) --- src/SFML/Window/Linux/JoystickImpl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/Linux/JoystickImpl.cpp b/src/SFML/Window/Linux/JoystickImpl.cpp index ff09c4572..d53eb1598 100644 --- a/src/SFML/Window/Linux/JoystickImpl.cpp +++ b/src/SFML/Window/Linux/JoystickImpl.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace sf @@ -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