Skip to content

usbkeyboard: fix double printing of input#20

Merged
DacoTaco merged 5 commits into
devkitPro:masterfrom
jamesy0ung:master
Jan 19, 2025
Merged

usbkeyboard: fix double printing of input#20
DacoTaco merged 5 commits into
devkitPro:masterfrom
jamesy0ung:master

Conversation

@jamesy0ung

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@DacoTaco

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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