using a magic data only entity will work just fine.
entity
{
"name" "UserInput"
"prevTime" "3.24"
"curTime" "3.38"
"time3.24"
{
"keyPressed"
{
"keyCode" "KEY_A"
"doubled" "false"
"repeated" "false"
}
}
"time3.38"
{
"keyPressed"
{
"keyCode" "KEY_A"
"doubled" "false"
"repeated" "false"
}
}
"isDown"
{
"KEY_A" "false"
"KEY_B" "false"
}
}
you could do it for platform info too.
you can also do the same with key mapping too.
entity
{
"name" "KeyMapping"
"forward"
{
"KEY_W"
"KEY_UP"
}
"backward"
{
"KEY_S"
"KEY_DOWN"
}
}
in theory you don't even have to write a keymapping class, but it might be a better idea. otherwise it is a bunch of verbose code. the keymapping class can also put the data in a real map. however, keyvalue should probably be implemented as a real map anyway.
gbKeyValue* kv_forwardp=getKeyValue("KeyMapping.forward");
for(int i=0;i
{
gbKeyValue* kv=kv_forward->_childs[i];
}
that is just half of it.
a better plan might be to pipe the input directly into the input class and just fire any listeners right then. the problem is it is a bit random, but oh well. the programmer will just have to understand that.
so have a gbGameInput class that exists in the entity database as GameInput. this class gets piped the input from the editor. any other entity can add itself as a listener to that entity and the connections will magically be persisted. when input comes in it just gets fired directly to the entity via a setValue you something.