- Home /
Is it possible to distinguish between mouse and trackpad scroll?
Is it possible to determine whether the user is using a laptop trackpad or a mouse scrollwheel when using Input.GetAxis("Mouse ScrollWheel")?
For whatever reason, using two fingers to scroll on a MacBook Pro trackpad is much more sensitive than using the scrollwheel on a mouse.
It would be great to be able to use a different speed factor for Mac trackpad input.
Answer by TheOfficialSkara · Sep 08, 2016 at 04:23 AM
I realize I am nearly 5 years late, but the answer could still be relevant to developers today.
Unfortunately there is no apparent way to distinguish between the two inputs on Mac, as the Input.GetAxis(), Input.mouseScrollDelta, and Event.current.delta methods of receiving scroll delta are all equivalent.
However on Windows there is the following solution:
Since Input.mouseScrollDelta doesn't pick up on a touchpad scroll and Event.current.type (in the OnGUI method) does, you can detect this and handle them independently.
void OnGUI () {
if (Event.current.type == EventType.ScrollWheel) {
if (Input.mouseScrollDelta.y == 0) {
// Handle touchpad scroll using Event.current.delta.y
} else {
// Handle mouse scroll using Input.mouseScrollDelta.y
}
}
}
Hi! Noticed the same issue on Unity 5.3.5p7. "Input.mouseScrollDelta" or using "$$anonymous$$ouse ScrollWheel" axis doesn't pick up input from laptop trackpad. $$anonymous$$ust be a Unity bug.
Bless you for sharing this. Despite the fact I would consider this to be a (pretty serious) bug, three years later, developers still have to handle all of their mouse events twice. This information was also REALLY hard to find, since so many people are asking questions about the janky mouse handling in Unity.
Answer by d1favero · Dec 15, 2011 at 06:06 PM
Nobody knows how???
I would not consider that an answer.
Please use comments unless you have a solution.
That way you don't get peoples' hopes up...
Answer by Robotron18 · Nov 25, 2014 at 11:23 AM
Try to resolve in WinAPI. But system see trackpad like a mouse.
[DllImport("user32.dll", SetLastError = true)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
bool fResult;
IntPtr aMouseInfo;
void Start()
{
fResult = SystemParametersInfo(0x101E, 0, aMouseInfo, 0);
if (fResult)
{
print("Info: " + aMouseInfo);
}
}