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

Author Topic: Mouse wheel problem on OS X.  (Read 5550 times)

0 Members and 1 Guest are viewing this topic.

Mr Qwak

  • Newbie
  • *
  • Posts: 5
    • View Profile
Mouse wheel problem on OS X.
« on: June 17, 2013, 12:34:09 pm »
Wondering if this is happening to anyone else...

I'm polling window events okay, and getting the mouse wheel delta (event.mouseWheel.delta). However, if I scroll my mouse wheel in one direction, slowly by continuously, one 'step' at a time; I always get a delta of 0.

Not sure if this is something specific just to the OS X version of SFML? Is there anything I can do to fix this behaviour?

I'm assuming event.mouseWheel.delta, is an int; is that correct?

Any suggestions very much appreciated. Thanks.

Mr Qwak

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Mouse wheel problem on OS X.
« Reply #1 on: June 17, 2013, 11:11:43 pm »
After some investigation...

It seems the mouse wheel deltaY comes from Mac OS X as a float; and SFML is stuffing it in to an Event struct as an int; which I suspect may be the cause of the issue.

1. First it's a float...

-(void)scrollWheel:(NSEvent *)theEvent
{
    if (m_requester != 0) {
        NSPoint loc = [self cursorPositionFromEvent:theEvent];
       
        m_requester->mouseWheelScrolledAt([theEvent deltaY], loc.x, loc.y);
       
    }
   
    // Transmit to non-SFML responder
    [[self nextResponder] scrollWheel:theEvent];
}

2. Now it's n int...

void WindowImplCocoa::mouseWheelScrolledAt(float delta, int x, int y)
{
    Event event;
    event.type = Event::MouseWheelMoved;
    event.mouseWheel.delta = delta; // suspect the event.mouseWheel.delta is an int?
    event.mouseWheel.x = x;
    event.mouseWheel.y = y;
   
    pushEvent(event);
}

Possibly moving the wheel a single notch at a time is causing low (< 0.5f values in the delta, which are coming out as 0, when it's converted to an int).

Could well be wrong though...
« Last Edit: June 17, 2013, 11:40:37 pm by Mr Qwak »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mouse wheel problem on OS X.
« Reply #2 on: June 17, 2013, 11:26:31 pm »
Yes, this is a common problem with smooth wheels. There is an issue about it on the task tracker.
Laurent Gomila - SFML developer

Mr Qwak

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Mouse wheel problem on OS X.
« Reply #3 on: June 17, 2013, 11:44:07 pm »
Ah, spotted it. Thank you Laurent. :)

Can I also ask, how does it work with the development of the SFML lib. Do you make all the changes yourself, or are other people making changes too? (checking stuff in and out of source control etc).

I imagine, it's just you. Could get rather messy with 'too many cooks spoiling the broth' etc etc. How do you like people to contribute? Just make suggestions on the issue tracker?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mouse wheel problem on OS X.
« Reply #4 on: June 18, 2013, 07:36:09 am »
People can contribute with patches or pull requests on github, if they want to submit code.
Laurent Gomila - SFML developer

jokoon

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Mouse wheel problem on OS X.
« Reply #5 on: June 01, 2014, 12:26:45 am »
well I see two solutions.

by testing how my mac is behaving, any tiny scrolling with the touchpad triggers an event, so converting to either 1 or -1 will enable devs to come with some quick ratio solution, but it won't be optimal...

I guess you can't really fix this by changing the sf::Event::MouseWheelEvent::delta type from int to float since it might break existing applications...

another fair fix would be to add another float delta_float field to store a float data when possible...

I don't really know the difference between how linux/windows/mac handles the mousewheel/touchpad, but I guess some issues have as much problems as solutions.