Distinguish mouse movement vs touch inputs

In short, my game is designed to be heavily cross platform in that any input method can be used simultaneously. Theoretically, you could have a touchscreen laptop with a controller hooked up to it, giving you four perfectly valid input devices (touch, mouse, keyboard, gamepad).

The problem I am facing is that my implementation for touch-based response and mouse-based response are quite different (which one would expect), but since my game intends to respond to all types of inputs simultaneously, I need to be able to distinguish a mouse movement from someone moving their finger on the screen.

I am using userInputService:GetMouseLocation() to detect mouse position and react accordingly, but when a player tries to input a touchswipe (userInputService.TouchSwipe), the action that is assigned to swipes gets overriden by Roblox thinking that the swipe was the mouse being moved.

I would like a way to be able to make it so GetMouseLocation (or any other function that would act the same) would only respond to inputs which are explicitly computer mice, and not a touchscreen input.

Please help!

1 Like

Never mind, I figured out that I can simply disable the mouse functionality when userInputService.TouchStarted is called. I would still find value in some way to completely distinguish and handle touch and mouse movements separately, which I suppose turns this post into more of a feature request (unless there is some method unknown to me).

2 Likes