Open fabriciopirini opened 3 years ago
Have you considered creating a thread responsible for sending device events (device.input_swipe
) that reads a global state, like:
class State(enum.Enum):
IDLE = 0
MOVE_DOWN = 1
# ...
QUIT = N
and then just update the global state from the callback? The thread body would be a simple while STATE != State.Quit
-loop.
And your problems with mouse events seem strange, since keyboard events require even more privileges. Do you have a stack trace or other information? Or do you simply not receive any events?
Thanks for the reply! I will soon try again to use pyinput
and I will try out your approach and post the feedback here.
I don't have any stack trace, no events were coming indeed so I believe Mac was swallowing them.
To investigate the missing events, you might want to add some debug logging here.
Hi! I'm trying to translate keyboard keys to joystick movements on an emulator screen (BlueStacks) on my Mac Catalina.
What I'm trying to achieve is to keep the movement until the key is released so I decided to create a loop to repeat the movement until the key is released. However, the loop is blocking the Thread so I can't accomplish that easily. I tried then to create 2 Threads, 1 for
on_press
events and another foron_release
events but that don't work either since I always getAttributeError
s from theobjc
for any key I press.Part of my code:
Thanks for any help and directions =)
Disclaimer: I tried to use
pyinput
for mouse events but I couldn't make it work on my Mac, even allowing my terminal and IDE on Accessibility (couldn't auth Python) and running withsudo
so I'm using ADB.