Unifying key input

nobody wrote on Wednesday, July 05, 2006:

Hi everyone!

I’ve been working with GLFW in D for a while now and while building keyboard support for my higher level framework I’ve stumbled on a problem.

What I want is to unify the receival of key inputs and character inputs in my API. I thought of doing somekind of buffered input where the user can loop thought every input event that have come since the last poll/loop.

I want the user to be able to use the integer key and its character representation with all possible modifiers. Is this feasible? Or should I try to think of a different scheme?

The usage could be something like this:

if (Keyboard.getNumberOfKeyEvents() > 0) {
while(Keyboard.getNextEvent()) {
doSomethingWithKey(Keyboard.getEventKey());
doSomethingWithChar(Keyboard.getEventCharater());
}
}

I’m also toyed with a full event based system idea, but haven’t tried it yet because I don’t know how well it would fit in a game loop.

Cheers,
Odeamus