Skip to content

Conversation

@LiquidityC
Copy link
Member

@LiquidityC LiquidityC commented Jan 23, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed keyboard input handling to ignore repeated key-press events, preventing unintended duplicate key triggers and ensuring consistent command execution.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Modified SDL key-down event handling in the input subsystem to filter out repeat events by checking the event->key.repeat flag. This ensures only initial key presses trigger state updates for modifier keys and device type detection, preventing duplicate key-press signals from auto-repeat.

Changes

Cohort / File(s) Summary
SDL Key-Down Event Filtering
src/input.c
Added conditional check to require event->key.repeat == false for key-down event processing, preventing auto-repeated key signals from updating mod-key state and device type

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A key pressed once, not thrice in haste,
The repeat flag cast aside with grace,
Input streams now clean and neat,
Each keystroke counted once complete!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Disables keyboard key repeats' directly and clearly describes the main change: suppressing repeated key-press signals in SDL key-down handling by checking the repeat flag.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LiquidityC LiquidityC enabled auto-merge (squash) January 23, 2026 08:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/input.c (1)

202-209: Change is correct, but tests break due to uninitialized repeat field.

The logic to filter out auto-repeat events is sound. However, the test in test/test_input.c (lines 30-34) constructs an SDL_KeyboardEvent without initializing the repeat field:

SDL_KeyboardEvent event;
event.type = SDL_EVENT_KEY_DOWN;
event.scancode = SDL_SCANCODE_W;
event.key = SDLK_W;
event.mod = SDL_KMOD_NONE;
// event.repeat is uninitialized - contains garbage

Since the code now checks !event->key.repeat at line 202 but the test provides undefined values, the test will fail unpredictably.

Fix: Initialize the repeat field or zero-initialize the struct:

SDL_KeyboardEvent event = {0};
event.type = SDL_EVENT_KEY_DOWN;
event.scancode = SDL_SCANCODE_W;
event.key = SDLK_W;
event.mod = SDL_KMOD_NONE;

@LiquidityC LiquidityC merged commit 23e75b5 into dev Jan 23, 2026
11 checks passed
@LiquidityC LiquidityC deleted the fix/disable_keyboard_key_repeat branch January 23, 2026 08:56
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