Search code examples
pythonpython-3.xpygameps4

Pygame .rumble() function not working via BlueTooth


I'm new to pygame. I need to make a DualShock 4 controller rumble via BlueTooth. I know that the .rumble(low_frequency, high_frequency, duration) makes the controller rumble, and it works for me, but only when I connect my DualShock4 via USB. When I connect it with BlueTooth, the function returns False, and it doesn't work. Why is this, and how do I fix it, if possible? I am on Windows 11, and all my bluetooth drivers are up to date.


Solution

  • I found the solution. If I add these two lines of code:

    import os
    os.environ['SDL_JOYSTICK_HIDAPI_PS4_RUMBLE'] = '1'
    

    The rumbling works, even via BlueTooth. Check this Reddit answer for more details: https://www.reddit.com/r/pygame/comments/12twl0e/cannot_rumble_dualshock_4_via_bluetooth_in_pygame/