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

[core] Fix IsKeyPressedRepeat() for PLATFORM_DRM direct input #3583

Merged
merged 1 commit into from Nov 30, 2023
Merged

[core] Fix IsKeyPressedRepeat() for PLATFORM_DRM direct input #3583

merged 1 commit into from Nov 30, 2023

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2023

Changes

  • Fixes IsKeyPressedRepeat() for PLATFORM_DRM direct input by adding the missing CORE.Input.Keyboard.keyRepeatInFrame to PollKeyboardEvents() (R1712).

Reference

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 on Raspberry Pi 3 Model B 1.2 (2015) with Linux (Raspberry Pi OS 12 Bookworm 32-bit armhf).

Edits

  • 1: added line marks.

@raysan5 raysan5 merged commit bd81bdc into raysan5:master Nov 30, 2023
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Nov 30, 2023

@ubkp thanks for the review!

@ghost ghost deleted the fix/drm-keyrepeat branch November 30, 2023 16:47
@larry104
Copy link

I just compiled against the latest master branch but it seems the fix is not working properly. If I for instance press the down cursor sometimes it does something and sometimes not. Also the repeat interval seem randomly sometimes fast sometimes slow. As I mentioned the repeat works via ssh keyboard even when just using "IsKeyPressed" and it's super reliable.

@ghost
Copy link
Author

ghost commented Nov 30, 2023

@larry104 Just retested it here right now and, for me, it's working exactly like PLATFORM_DESKTOP. See implementation:

PLATFORM_DESKTOP PLATFORM_DRM
set L1699 L1712
unset L1120 L550

I don't think a repeat interval is specified as an option on the current implementation of IsKeyPressedRepeat(): L2669-L2679.

@larry104
Copy link

Maybe it has to do with my app ... it seemed smoother with an ssh keyboard.
Is the IsKeyPressedRepeat supposed to detect also a single press? Or do I need something like this?
if (IsKeyPressedRepeat(KEY_UP) || IsKeyPressed(KEY_UP)) {..}

@ghost
Copy link
Author

ghost commented Nov 30, 2023

@larry104 It's meant to catch key repeats in a single frame (keyRepeatInFrame). Reference/context: #3245, #3248, #3256.

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.

2 participants