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

Author Topic: MouseWheelEvent with Trackpad, delta = 0 ?  (Read 1392 times)

0 Members and 1 Guest are viewing this topic.

Nafffen

  • Newbie
  • *
  • Posts: 15
    • View Profile
MouseWheelEvent with Trackpad, delta = 0 ?
« on: August 20, 2022, 11:59:01 pm »
Hello everyone,

I'm using SFML on Windows 10 with my laptop and I use a trackpad to move my mouse.

When it comes to MouseWheelEvent (sliding two fingers on the trackpad), the delta member is most of the time 0 which is quite disturbing for me.
Btw if I slide quickly, the delta is about +-5 and there is an inertie towards 0 (I assume it's device/system dependent) and I'm ok with that.

Edit: I noticed when you zoom with trackpad (two fingers get closer) it triggers MouseWheelEvent with a decent delta as expected. The issue is really focused on sliding two fingers (up/down) on the trackpad

Why the delta stays at 0 if the user inputs natural movement ? How can I handle it ?

Thank you
« Last Edit: August 21, 2022, 10:33:10 pm by Nafffen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: MouseWheelEvent with Trackpad, delta = 0 ?
« Reply #1 on: August 22, 2022, 03:15:00 am »
SFML just provides what the OS event is reporting. Might want to double check the installed driver for your trackpad and see if there's something you can/need to adjust.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kojack

  • Sr. Member
  • ****
  • Posts: 300
  • C++/C# game dev teacher.
    • View Profile
Re: MouseWheelEvent with Trackpad, delta = 0 ?
« Reply #2 on: August 22, 2022, 03:56:32 am »
There are two things that come to mind.
1 - Are you checking which direction the scroll is? A trackpad can do horizontal and vertical scrolling. SFML tells you which it is in the wheel member of the mousewheelscroll event. Maybe you are getting some horizontal events mixed in.
2 - Are you looking at the delta directly, or storing it in a variable first? For my Surface Pro, the delta from the trackpad scroll is very small, around 0.008 to 0.1 for average scrolling. If you grab it into an int, you won't see anything besides fast (over 1) scrolls.


Nafffen

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: MouseWheelEvent with Trackpad, delta = 0 ?
« Reply #3 on: August 22, 2022, 09:49:46 am »
1. Well spotted, I didnt try horizontal scrolling, with my trackpad it doesnt trigger the MouseWheelEvent event

2. I simply printed out the delta attribute of sf::Event::MouseWheelEvent Struct (https://www.sfml-dev.org/documentation/2.5.1-fr/structsf_1_1Event_1_1MouseWheelEvent.php), indeed it's a int. Where did you get from the float value ?

kojack

  • Sr. Member
  • ****
  • Posts: 300
  • C++/C# game dev teacher.
    • View Profile
Re: MouseWheelEvent with Trackpad, delta = 0 ?
« Reply #4 on: August 22, 2022, 11:27:37 am »
MouseWheelEvent is deprecated.
I used the newer MouseWheelScrollEvent, it has a float delta and the type of the wheel (horizontal or vertical).

Nafffen

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: MouseWheelEvent with Trackpad, delta = 0 ?
« Reply #5 on: August 22, 2022, 01:06:31 pm »
My bad I didn't see
solved thank you very much c: