SFML 2.0. I had the same problem with both the version from the package manager as well as the version I compiled from the source code on the SFML website.
Fake Edit: I just cloned the SFML repository from github and compiled, same issue.
The minor slowdown I've been getting from keyboard events is probably negligable. And the USB mouse issue is probably because the mouse reports at a much higher rate and at a higher dpi than the laptop touchpad which makes it send a million more mouse movement events.
This is the code I've been using to test this out:
#include <SFML/Window.hpp>
#include <cstdio>
void calculate(sf::Time elapsedTime, sf::Time& updateTime, std::size_t& frameCount)
{
updateTime += elapsedTime;
frameCount += 1;
if (updateTime >= sf::seconds(1.0f))
{
printf("fps: %d\n dt: %d\n", frameCount, updateTime.asMicroseconds() / frameCount);
updateTime -= sf::seconds(1.0f);
frameCount = 0;
}
}
int main()
{
// Create the main window
sf::Window window(sf::VideoMode(640, 480, 32), "SFML Window", sf::Style::Close);
window.setFramerateLimit(60);
window.setKeyRepeatEnabled(true);
std::size_t frameCount = 0;
sf::Time updateTime = sf::Time::Zero;
sf::Clock frameClock;
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
// Escape key : exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
window.close();
}
calculate(frameClock.restart(), updateTime, frameCount);
// Finally, display the rendered frame on screen
window.display();
}
return EXIT_SUCCESS;
}
I think I get an average of 30 frames per second when I just made circles with my mouse on the empty window as opposed to 60 frames per second when idling.
Another thing to note is that I solved my initial issue by downgrading my kernel and switching from a kernel with the ck patchset to a more vanilla kernel (in one step). I guess that might be something to look into also. I was getting idling at 20 frames per second and it would instantly drop down to <5 if I sent any event to the window. I'm aware that I changed two variables there; I'm not completely sure whether it was the new kernel version or the ck-patchset that caused the problem the first time around.