zeth / inputs

Cross-platform Python support for keyboards, mice and gamepads
BSD 3-Clause "New" or "Revised" License
269 stars 87 forks source link

get_mouse blocks before first execution #69

Open frastlin opened 5 years ago

frastlin commented 5 years ago

Problem

def run():
    events = get_mouse()
    for event in events:
        print(event.__dict__)

    while True:
        run()
        print("new loop")

With the above code, "new loop" will not print until after the first event is triggered.

What should happen

"new loop" should print when the application starts and continue printing until the application stops. If one does get_key with the above code, the proper result happens.

Other Information

OS: Windows 10 64 bit python 3.6

frastlin commented 5 years ago

Hello, So after looking at the code, the problem is around line 2609 on the last line of the _get_data function:

def _get_data(self, read_size):
    """Get data from the character device."""
    if NIX:
        return super(Mouse, self)._get_data(read_size)
    return self._pipe.recv_bytes()

Something is going on with the pipe for mouse events that keeps the process from exiting before a mouse event happens for the first time. The process also freezes again after the app has been running for a while.

ErikOrjehag commented 4 years ago

Hey! Look at issue #7 , I found a solution that worked for me