Fix weird getQwertyKey function which incorrectly assumed KEY_W = KEY_Q+1 and so on.
Changelog: Fix Alt+Letter / Shift+Letter only saving/recalling camera positions if A ≤ Letter ≤ L.master
parent
74c3872aa0
commit
06acd4c399
55
src/keymap.c
55
src/keymap.c
|
@ -948,35 +948,33 @@ void keySetMappingStatus(KEY_MAPPING *psMapping, BOOL state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Returns the key code of the first ascii key that its finds has been PRESSED */
|
static const KEY_CODE qwertyCodes[26] =
|
||||||
KEY_CODE getQwertyKey( void )
|
|
||||||
{
|
{
|
||||||
UDWORD i;
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O, KEY_P,
|
||||||
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
KEY_A, KEY_S, KEY_D, KEY_F, KEY_G, KEY_H, KEY_J, KEY_K, KEY_L,
|
||||||
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M
|
||||||
|
// +---+ +---+ +---+ +---+ +---+ +---+ +---+
|
||||||
|
};
|
||||||
|
|
||||||
for(i = KEY_Q; i <= KEY_P; i++)
|
/* Returns the key code of the first ascii key that its finds has been PRESSED */
|
||||||
|
KEY_CODE getQwertyKey(void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(qwertyCodes); ++i)
|
||||||
{
|
{
|
||||||
if(keyPressed(i))
|
if (keyPressed(qwertyCodes[i]))
|
||||||
{
|
{
|
||||||
return(i); // top row key pressed
|
return qwertyCodes[i]; // Top-, middle- or bottom-row key pressed.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = KEY_A; i <= KEY_L; i++)
|
return (KEY_CODE)0; // no ascii key pressed
|
||||||
{
|
|
||||||
if(keyPressed(i))
|
|
||||||
{
|
|
||||||
return(i); // middle row key pressed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = KEY_Z; i <= KEY_M; i++)
|
|
||||||
{
|
|
||||||
if(keyPressed(i))
|
|
||||||
{
|
|
||||||
return(i); // bottomw row key pressed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(0); // no ascii key pressed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ -985,18 +983,15 @@ UDWORD i;
|
||||||
*/
|
*/
|
||||||
UDWORD asciiKeyCodeToTable(KEY_CODE code)
|
UDWORD asciiKeyCodeToTable(KEY_CODE code)
|
||||||
{
|
{
|
||||||
if( code >= KEY_Q && code<=KEY_P )
|
unsigned i;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(qwertyCodes); ++i)
|
||||||
{
|
{
|
||||||
return code - KEY_Q; // q is the first of the ascii scan codes
|
if (code == qwertyCodes[i])
|
||||||
}
|
|
||||||
if( code >= KEY_A && code <=KEY_L )
|
|
||||||
{
|
{
|
||||||
return (code - KEY_A) + 10; // ten keys from q to p
|
return i;
|
||||||
}
|
}
|
||||||
if( code >= KEY_Z && code<=KEY_M )
|
|
||||||
{
|
|
||||||
return (code - KEY_Z) + 19; // 19 keys before, the 10 from q..p and the 9 from a..l
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(false, "only pass nonzero key codes from getQwertyKey to this function");
|
ASSERT(false, "only pass nonzero key codes from getQwertyKey to this function");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue