Mouse hovering up and down on its own

My mouse keeps hovering up and down like every 5 seconds and it’s making the game unplayable. This is also happening to me in my PreSequel. I’m in Ubuntu 16.10 and I’m using Logitech g502 mouse. Hope anyone can help