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

Author Topic: static access to mouse wheel (SFML2)  (Read 6891 times)

0 Members and 2 Guests are viewing this topic.

m00npirate

  • Newbie
  • *
  • Posts: 18
    • View Profile
static access to mouse wheel (SFML2)
« on: August 11, 2011, 06:27:01 am »
Can we get static access to the mouse wheel like the other inputs in sfml2? Thanks.

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
static access to mouse wheel (SFML2)
« Reply #1 on: August 11, 2011, 06:39:24 am »
How is that supposed to work?

There is no constant value for the mouse wheel motion that would allow for it to be accessed statically, unless you mean the "middle mouse button" being pressed down (ie mouse wheel being pressed). In that case, use sf::Mouse.

Otherwise, the mouse wheel has ticks, everytime the user rotates the wheel and a tick is reached, a mouse wheel event is caused in SFML that can be polled using sf::Window::PollEvent.
JSFML - The Java binding to SFML.

m00npirate

  • Newbie
  • *
  • Posts: 18
    • View Profile
static access to mouse wheel (SFML2)
« Reply #2 on: August 11, 2011, 07:16:33 am »
AFAIK the mouse wheel is a button just like any other. Many games treat MouseWheelUp/MouseWheelDown like any other key and let you bind commands to them. This is what I am trying to do, but I am forced to poll for them separately through window events then pass them around. Isn't this what the static input interface was made to avoid in the first place?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
static access to mouse wheel (SFML2)
« Reply #3 on: August 11, 2011, 08:04:59 am »
Quote
AFAIK the mouse wheel is a button just like any other. Many games treat MouseWheelUp/MouseWheelDown like any other key and let you bind commands to them.

I still don't understand if you're talking about pressing the wheel button, or rotating the wheel up and down.
Laurent Gomila - SFML developer

m00npirate

  • Newbie
  • *
  • Posts: 18
    • View Profile
static access to mouse wheel (SFML2)
« Reply #4 on: August 11, 2011, 08:17:15 am »
Sorry, I mean rotating the mouse wheel. I would like to access whether the wheel has progressed up or down a tick statically.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
static access to mouse wheel (SFML2)
« Reply #5 on: August 11, 2011, 08:21:03 am »
This is not possible. The wheel has no permanent state, the only thing that you can know about it is when it rotates up or down. But once it has rotated, it's not in a new state that could be represented by a number. What would you expect a Mouse::GetWheelPosition() to return?

Quote
Many games treat MouseWheelUp/MouseWheelDown like any other key and let you bind commands to them

Yeah, these two things are events ;)
Laurent Gomila - SFML developer

m00npirate

  • Newbie
  • *
  • Posts: 18
    • View Profile
static access to mouse wheel (SFML2)
« Reply #6 on: August 11, 2011, 09:11:07 am »
I would imagine something like Mouse::GetWheelDelta() which returns the net number of ticks since the last time the function was called. Actually, I see now how I could just add this myself, but it would be nice to not have to catch window events manually to get it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
static access to mouse wheel (SFML2)
« Reply #7 on: August 11, 2011, 09:35:36 am »
Quote
I would imagine something like Mouse::GetWheelDelta() which returns the net number of ticks since the last time the function was called

This is not how real-time inputs work. They give you the state of a device at the moment you request it ("is this key down?", "what's the cursor position?" -- not "was this button pressed since I last checked?" or similar).
It's not an event accumulator, that would tell you what happened since the last time you asked.

And by the way, if you move the wheel up and then down very fast, a Mouse::GetWheelDelta() function would return 0, just like if nothing happened.
Laurent Gomila - SFML developer

m00npirate

  • Newbie
  • *
  • Posts: 18
    • View Profile
static access to mouse wheel (SFML2)
« Reply #8 on: August 11, 2011, 08:46:01 pm »
Ah ok. I see the confusion now. An accumulator of events is exactly what I am making. For each key I care about I increment a counter if I see it pressed this frame, and reset it to zero if I don't. This tells me if a key was just pressed this frame, is being held down, has just been released, etc. I retract my request =P