Fix joystick initialization and update button press handling in KeyLogger
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user