mgba does not allow background input
SpectralGrim opened this issue · 3 comments
I tried to run a pyautogui script on my raspberry pi 5 togehter with mgba, so I built a listener to catch the evdev event when I press a specific button on my controller to execute the pyautogui script when I'm playing on mgba. But if I use the controller with mgba active, the input gets not recognized by the listener because the input is not shared to the listener, as it is not a background input, but only recognized by mgba.
So what I want to do is simple: Press Y button on my controller, fullfill some automated steps in the game
AND use the controller also to control the game
pyautogui script:
import pyautogui
import time
pyautogui.press('f1')
time.sleep(4)
pyautogui.press('s')
time.sleep(3)
pyautogui.press('a')
time.sleep(3)
pyautogui.press('a')
listener script
import evdev
from evdev import InputDevice, categorize, ecodes
import subprocess
device = InputDevice('/dev/input/event11')
print(f"Listening for button press on {device.path}...")
BUTTON_CODE = 308
script_path = "/home/grim/Downloads/pyautogui shiny reset.py"
for event in device.read_loop():
if event.type == ecodes.EV_KEY:
key_event = categorize(event)
if key_event.scancode == BUTTON_CODE and key_event.keystate == key_event.key_down:
print(f"Button {BUTTON_CODE} pressed, executing script...")
subprocess.run(["python3", script_path])
So is the problem that the controller is not recognized by mGBA while mGBA is not active? You have a run-on sentence trying to explain what the problem is, and I'm not able to follow.
If that's the case, that seems strange considering #1378 and #2169 both exist, one for keyboard and one for controller.
When mGBA is active, inputs into mGBA are only known by mGBA, but there is no throughput to os.
mGBA is using all ressources of a controller when mGBA is active.
It's the opposite issue of #1378
Userstory:
I want to use my xbox controller to play on mGBA, but I also want to map the Y-Button of the same controller to another application and control both applications at the same time. When mGBA is active, you can not use a button of the same controller for another application at the same time, because the input from the controller is not a background input to os.
It would be awesome to have a checkbox to allow other inputs to other applications while mGBA is active for 0.12.0 Milestone
Keep up the good work.
The reason my pyautogui script isn't working with mgba is that pyautogui operates by simulating higher-level inputs through the operating system's graphical user interface (GUI). These inputs are not recognized as direct inputs at the hardware level, which is what mgba expects when running.