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

Add option to disable keybindings when running with display modes #340

Closed
AoifeHughes opened this issue Sep 1, 2024 · 7 comments
Closed

Comments

@AoifeHughes
Copy link

Similar to #339 and #249

Im currently doing some debugging and it's very annoying to have the keybindings affecting the game state when I don't want them to! It would be great to have a simple way to have an SDL or OpenGL window but with the inputs disabled.

@AoifeHughes
Copy link
Author

AoifeHughes commented Sep 1, 2024

Ah, after much digging I've found the '--no-input' flag. But it doesn't solve the problem of still allowing the sending of inputs programatically

@Baekalfen
Copy link
Owner

What would be the point of not allowing inputs from the API? Then the emulator can't do anything?

@AoifeHughes
Copy link
Author

Because you might want visuals and realtime interactions but don't want the default keyboard inputs at all. Like semi supervised learning for example!

Say I want to use space bar to interrupt and take control it doesn't easily allow you to do that and record your own button pushes. The current implementation of pyboy allows for weird problems where you get double inputs if controlling the game programmatically and pressing keys, because you can't filter them without changing sdl plugin.

@Baekalfen
Copy link
Owner

Sounds like a too specific use-case to have built-in. You can come and join the Discord server if you want to discuss solutions.

@AoifeHughes
Copy link
Author

The solution is fairly straight forward, it would be altering this function to not be hardcoded:
https://github.com/Baekalfen/PyBoy/blob/master/pyboy/plugins/window_sdl2.py#L101

Having a config json or something for the button press mapping (which could also be blank) would solve #339 and #249 too.

Sorry, I don't use discord, I prefer doing OS work in the most accessible places :)

@Baekalfen
Copy link
Owner

I'm offering you to come to Discord if you want any further help. I can't help everyone 1:1 on here.

Also, others on Discord have used the API to implement more or less what you're asking for.

@AoifeHughes
Copy link
Author

if anyone stumbles across this in the future you can just monkey patch and it avoids a lot of issues that occur from the global use of SDL events

import pyboy.plugins.window_sdl2 as window_sdl2


# Monkey patch the event pump to avoid the double reading of events
def dummy_event_pump(events):
    return events


def apply_monkey_patch():
    window_sdl2.sdl2_event_pump = dummy_event_pump

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