Aggiungi la gestione del joystick per il controllo degli eventi nella finestra di gioco

This commit is contained in:
Matteo Benedetto
2024-12-22 01:14:19 +01:00
parent 4f1b5e963a
commit 36b856e520
+3 -1
View File
@@ -116,8 +116,10 @@ class GameWindow:
elif event.type == sdl2.SDL_MOUSEMOTION:
self.scroll_view((event.motion.x//self.cell_size, event.motion.y//self.cell_size))
elif event.type == sdl2.SDL_JOYBUTTONDOWN:
key = sdl2.SDL_JoystickGetButton(event.jbutton.which, event.jbutton.button)
joystick = sdl2.SDL_JoystickOpen(event.jbutton.which)
key = sdl2.SDL_JoystickGetButton(joystick, event.jbutton.button)
self.key_callback(key)
sdl2.SDL_JoystickClose(joystick)
# Disegna qui gli sprite
self.renderer.present()