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

Author Topic: mouse input not always registering  (Read 2157 times)

0 Members and 1 Guest are viewing this topic.

sludge

  • Newbie
  • *
  • Posts: 24
    • View Profile
mouse input not always registering
« on: August 22, 2010, 02:09:18 am »
The title says everything.

In my gameloop, the following variable is checked for a left mouse clicked every iteration.

const sf::Input& input = editorWindow.GetInput();

I noticed that sometimes the mouse does not seem to respond as anticipated.  After adding a simple cout statement after

if(input.IsMouseButtonDown(sf::Mouse::Left))

I learned that the condition is not returning true after every time I press the left mouse button.  I know that the input class is used to gather real-time input.  Are some of the mouse clicks not being registered simply because of a lag in between calls to GetInput()?

I imagine that things will function as expected if I check for a mouse event instead?  Is this the case?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
mouse input not always registering
« Reply #1 on: August 22, 2010, 09:02:27 am »
if there is a «lag» it's with cout.

sf::Input is updated with sf::Event. So using sf::Event will not change anything here.
SFML / OS X developer

Recruit0

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
mouse input not always registering
« Reply #2 on: August 23, 2010, 02:06:57 am »
It depends on where you're calling it. If it's not in the event handler code, then it could miss it.

sludge

  • Newbie
  • *
  • Posts: 24
    • View Profile
mouse input not always registering
« Reply #3 on: August 25, 2010, 06:43:30 am »
Ah ha.  I figured it out.  After you mentioned that input and events are essentially the same thing, it all clicked.

 

anything