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

Author Topic: Bugreport: Scrollwheel does not work properly under Windows  (Read 3060 times)

0 Members and 1 Guest are viewing this topic.

nwp

  • Newbie
  • *
  • Posts: 4
    • View Profile
Bugreport: Scrollwheel does not work properly under Windows
« on: December 28, 2013, 11:26:56 pm »
Somehow I did not find the bug report subforum, sorry for that.

Under Windows the translation from WM_MOUSEWHEEL to sf::Event::MouseWheelMoved in SFML/Window/Win32/WindowImplWin32.cpp:603 is wrong for SFML 2.1. The WM_MOUSEWHEEL goes in WHEEL_DELTA units, which is 120. The line says
Quote
event.mouseWheel.delta = static_cast<Int16>(HIWORD(wParam)) / 120;
The Windows documentation states
Quote
The delta was set to 120 to allow Microsoft or other vendors to build finer-resolution wheels (a freely-rotating wheel with no notches) to send more messages per rotation, but with a smaller value in each message.
I have one of those mice (mouses?). If I scroll 1 notch, HIWORD(wParam) will be 112. It is then rounded down to 0 when it is divided by 120. Consequently in SFML I get lots of sf::Event::MouseWheelMoved with event.mouseWheel.delta equaling 0. When scrolling very fast so Windows reports scrolldistances bigger than 112 it sort of works.
Quick workaround:
Change the offending line to
Quote
event.mouseWheel.delta = static_cast<Int16>((HIWORD(wParam)) + 60) / 120;
That way at least the scrolling sort of works.
Real solution:
Change the type of event.mouseWheel.delta to float and the line to
Quote
event.mouseWheel.delta = (HIWORD(wParam)) / 120.f;

For extra style points change the magic number 120 to the Windows defined macro WHEEL_DELTA.

PS: How come the forum supports marquee and glow text, but no C++-code tags?

Edit: My recommended quick workaround only works for scrolling up, which is insufficient. New workaround:
event.mouseWheel.delta = (static_cast<Int16>(HIWORD(wParam)) * 3 / 2) / WHEEL_DELTA;
But its still a bad hack.
« Last Edit: December 28, 2013, 11:45:05 pm by nwp »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Bugreport: Scrollwheel does not work properly under Windows
« Reply #1 on: December 28, 2013, 11:39:07 pm »
PS: How come the forum supports marquee and glow text, but no C++-code tags?
There is, you just shouldn't look for a button, but instead use the drop down menu on the right side or simply write [ code=cpp ]My Code[ /code ]. ;)

Which mouse of yours has such issues?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nwp

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Bugreport: Scrollwheel does not work properly under Windows
« Reply #2 on: December 28, 2013, 11:49:43 pm »
Hmm, somehow I missed the Code dropdown thingie.

Which mouse of yours has such issues?
It says Microsoft Wireless Mobile Mouse 1000 Model 1452 on the back. I do not think this is a mouse issue though, its just a disagreement between windows and SFML how mousewheels work.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Bugreport: Scrollwheel does not work properly under Windows
« Reply #3 on: December 29, 2013, 12:46:02 am »
Looks like this is already a known issue: #95

I do not think this is a mouse issue though, its just a disagreement between windows and SFML how mousewheels work.
Yeah just wanted to get some model, so if anyone has a similar mouse, they could test it as well.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Bugreport: Scrollwheel does not work properly under Windows
« Reply #4 on: December 29, 2013, 02:41:52 pm »
Seems to work fine with my Logitech G700 on the latest master, no matter whether the wheel notches are enabled or not I always get at least -1 or +1.