Suppress generation of menu input when entering text with numpad with NumLock on; bug #934

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3186 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-10-07 00:30:11 +00:00
parent f5a0024efc
commit 12a0e5f9cd
4 changed files with 27 additions and 12 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.7: Changes towards version 0.7:
- Fixed inputting numbers with the numpad, except directx (bug #934) - Alex
- Better location description in savegame summaries (bug #844) - Alex - Better location description in savegame summaries (bug #844) - Alex
- Fixed crash when saving a game into the last slot while having - Fixed crash when saving a game into the last slot while having
too many devices on board - Alex too many devices on board - Alex
+3 -1
View File
@@ -170,8 +170,10 @@ DoTextEntry (TEXTENTRY_STATE *pTES)
} }
pTES->CacheStr = HMalloc (pTES->MaxSize * sizeof (*pTES->CacheStr)); pTES->CacheStr = HMalloc (pTES->MaxSize * sizeof (*pTES->CacheStr));
EnterCharacterMode ();
DoInput (pTES, TRUE); DoInput (pTES, TRUE);
ExitCharacterMode ();
if (pTES->CacheStr) if (pTES->CacheStr)
HFree (pTES->CacheStr); HFree (pTES->CacheStr);
+2 -2
View File
@@ -43,8 +43,8 @@ extern volatile int QuitPosted;
/* Functions for dealing with Character Mode */ /* Functions for dealing with Character Mode */
void EnableCharacterMode (void); void EnterCharacterMode (void);
void DisableCharacterMode (void); void ExitCharacterMode (void);
wchar_t GetNextCharacter (void); wchar_t GetNextCharacter (void);
wchar_t GetLastCharacter (void); wchar_t GetLastCharacter (void);
+21 -9
View File
@@ -42,7 +42,7 @@ static int *kbdstate = NULL;
static BOOLEAN InputInitialized = FALSE; static BOOLEAN InputInitialized = FALSE;
static BOOLEAN _in_character_mode = FALSE; static BOOLEAN in_character_mode = FALSE;
static const char *menu_res_names[] = { static const char *menu_res_names[] = {
"pause", "pause",
@@ -217,7 +217,7 @@ TFB_InitInput (int driver, int flags)
} }
#endif /* HAVE_JOYSTICK */ #endif /* HAVE_JOYSTICK */
_in_character_mode = FALSE; in_character_mode = FALSE;
resetKeyboardState (); resetKeyboardState ();
/* Prepare the Virtual Controller system. */ /* Prepare the Virtual Controller system. */
@@ -239,22 +239,20 @@ TFB_UninitInput (void)
HFree (kbdstate); HFree (kbdstate);
} }
// XXX: not currently used -- character mode is always on
void void
EnableCharacterMode (void) EnterCharacterMode (void)
{ {
kbdhead = kbdtail = 0; kbdhead = kbdtail = 0;
lastchar = 0; lastchar = 0;
_in_character_mode = TRUE; in_character_mode = TRUE;
VControl_ResetInput (); VControl_ResetInput ();
} }
// XXX: not currently used -- character mode is always on
void void
DisableCharacterMode (void) ExitCharacterMode (void)
{ {
VControl_ResetInput (); VControl_ResetInput ();
_in_character_mode = FALSE; in_character_mode = FALSE;
kbdhead = kbdtail = 0; kbdhead = kbdtail = 0;
lastchar = 0; lastchar = 0;
} }
@@ -294,6 +292,16 @@ ProcessMouseEvent (const SDL_Event *e)
} }
} }
static inline int
is_numpad_char_event (const SDL_Event *Event)
{
return in_character_mode &&
(Event->type == SDL_KEYDOWN || Event->type == SDL_KEYUP) &&
(Event->key.keysym.mod & KMOD_NUM) && /* NumLock is ON */
Event->key.keysym.unicode > 0 && /* Printable char */
Event->key.keysym.sym >= SDLK_KP0 && /* Keypad key */
Event->key.keysym.sym <= SDLK_KP_PLUS;
}
void void
ProcessInputEvent (const SDL_Event *Event) ProcessInputEvent (const SDL_Event *Event)
@@ -302,7 +310,11 @@ ProcessInputEvent (const SDL_Event *Event)
return; return;
ProcessMouseEvent (Event); ProcessMouseEvent (Event);
VControl_HandleEvent (Event);
// In character mode with NumLock on, numpad chars bypass VControl
// so that menu arrow events are not produced
if (!is_numpad_char_event (Event))
VControl_HandleEvent (Event);
if (Event->type == SDL_KEYDOWN || Event->type == SDL_KEYUP) if (Event->type == SDL_KEYDOWN || Event->type == SDL_KEYUP)
{ // process character input event, if any { // process character input event, if any