E
E
ehita2022-03-10 21:30:06
pygame
ehita, 2022-03-10 21:30:06

How to implement emulation of cursor movement with a gamepad?

It is necessary to implement smooth movement of the mouse cursor with a gamepad, but the only solution that I found on the Internet is the pyautogui library, but using this library, the cursor moves intermittently, slowly and only up or to the side, there may be some other solutions or you can somehow speed up the code so that the cursor moves smoothly?
I also use the pygame library to track the joystick.

def tracking_sticks(event):
    move_curs = [0, 0]
    if event.type == pygame.JOYAXISMOTION:
        if event.axis < 2:
            move_curs[event.axis] = event.value
            pyautogui.move(move_curs[0] * 10, move_curs[1] * 10)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question