SFML community forums

Help => Window => Topic started by: shadok on March 15, 2010, 02:23:47 am

Title: Unresponsive mouse event
Post by: shadok on March 15, 2010, 02:23:47 am
Hi there,
I'm using the SFML API for a little project/game, and I found that the mouse event handler doesn't capture all the mouse event that can happens.
Let me explain further: when I move very fast the mouse and then I click in the window, despite the fact that I have coded the capture mouse button func in my source correctly, the window won't process the clicks.
For the sake of completeness, I have tried both with the event and the input funcs, with the same result.
I found this glitch only, the rest of the API is done wonderfully.

Thank you Laurent, keep on with this work!
Bye

P.S. I am sorry if my english may be poor. I speak natively the italian language, and seldom the english language.
Title: Unresponsive mouse event
Post by: Laurent on March 15, 2010, 08:40:30 am
Hi

Can you show a minimal and complete source code that reproduces your problem?
Title: Unresponsive mouse event
Post by: shadok on March 15, 2010, 03:55:25 pm
Quote from: "Laurent"
Hi

Can you show a minimal and complete source code that reproduces your problem?


I have send you the source code. I have noticed that I got this issue if I set a frame limit for the main window (I set it on 60 fps), or use vertical sync. If I remove this line of code, the glitch doesn't present again.
Title: Unresponsive mouse event
Post by: shadok on March 25, 2010, 06:45:03 pm
Basically, I setup a game state manager like described in this page http://gamedevgeek.com/tutorials/managing-game-states-in-c. Next, I coded three states (the intro, the menu and a black main game loop state), with a little modify: every time i change the state, the manager remember the last pushed state, so it won't pop back a state every time I need to perform an action with it. I was thinking this solution would speeding up operations (or fps) and resolve my problem, but I have achieved nothing. The capture handler for mouse input (or mouse event) seems to suffer of a strange lag...
Title: Unresponsive mouse event
Post by: shadok on March 26, 2010, 08:14:43 pm
I totally forgot to say that I use Linux to develop this project. Compiling and running under Vista, makes the issue disappears.
Title: Unresponsive mouse event
Post by: shadok on March 28, 2010, 08:08:12 pm
I have resolved the problem, at last. It was an error in my code!

In the event handling code I had:

Code: [Select]

void CGameEngine::handleEvent()
{
    // let the state handle events
    if(m_win.GetEvent(m_event))
        m_currentState->handleEvent(m_event);
}


I have replaced the if with a while:

Code: [Select]

void CGameEngine::handleEvent()
{
    // let the state handle events
    while(m_win.GetEvent(m_event))
        m_currentState->handleEvent(m_event);
}


Now the lag is disappeared, and everything works fine. Sorry to have bothered you!

Bye