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

usbkeyboard: fix double printing of input #20

Merged
merged 5 commits into from
Jan 19, 2025

Conversation

jamesy0ung
Copy link
Contributor

See issue: #19

The previous implementation caused duplicate character output due to both the keyPress_cb function and the main loop handling keyboard input. The keyPress_cb function directly printed characters, while the main loop read and reprinted them using getchar().

Now, the main loop uses non-blocking getchar() for centralized character handling, ensuring controlled output of printable and newline characters. The keyPress_cb function handles the escape key to exit the application.

Key changes:

  • Removed putchar() calls from keyPress_cb in usbkeyboard.c.
    
  • Updated the main loop in usbkeyboard.c to manage character printing centrally using non-blocking getchar().
    

@DacoTaco
Copy link
Member

Hey!
thanks for the fix!

sorry i didn't reply sooner, been a bit busy.
would you mind rechecking the change and checking the space/tabs? the PR is changing way too much on first look :)

@jamesy0ung
Copy link
Contributor Author

Try the latest commit, I clang-formatted it to tabs :)

@DacoTaco
Copy link
Member

thanks for that! much better changelog and easier to review :)
its a very minor nitpick but i would have kept the original keyboard cb, but move the exit to the main loop.
isn't that possible/better?
shows the usage of the cb (and putchar) and the check for esc as exit

@jamesy0ung
Copy link
Contributor Author

I have moved the exit check to the main loop.

A side effect, is that since the character print occurs before the exit check, an arrow is printed to console when esc is pressed.

@DacoTaco DacoTaco merged commit a9cf53f into devkitPro:master Jan 19, 2025
@DacoTaco
Copy link
Member

fix merged! thanks for your effort! ^^

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