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

Author Topic: Unresponsive mouse event  (Read 3195 times)

0 Members and 1 Guest are viewing this topic.

shadok

  • Newbie
  • *
  • Posts: 5
    • View Profile
Unresponsive mouse event
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Unresponsive mouse event
« Reply #1 on: March 15, 2010, 08:40:30 am »
Hi

Can you show a minimal and complete source code that reproduces your problem?
Laurent Gomila - SFML developer

shadok

  • Newbie
  • *
  • Posts: 5
    • View Profile
Unresponsive mouse event
« Reply #2 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.

shadok

  • Newbie
  • *
  • Posts: 5
    • View Profile
Unresponsive mouse event
« Reply #3 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...

shadok

  • Newbie
  • *
  • Posts: 5
    • View Profile
Unresponsive mouse event
« Reply #4 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.

shadok

  • Newbie
  • *
  • Posts: 5
    • View Profile
Unresponsive mouse event
« Reply #5 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

 

anything