Skip to content

Document SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS environment variable. #2962

@KingOfIce77

Description

@KingOfIce77

Hijacking top post for tasks:

  • Add environment variable to pygame module docs with the other environment variables
  • Add note about current behaviour (defaults to no joystick events for apps without focus) to joystick module introduction somewhere.
  • Nice to have: open a new issue about adding SetSDLHint() & GetSDLHint() (names not final) to new context module.

Windows
Python 3.10
PyGame 2.1.2

I had to go back to version 2.1.0 and it works again : my pygame window that captures all joystick events doesn't capture anything anymore when I switch to another window

Current behavior:

No joystick events catched

Expected behavior:

joystick events catched (wirks on pygame 2.1.0)

code

# Extract from my 2.1.0 working code
pygame.init()

screen = pygame.display.set_mode((200, 200), pygame.NOFRAME)
hwnd = pygame.display.get_wm_info()["window"]
win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 600, 300, 0, 0, win32con.SWP_NOSIZE)
...
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]

for joy in joysticks:
    print(joy.get_name(), joy.get_id(), joy.get_guid(), joy.get_instance_id())
    if joy.get_name() == 'My joystick 1':
        MyJoysticks['My joystick 1']={}
        MyJoysticks['My joystick 1']['joy'] = joy
        MyJoysticks['My joystick 1']['joy'].init()
...
while 1==1:
    ...
    PosJoy1 = MyJoysticks['My joystick 1']['joy'].get_axis(0)
    ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions