The screen keeps flickering when I tried to catch joystick operations

OS: Windows 11
Psychopy version: 2023.2.3

As the ducument (joystick (pyglet and pygame) — PsychoPy v2024.1.1) said, when trying to catch the operations of a joystick, the win.flip() method must be in the while circuit.
Here was part of my code:

...
        self.states_before = [False] * len(self.js.getAllButtons())
        update = None
        while True:
            states_current = self.js.getAllButtons()
            for i, (j, k) in enumerate(zip(states_current, self.states_before)):
                if (j) and (not k): #press a button once
                    update = True
                    self.states_before[i] = True
                    if ... #some operations on the joystick and visual changes
                    elif ... #some operations on the joystick and visual changes
                    else: #some operations on the joystick
                        self.win.flip(clearBuffer=False) # no need to change visual stims
                elif (k) and (not j): #keep pressing a button
                    update = False
                    self.states_before[i] = False

            if update:
                ... # draw the visual changes in the buffer.
                win.flip()
            else:
                self.win.flip(clearBuffer=False) #THIS IS WHERE MY PROBLEM IS!!!

            core.wait(0.01)

If there’s no else: self.win.flip(clearBuffer=False) , any operations on the joystick will not work; but when the two lines exists, my screen keeps flickering because of frequent .win.flip() method (100times/s).

How can I solve this paradox?
I really don’t want to use while...win.flip() to catch operations on the joystick.

(I can run the experiment normally with a KEYBOARD version of this experiment because catch the keyboard event does not rely on while...win.flip() . But I have to use joysticks in a 2-person experiment.)

OK, finnaly I found a not-so-elegent resolution:

creat an extra window_trash = visual.Window() object to excute windows_trash.flip() to get the states of a joystick…

Minimize this window manually before the experiment begins, that’s my relosution.