I understand and this is certainly an good alternative. The only think I don't like is overhead of creating all the wrapper methods each of the on_*, then setting each into the array. I'm certainly going to keep your suggestion in mind, in the event that I run across a problem doing it the other way:


#define KB_ESC 1 // esc;
#define KB_1 2 // 1;
#define KB_2 3 // 2;
...
function init_key_map()
function save_key_map()
function restore_key_map()
function map_key(int scode, function* func)
function handle_keys(int scode);

function* key_map[88]; // main map
function* key_map_cache[88]; // temp store to restore main map
...
function init_key_map()
{
int i;
for( i = 0;i < 89; i++)
{
current_key_mapping = NULL; // NULL;
}
}

function save_key_map()
{

int i;
for( i = 0; i < 89;i++)
{
key_map_cache = key_map;
}
}

function restore_key_map()
{
int i;
for( i = 0; i < 89; i++)
{
key_map = key_map_cache;
}
}

function map_key(int scode, function* func)
{
if (scode > 0 && scode < 89)
{
key_map[scode] = func;
}
}

function handle_keys(int scancode)
{
function* handler = key_map[scancode];
if ( handler != null ) handler();
}

on_anykey = handle_keys;

save_key_map() allows you to backup gaming key mapping in the event that you want to change the mapping while in a menu. When leaving the menu, restore_key_map() could be called to reset gaming keys. Setting a key event would be done with a call like, map_key(KB_1, myFunct).