I am currently trying to implement a 360 degree direction listener of mouse inputs and print these to the terminal (long term is plotting these inputs). Looking to get advice on what libraries people are using and the best implementation you all have had with it.
I have been able to get mouse position through Pyautogui to out put position but not direction.
I have been able to implement cardinal directions with pynput.mouse but doing it in 360 degrees continues to be a problem.
You would need two mouse positions to be able to get a direction.
If you have two mouse positions (x1, y1) and (x2, y2) then you can infer the direction with this function:
def get_angle(x1, y1, x2, y2):
# Calculate the angle of movement in radians
angle_rad = math.atan2(y2 - y1, x2 - x1)
# Convert the angle to degrees
angle_deg = math.degrees(angle_rad)
return angle_deg