Hi,
Currently, the lwjgl Keyboard class regards the keyboard as one big gamepad. That is, you can query the up/down state of a key or ask the class to stream keyboard events to a buffer that can be emptied every frame or when keyboard input is needed. So when in buffered mode, a raw user key press/release event is recorded to a buffer and stored for the game to read when ready.
The nice thing about regarding the keyboard as a gamepad is that arcade/action games are easily implemented and with minimal overhead. Games like Quake, Tetris and the like, where only key states matters. The bad is that chat-based games are not easily implemented. Games like Warcraft, Sims etc. where text input is required from the user and not just key presses/releases.
The current approach is just to use the Keyboard.map method that supplies a crude form of static key->ascii char mapping. This way, the keyboard is always mapped according to a US keymap, so international letters (like the danish æøå), accented letters (é, ñ) and to a certain degree even modified letters (shift+a->‘A’) are not possible under the current scheme.
To keep the arcade style keyboard for those who prefer that, I propose we add another buffer to Keyboard class that is enabled through a Keyboard.enableTranslation() call. Enabling the translation buffer will require that the event buffer is enabled. When the translation buffer is enabled, every key press/release event is still recorded to the event buffer as normal, but additionally the events are translated to character whenever possible and placed on the translation buffer to be read from the game and used when clear text is required.
So a key event buffer that looks like
[shift down][a down][a up][shift up][; down][; up][’ down][’ up][e down][e up][esc down][esc up][shift down]
Will result in the translation buffer on a Danish keymapping being filled with:
“Aæé”
The last shift event cannot be translated in itself, so it has to stay in the buffer when the next read() is performed. That is, every event that cannot be fully translated will be copied to the beginning of the event buffer. Of course the index that marks the next key pressed/released event to be read by the game will have to be adjusted so no raw events are read more than once.
The esc key cannot be translated so it is ignored by the translation and can only be detected if the game reads the raw event buffer.
- elias