how can i write a code that reads from an xml file what key i must press for what action
greets Morph
key input & XML
Hi,
Reply is a bit late, but anyway:
There is plenty of documentation and examples how to read from an xml file. For mapping key input to desired action you might do something like this:
Reply is a bit late, but anyway:
There is plenty of documentation and examples how to read from an xml file. For mapping key input to desired action you might do something like this:
Code: Select all
//pseudo code
struct map {
key irr::u8;
function irr::u16;
};
core::array<MyMap> map;
init()
{
map tmp;
while (not end of xml)
'read from xml file here into tmp
map.push_back(tmp)
};
irr::u8 get key pressed()
// some funtion to translate enum into u8
// maybe use number value associated wih Irrlicht enum EKEY_CODE to keep it simple
//inputreceiver
bool OnEvent(SEvent event)
{
irr::u8 key = get key pressed();
for(irr::u16 i=0; i<map.size(); i++)
{
if (map[i].key == key)
{f = map[i].function; break;}
}
switch (f)
case 1 : do_action_1;
case 2 : do_action_2;
case n : do_action_n;
}