fix numpad behavior: movement keys are no longer triggered with numlock on
This commit is contained in:
parent
d59253cfc7
commit
43bff37279
@ -414,6 +414,27 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[])
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDLKey MapNumpad(SDLKey key)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case KEY_NUM_UP:
|
||||||
|
return KEY_UP;
|
||||||
|
case KEY_NUM_DOWN:
|
||||||
|
return KEY_DOWN;
|
||||||
|
case KEY_NUM_RIGHT:
|
||||||
|
return KEY_RIGHT;
|
||||||
|
case KEY_NUM_LEFT:
|
||||||
|
return KEY_LEFT;
|
||||||
|
case KEY_NUM_HOME:
|
||||||
|
return KEY_HOME;
|
||||||
|
case KEY_NUM_END:
|
||||||
|
return KEY_END;
|
||||||
|
default:
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0;
|
int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0;
|
||||||
unsigned int lastTick = 0;
|
unsigned int lastTick = 0;
|
||||||
float fps = 0, delta = 1.0f, inputScale = 1.0f;
|
float fps = 0, delta = 1.0f, inputScale = 1.0f;
|
||||||
@ -422,6 +443,9 @@ float currentWidth, currentHeight;
|
|||||||
|
|
||||||
void EventProcess(SDL_Event event)
|
void EventProcess(SDL_Event event)
|
||||||
{
|
{
|
||||||
|
if(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
|
||||||
|
if(!(event.key.keysym.mod&KEY_MOD_NUM))
|
||||||
|
event.key.keysym.sym = MapNumpad(event.key.keysym.sym);
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
@ -41,10 +41,10 @@ void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
|
|||||||
commandField->SetText("");
|
commandField->SetText("");
|
||||||
commandField->SetDisplayText("");
|
commandField->SetDisplayText("");
|
||||||
break;
|
break;
|
||||||
case KEY_DOWN: case KEY_NUM_DOWN:
|
case KEY_DOWN:
|
||||||
c->NextCommand();
|
c->NextCommand();
|
||||||
break;
|
break;
|
||||||
case KEY_UP: case KEY_NUM_UP:
|
case KEY_UP:
|
||||||
c->PreviousCommand();
|
c->PreviousCommand();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -229,9 +229,9 @@ void PropertyWindow::OnDraw()
|
|||||||
|
|
||||||
void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
if (key == KEY_UP || key == KEY_NUM_UP)
|
if (key == KEY_UP)
|
||||||
property->SetOption(property->GetOption().second-1);
|
property->SetOption(property->GetOption().second-1);
|
||||||
else if (key == KEY_DOWN || key == KEY_NUM_DOWN)
|
else if (key == KEY_DOWN)
|
||||||
property->SetOption(property->GetOption().second+1);
|
property->SetOption(property->GetOption().second+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,20 +342,20 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
{
|
{
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case KEY_HOME: case KEY_NUM_HOME:
|
case KEY_HOME:
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
break;
|
break;
|
||||||
case KEY_END: case KEY_NUM_END:
|
case KEY_END:
|
||||||
cursor = backingText.length();
|
cursor = backingText.length();
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT: case KEY_NUM_LEFT:
|
case KEY_LEFT:
|
||||||
if(cursor > 0)
|
if(cursor > 0)
|
||||||
cursor--;
|
cursor--;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
break;
|
break;
|
||||||
case KEY_RIGHT: case KEY_NUM_RIGHT:
|
case KEY_RIGHT:
|
||||||
if(cursor < backingText.length())
|
if(cursor < backingText.length())
|
||||||
cursor++;
|
cursor++;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
|
Loading…
Reference in New Issue
Block a user