How to detect if wheel event is trackpad

when overriding the method juce::Component::mouseWheelMove(…) i try to make a difference between normal computer mouses and trackpads from laptops. in the process of improving my selfmade slider/knob implementation i noticed that trackpads need a different behaviour than mouses. say i have a mouse. ofc i won’t use the exact value from deltaY, but just the fact if it’s bigger or smaller than 0 and multiply 1 or -1 with the desired speed value for that knob. easy. but when i’m on a trackpad deltaY actually gives you valuable information about the step that should be taken, so it would be cool if there was a way to check if the wheel-event comes from a trackpad. is that possible? i thought it would be the isSmooth variable, but it yielded false…

other ideas how to solve this problem are also welcome (except if they are “use juce::Slider”)

void mouseWheelMove(const juce::MouseEvent& evt, const juce::MouseWheelDetails& wheel) override {
            if (evt.mods.isAnyMouseButtonDown()) return;
            const bool reversed = wheel.isReversed ? -1.f : 1.f;
            const bool isTrackPad = wheel.deltaY < .2f; //lmao
            if (isTrackPad)
                dragY = reversed * wheel.deltaY;
                dragY = reversed * WheelDefaultSpeed;
            if (evt.mods.isShiftDown())
                dragY *= SensitiveDrag;
            const auto newValue = juce::jlimit(0.f, 1.f, this->rap.getValue() + dragY);

atm my best idea is to just check if deltaY is smaller than .2 because that seems to be the case usually even when dragging them hard, while normal mouses produce some value a bit higher than that. but i do know that this is no real “evidence” that there’s a trackpad and it would be cool to have a more accurate way to tell. i could also maybe keep track of old deltaY values and just check if they ever change, but i don’t like this idea, because it would mean that i have to keep checking about that and also it would break if 2 consecutive trackpad evts have the same deltaY actually.

edit: isn’t there maybe a way to check how many fingers are currently down to create a certain mouse event? that would be kind of a trackpad check wouldn’t it?

You can get the MouseInputSource from the event using evt.source.

MouseInputSource has an isTouch() method, which I would guess returns true for touchpads?

1 Like

i think that was a good idea, but unfortunately it didn’t work :confused:

so i just found out that juce::MouseInputSource has a method called getType() and it returns an InputSourceType, which can be either mouse, pen or touch. unfortunately none of them detect the existence of a trackpad. but i feel like i’m getting closer to the solution in this area.

edit: lol that’s exactly what the isTouch() method outputs already. that explains why it also didn’t work^^
ok so, i now decided to just ignore this issue for now and use my hacky solution. it would be really cool if the juce team could give a little statement if they aknowledge this as a problem and try to work out a solution tho. trackpads are almost everywhere. juce should definitely reflect that