Hello, upon getting a new keyboard I noticed that some of my SFML projects experienced huge slow-downs whenever I moved mouse around. I searched the forums for answers and found that it's possible that the analog capabilities of my keyboard (it's a Wooting Two analog keyboard) might make the event-loop slow due to SFML's joystick handlig. But I did not find any solution to this, only links to pages that no longer exist.
I have attached a video that illustrates my problem along with the code I used to illustrate the behaviour, I'm printing the time in ms it takes to run the event-loop.
code:
#include "SFML/Graphics.hpp"
#include <iostream>
#include <chrono>
int main() {
typedef std::chrono::high_resolution_clock Clock;
sf::err().rdbuf(NULL);
sf::RenderWindow window(sf::VideoMode(1280, 720), "woof!", sf::Style::Default);
window.setFramerateLimit(60);
while (window.isOpen()) {
auto t1 = Clock::now();
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
window.close();
}
}
auto t2 = Clock::now();
std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
std::cout << fp_ms.count() << std::endl;
window.clear();
window.display();
}
return 0;
}
I'm using "sf::err().rdbuf(NULL);" because otherwise the terminal would be packed with "Failed to set DirectInput device axis mode: 1".
Any help would be appreciated