From 5e0f375948f7b5ab81089a58c9f8c263bbdac992 Mon Sep 17 00:00:00 2001 From: Matteo Benedetto Date: Tue, 19 Aug 2025 16:19:59 +0200 Subject: [PATCH] Fix joystick initialization and update button press handling in KeyLogger --- key.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/key.py b/key.py index d681655..59d1c0d 100644 --- a/key.py +++ b/key.py @@ -12,6 +12,8 @@ class KeyLogger: # Initialize joystick support sdl2.SDL_Init(sdl2.SDL_INIT_JOYSTICK) sdl2.SDL_JoystickOpen(0) + sdl2.SDL_JoystickOpen(1) # Open the first joystick + sdl2.SDL_JoystickEventState(sdl2.SDL_ENABLE) self.window = sdl2.ext.Window("Key Logger", size=(640, 480)) self.window.show() self.running = True @@ -37,7 +39,7 @@ class KeyLogger: elif event.type == sdl2.SDL_JOYBUTTONDOWN: button = event.jbutton.button self.message = f"Joystick button {button} pressed" - if button == 0: # Assuming button 0 is the right trigger + if button == 9: # Assuming button 0 is the right trigger self.running = False elif event.type == sdl2.SDL_QUIT: self.running = False