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;
else
dragY = reversed * WheelDefaultSpeed;
if (evt.mods.isShiftDown())
dragY *= SensitiveDrag;
const auto newValue = juce::jlimit(0.f, 1.f, this->rap.getValue() + dragY);
this->attach.setValueAsCompleteGesture(this->rap.convertFrom0to1(newValue));
}
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?