Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate/script keystrokes user input for running games #228

Open
emma-makes opened this issue May 8, 2022 · 2 comments
Open

Automate/script keystrokes user input for running games #228

emma-makes opened this issue May 8, 2022 · 2 comments

Comments

@emma-makes
Copy link

I'm writing a bot to automate some movement with a python script in a running rom. I'm using RetroPie/Emulationstation to run lr-gambatte and those projects do not rely on X11. Most libraries to emulate a virtual keyboard input don't work.

The following python3 script (using uinput, https://github.com/tuomasjjrasanen/python-uinput) works in the emulationstation menu, but doesn't in game (lr-gambatte). I start the script via SSH as root.

Does anyone have an idea, how to send/emulate keystrokes via a python script that is started via SSH? I'm not opposed to switching the script language.

import time
import uinput

def main():
    events = (uinput.KEY_LEFT, uinput.KEY_DOWN, uinput.KEY_D)

    with uinput.Device(events) as device:
        time.sleep(1)
        device.emit_click(uinput.KEY_LEFT)
        time.sleep(0.2)
        device.emit_click(uinput.KEY_D)
        time.sleep(0.2)
        device.emit_click(uinput.KEY_DOWN)
        time.sleep(0.2)

if __name__ == "__main__":
    main()
@cyberic99
Copy link

@emma-makes this project https://github.com/jkotlinski/lsdpack uses libgambatte and sends keystrokes to a headless stripped down gambatte.

not sure it will fit your needs

@emma-makes
Copy link
Author

@emma-makes this project https://github.com/jkotlinski/lsdpack uses libgambatte and sends keystrokes to a headless stripped down gambatte.

not sure it will fit your needs

Thank you for bringing this to my attention. That might be a crude hack, but I'll keep it in mind as a last resort approach. I hope to find a scriptable library designed to send keyboard input, which is accepted by retroarch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants