Note that there are some explanatory texts on larger screens.

plurals
  1. PORepeating key events blocking
    primarykey
    data
    text
    <p>I wrote a simple program with <strong>SFML</strong> and <strong>OpenGL</strong> which draws a spinning square that can be moved around the screen with the arrow keys.</p> <p>It works fine on all the Linux and Mac computers I've tested it on, but when I try to move the square on Windows (by holding down an arrow key) it moves a small distance and then stops moving and spinning. I'm pretty sure the program is getting stuck in the <code>GetEvent</code> method - my guess is that when I've held the key down long enough for it to start repeating, the event stack keeps getting new events added to it before I can pop everything off it (and if I turn the key repeat rate on Windows right down to the minimum then the problem goes away - I don't really like this as a solution though). </p> <p>I found that pressing and holding Alt, Ctrl, Delete, Page up, Page down, Home, End etc all cause this behavior too (even though I don't specifically detect any of these keys in the program), but all the letter keys, as well as space, enter, backspace and the keypad arrow keys work fine (i.e. they don't cause the program to pause if I hold them down for too long).</p> <p>I don't have the exact code (I just turned my laptop off), but it looks like:</p> <pre><code>while(running) { while(app.GetEvent(event)) if(event.Type==sf::Event::Closed) running=false; if(input.IsKeyDown(sf::Key::Right)); // move right // etc etc // update rotation // draw everything } </code></pre> <p>Any ideas as to what the exact problem might be, and how I could fix it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload