Closed fpiesik closed 9 months ago
Sounds like your program is returning keycodes (https://wiki.libsdl.org/SDL2/SDLKeycodeLookup) while the config uses scancodes (https://www.freepascal-meets-sdl.net/sdl-2-0-scancode-lookup-table/)
That's it - thank you!
I've written a small Python program using Pygame to identify the SDL keycodes of keyboard keys. My goal is to remap the keyboard. However, I've noticed a discrepancy between the keycodes generated by my program and those listed in a config file.
For instance, in my program, the "space" key (which I intend to map to "start") returns an SDL keycode of 32. However, in the config.ini file, "start" is associated with either 44 or 27. Clearly, there's a mismatch, and I'm unsure about the cause.
Here's the code for my program:
import pygame pygame.init()
screen = pygame.display.set_mode((400, 300)) pygame.display.set_caption("SDL Keycode Lookup")
running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: print(f"Key pressed: {pygame.key.name(event.key)}") print(f"SDL Keycode: {event.key}") print("-------------------------------")
pygame.quit()
I would appreciate any insights or suggestions on what might be causing this discrepancy and how to resolve it.