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

Author Topic: Input GetMouseX/Y not catching on to mouse movement  (Read 1883 times)

0 Members and 1 Guest are viewing this topic.

H

  • Newbie
  • *
  • Posts: 2
    • View Profile
Input GetMouseX/Y not catching on to mouse movement
« on: June 27, 2010, 08:22:15 pm »
I'm programming a GUI in my app and I noticed that button presses weren't being registered very quickly. I did some lazy debugging (send coordinates of mouse to output) and I noticed that Input's GetMouseX and GetMouseY weren't responding nearly fast enough to when the mouse moved somewhere.

This small tidbit should be able to reproduce it (in a HandleEvents function that is called in a typical game loop, obviously replace App::whatever with whatever you have in your workspace).

Code: [Select]

int x = App::GetApp()->GetInput().GetMouseX();
int y = App::GetApp()->GetInput().GetMouseY();
std::cout << x << " " << y << "\n";


Just move your mouse around on the screen and watch the output. I'm not sure if this is correct behavior and I'm using it for the wrong purpose, or what, but I need some way to retrieve the mouse's exact location at any given time. Any help is appreciated, thanks.

P.S. If I move the mouse slowly the problem doesn't occur.

Edit: Using SFML 1.5 (though I tested on 1.6 and still had same problem). To make what is wrong a bit more clear, say the cursor starts at 30,60. You move your mouse very quickly to 400, 200. GetMouseX and GetMouseY will return that position correctly, but it will get "stuck" at that position when I continue to move the mouse. If I move the mouse very slowly the whole time there isn't a problem.

I also tried calling the MouseMove event x attribute and y attribute, and what I noticed there is that when the mouse moved fast and then stopped, the values would continuously go up and down (238->538->238) in a rolling manner (i.e. 1 by 1(very fast though)). This is hard to explain in words, but hopefully you get what I mean.

2nd Edit:

Edit:

I was wrong. The problem only occurs in context with the rest of the stuff going on. When I blocked out most of the game loop and only included retrieving cursor position, it worked fine. Still not sure what is wrong though. I also noticed (when putting in some keyboard input for that state) that moving the mouse quickly lags the keyboard input as well.

H

  • Newbie
  • *
  • Posts: 2
    • View Profile
Input GetMouseX/Y not catching on to mouse movement
« Reply #1 on: June 30, 2010, 04:26:50 am »
The problem was that only one event was being polled per frame. Fixed.