# Input: Buffered/Unbuffered or Both?

## Recommended Posts

I've read that unbuffered input is best for controlling the gameplay parts of a game and buffered is best for things like text entry and GUI systems - because input may not be retrieved until several frames later. However what if I run an input loop during each iteration of the game loop where I handle all of the buffered input before continuing with the game loop e.g.
while(game_running)
{
while(input_available)
process_input();

//...
}


Surely this would work just as good as unbuffered/immediate input? Or would I be better off switching to unbuffered input during gameplay sections and using buffered input only in menu screens and such?

##### Share on other sites
It's no longer recommended to use DInput for text entry for a variety of reasons. Use unbuffered to get the current state of keys for gameplay, and use windows messages (WM_CHAR, and things like that) for text input.

Many languages have accent characters, and it's often entered as a special first key-press to select an accent, followed by a second press to choose the letter, like these. In DInput you'd have to handle all this yourself, hope you got everything, for every language, etc. Instead you can just have Windows handle it like it does for every application, and tell you the fully qualified character at the end.

It will also take into account different keyboard layouts, such as French or German, which may use different scan codes (what DInput uses) for fairly standard keys. It will also allow you to use a completely different keyboard layout such as dvorak.

In short, DInput is not for text if you care about your users.

##### Share on other sites
Eek, yeah it sounds as though it would get extremely nasty trying to use DInput for text entry! I'll make use of WM_CHAR to handle that sort of stuff then. Thanks.