Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Fix IsKeyPressedRepeat() for PLATFORM_DESKTOP_SDL #3605

Merged
merged 2 commits into from Dec 7, 2023
Merged

[rcore] Fix IsKeyPressedRepeat() for PLATFORM_DESKTOP_SDL #3605

merged 2 commits into from Dec 7, 2023

Conversation

ghost
Copy link

@ghost ghost commented Dec 5, 2023

Changes

  1. Fixes IsKeyPressedRepeat() for PLATFORM_DESKTOP_SDL by adding the missing CORE.Input.Keyboard.keyRepeatInFrame handling to PollInputEvents() (R1097).

  2. Removes a duplicated reset loop (L972-L973) that's already present a few lines ahead (R1003-R1006).

Code example

#include "raylib.h"

int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {
        BeginDrawing();
        ClearBackground(RAYWHITE);

        if (IsKeyPressedRepeat(KEY_ONE)) {
            DrawText("1 is repeat", 20, 20, 20, BLACK);
            TraceLog(LOG_INFO, "1 is repeat");
        }
        if (IsKeyPressedRepeat(KEY_TWO)) {
            DrawText("2 is repeat", 20, 40, 20, BLACK);
            TraceLog(LOG_INFO, "2 is repeat");
        }

        EndDrawing();
    }
    CloseWindow();
    return 0;
}

Environment

  • Tested successfully on Linux (Mint 21.1 64-bit) with SDL2 (2.28.4).

Edits

  • 1: added line marks.
  • 2: correction.

@raysan5 raysan5 merged commit d99617d into raysan5:master Dec 7, 2023
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Dec 7, 2023

@ubkp thanks for the review and excuse the late response, I'm working on the land picking up olives this week and I'm a bit disconnected from the computer...

@ghost
Copy link
Author

ghost commented Dec 7, 2023

@raysan5 No problem, don't worry about it. Hope you can get some good rest after. Best of luck. 👍

@ghost ghost deleted the fix/sdl-keyrepeat branch December 7, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant