This is a little different than what the OP is asking but - I programmed an Xbox controller so that its buttons can act as left and right mouse buttons. This helps relieve fatigue in my right hand when I am working on mouse-intensive CAD work like laying out circuit boards etc.
Write-up here : https://iskender.ee/2020/12/27/Dual-Mouse.html