Baekalfen / PyBoy

Game Boy emulator written in Python
Other
4.57k stars 472 forks source link

Change keybindings for sdl2 #289

Closed tk744 closed 1 month ago

tk744 commented 9 months ago

Added feature to change the sdl2 keybindings as suggested by this issue.

Usage:

from pyboy.plugins.window_sdl2 import set_keybinding

set_keybinding(sdl2.SDLK_w, WindowEvent.PRESS_ARROW_UP, WindowEvent.RELEASE_ARROW_UP)
set_keybinding(sdl2.SDLK_s, WindowEvent.PRESS_ARROW_DOWN, WindowEvent.RELEASE_ARROW_DOWN)
set_keybinding(sdl2.SDLK_a, WindowEvent.PRESS_ARROW_LEFT, WindowEvent.RELEASE_ARROW_LEFT)
set_keybinding(sdl2.SDLK_d, WindowEvent.PRESS_ARROW_RIGHT, WindowEvent.RELEASE_ARROW_RIGHT)
Baekalfen commented 9 months ago

Thank you for your PR! I'll have to consider it. I would have preferred if it was a generic solution for OpenGL and a future window type too, but I don't have a good idea on how to do it. Problem is that once it's in, I'll have to keep supporting it going forward.