I thought a bit about the possibility you speak of... multiple key mapping sets.

I had out-of-town guests and wasn't able to post another correction. I found another problem with the size specified for the arrays, which ripple down to the conditions tested. I noticed that your code is using the incorrect 88, which wouldn't include the mouse and joystick scancodes. The size of the arrays should be 116 as opposed to the earlier correction I made of 115. I noticed that your code is using the incorrect 88, which wouldn't include the mouse and joystick scancodes. If one did want to just include the keyboard, the 88 would have to be upped to 89 and the loop conditions would have to test for "< 89".

Here's the corrections I made to account for all scancodes:

EDITED: BETTER NAME FOR THE FOLLOWING WOULD BE KEY_MAP_SIZE...
#define MAX_KEY_POS 116

...

void init_key_map()
{
...
for( i = 0;i < MAX_KEY_POS; i++)
...
}


void cache_key_map()
{
...
for( i = 0; i < MAX_KEY_POS;i++)
...
}

void restore_key_map()
{
...
for( i = 0; i < MAX_KEY_POS; i++)
...
}

void map_key(var scode, void* funct)
{
if (scode > 0 && scode < MAX_KEY_POS )
...
}

I think this covers the array dimensioning problems. Recognized this problem when my code was crashing, in an attempt to work on navigation control. Saw the dimensioning problem and fixed it thinking it would correct my crash. Didn't correct the crash, but at least the subtle dimension problem is fix fixed.



Last edited by 3Dski; 10/28/07 20:32.