Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Event::KeyReleased event bug in SFML 2.0 ?  (Read 4156 times)

0 Members and 1 Guest are viewing this topic.

andrei

  • Newbie
  • *
  • Posts: 4
    • View Profile
sf::Event::KeyReleased event bug in SFML 2.0 ?
« on: May 12, 2013, 10:13:56 am »
Hello, until now I was working with SFML-2.0-r.c. and I didn't noticed anything strange but from yesterday I switched to SFML-2.0 latest version and I noticed that sf::Event::KeyReleased event is not triggered every time.
It works as follows: when I press a key and release it the sf::Event::KeyReleased event is triggered but if I press a key and hold it for some time ( a second or a bit more ) and then release it the sf::Event::KeyReleased event "sometimes" is not triggered. "Sometimes" means that there are times that it is triggered but more often it is not.
I am on Ubuntu 12.04.
« Last Edit: May 13, 2013, 09:15:25 am by andrei »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« Reply #1 on: May 12, 2013, 03:43:40 pm »
I do not verify this problem :/

andrei

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« Reply #2 on: May 13, 2013, 09:50:23 am »
I have some updates. Today I tried to reproduce this bug and it was not so easy but I could reproduce it. On the other hand I could not reproduce this bug on SFML-2.0-r.c. when switching to it.
When reproducing this "bug" sometimes the release event didn't occurred but sometimes the release event occurred and after it another keyPressed event, thus negating the effect of KeyReleased event.

I will attach the .hpp and .cpp files with which I reproduced this "bug".

I am using code::blocks and I linked static SFML library.

[attachment deleted by admin]

andrei

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« Reply #3 on: May 19, 2013, 09:09:03 am »
Hello again. Can anyone help me with this "bug" of mine? because I am still getting this "bug" . I can make a pseudo code if needed, well the 2 files I uploaded in the previous post are the bare minimum of code, they just contain initialization of sfml without opengl, without drawing anything on the screen and sfml::events with more then one key to test.
Thank you for your time.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« Reply #4 on: May 19, 2013, 02:47:37 pm »
well the 2 files I uploaded in the previous post are the bare minimum of code
Not really. A minimal code would be a single .cpp file with only a main() function. No classes, no other functions, no custom code.

Like this, it is much easier for us to see if you made a mistake or if there is an actual issue with SFML, and in the latter case, where it is. Please reduce the code further, so that you can paste it directly with code tags here. Thanks :)

According to your description in the initial post, a normal event loop should suffice to show the problem. Ideal would be some cout statements to log the events, so that you could also provide the corresponding output. In fact, the problem might have been introduced in this modification. You can also use my code snippet there to test and output.
« Last Edit: May 19, 2013, 02:53:30 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

andrei

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« Reply #5 on: May 19, 2013, 03:47:28 pm »
Seeing your code I understand why my code is bloated  ;D .
Okay, I used your code:
#include <SFML/Window.hpp>
#include <iostream>

int main()
{
    sf::Window window(sf::VideoMode(640, 480), "SFML Test");
    window.setKeyRepeatEnabled(false);

    sf::Clock clock;

    int i = 0;
    for (;;)
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
                case sf::Event::Closed:
                    return 0;

                case sf::Event::KeyPressed:
                    if (event.key.code == sf::Keyboard::F)
                        std::cout << ++i << "\tPressed \t"
                        << clock.getElapsedTime().asMilliseconds() << std::endl;
                    break;

                case sf::Event::KeyReleased:
                    if (event.key.code == sf::Keyboard::F)
                        std::cout << "\tReleased\t"
                        << clock.getElapsedTime().asMilliseconds() << std::endl;
                    break;
            }
        }

        window.display();
    }
}

 

and this is the output:
as it can be seen at 5, 6 and 13 the key release event didn't triggered
1       Pressed         2041
        Released        2535
2       Pressed         2942
        Released        3553
3       Pressed         3907
        Released        4417
4       Pressed         4795
        Released        5309
5       Pressed         5704
6       Pressed         7007
7       Pressed         8262
        Released        8839
8       Pressed         9365
        Released        9892
9       Pressed         10364
        Released        10963
10      Pressed         11402
        Released        12018
11      Pressed         12421
        Released        13115
12      Pressed         13542
        Released        14149
13      Pressed         14618
14      Pressed         16177
        Released        16734
 

Thank you for your reply and help.

 

anything