Permalink
Browse files

Add SDL_keysym.h, Use official SDL constants

  • Loading branch information...
jacob1 committed Jul 20, 2016
1 parent 95fde9d commit ecb08952e56b753f03efd76827e0c0cec99fd149
@@ -587,24 +587,24 @@ 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;
case KEY_NUM_PERIOD:
return KEY_DELETE;
case KEY_NUM_INS:
case KEY_NUM_PGUP:
case KEY_NUM_PGDOWN:
return KEY_UNKNOWN;
case SDLK_KP8:
return SDLK_UP;
case SDLK_KP2:
return SDLK_DOWN;
case SDLK_KP6:
return SDLK_RIGHT;
case SDLK_KP4:
return SDLK_LEFT;
case SDLK_KP7:
return SDLK_HOME;
case SDLK_KP1:
return SDLK_END;
case SDLK_KP_PERIOD:
return SDLK_DELETE;
case SDLK_KP0:
case SDLK_KP9:
case SDLK_KP3:
return SDLK_UNKNOWN;
default:
return key;
}
@@ -641,10 +641,10 @@ void EventProcess(SDL_Event event)
engine->Exit();
break;
case SDL_KEYDOWN:
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_SHIFT, event.key.keysym.mod&KEY_MOD_CONTROL, event.key.keysym.mod&KEY_MOD_ALT);
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
break;
case SDL_KEYUP:
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_SHIFT, event.key.keysym.mod&KEY_MOD_CONTROL, event.key.keysym.mod&KEY_MOD_ALT);
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
break;
case SDL_MOUSEMOTION:
engine->onMouseMove(event.motion.x*inputScale, event.motion.y*inputScale);
@@ -243,7 +243,7 @@ void ColourPickerActivity::OnMouseUp(int x, int y, unsigned button)
void ColourPickerActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if (key == KEY_TAB)
if (key == SDLK_TAB)
{
if (rValue->IsFocused())
gValue->TabFocus();
@@ -28,23 +28,23 @@ void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
{
switch(key)
{
case KEY_ESCAPE:
case SDLK_ESCAPE:
case '`':
if (character != '~')
c->CloseConsole();
else
Window::DoKeyPress(key, character, shift, ctrl, alt);
break;
case KEY_RETURN:
case KEY_ENTER:
case SDLK_RETURN:
case SDLK_KP_ENTER:
c->EvaluateCommand(commandField->GetText());
commandField->SetText("");
commandField->SetDisplayText("");
break;
case KEY_DOWN:
case SDLK_DOWN:
c->NextCommand();
break;
case KEY_UP:
case SDLK_UP:
c->PreviousCommand();
break;
default:
@@ -188,13 +188,13 @@ void ElementSearchActivity::OnTick(float dt)
void ElementSearchActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if(key == KEY_ENTER || key == KEY_RETURN)
if (key == SDLK_KP_ENTER || key == SDLK_RETURN)
{
if(firstResult)
gameController->SetActiveTool(0, firstResult);
exit = true;
}
if(key == KEY_ESCAPE)
if (key == SDLK_ESCAPE)
{
exit = true;
}
@@ -25,6 +25,7 @@
#include "gui/save/LocalSaveActivity.h"
#include "gui/save/ServerSaveActivity.h"
#include "gui/interface/Keys.h"
#include "gui/interface/Mouse.h"
#include "simulation/Snapshot.h"
#include "debug/DebugInfo.h"
#include "debug/DebugParts.h"
@@ -562,7 +563,7 @@ bool GameController::MouseDown(int x, int y, unsigned button)
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
x = point.X;
y = point.Y;
if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != SDL_BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
{
foundSign = GetSignAt(x, y);
if(foundSign && sign::splitsign(foundSign->text.c_str()))
@@ -582,7 +583,7 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
x = point.X;
y = point.Y;
if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != SDL_BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
{
sign * foundSign = GetSignAt(x, y);
if (foundSign)
@@ -644,36 +645,36 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl,
if (ret)
{
Simulation * sim = gameModel->GetSimulation();
if (key == KEY_RIGHT)
if (key == SDLK_RIGHT)
{
sim->player.comm = (int)(sim->player.comm)|0x02; //Go right command
}
if (key == KEY_LEFT)
if (key == SDLK_LEFT)
{
sim->player.comm = (int)(sim->player.comm)|0x01; //Go left command
}
if (key == KEY_DOWN && ((int)(sim->player.comm)&0x08)!=0x08)
if (key == SDLK_DOWN && ((int)(sim->player.comm)&0x08)!=0x08)
{
sim->player.comm = (int)(sim->player.comm)|0x08; //Use element command
}
if (key == KEY_UP && ((int)(sim->player.comm)&0x04)!=0x04)
if (key == SDLK_UP && ((int)(sim->player.comm)&0x04)!=0x04)
{
sim->player.comm = (int)(sim->player.comm)|0x04; //Jump command
}
if (key == KEY_d)
if (key == SDLK_d)
{
sim->player2.comm = (int)(sim->player2.comm)|0x02; //Go right command
}
if (key == KEY_a)
if (key == SDLK_a)
{
sim->player2.comm = (int)(sim->player2.comm)|0x01; //Go left command
}
if (key == KEY_s && ((int)(sim->player2.comm)&0x08)!=0x08)
if (key == SDLK_s && ((int)(sim->player2.comm)&0x08)!=0x08)
{
sim->player2.comm = (int)(sim->player2.comm)|0x08; //Use element command
}
if (key == KEY_w && ((int)(sim->player2.comm)&0x04)!=0x04)
if (key == SDLK_w && ((int)(sim->player2.comm)&0x04)!=0x04)
{
sim->player2.comm = (int)(sim->player2.comm)|0x04; //Jump command
}
@@ -710,30 +711,30 @@ bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl
if (ret)
{
Simulation * sim = gameModel->GetSimulation();
if (key == KEY_RIGHT || key == KEY_LEFT)
if (key == SDLK_RIGHT || key == SDLK_LEFT)
{
sim->player.pcomm = sim->player.comm; //Saving last movement
sim->player.comm = (int)(sim->player.comm)&12; //Stop command
}
if (key == KEY_UP)
if (key == SDLK_UP)
{
sim->player.comm = (int)(sim->player.comm)&11;
}
if (key == KEY_DOWN)
if (key == SDLK_DOWN)
{
sim->player.comm = (int)(sim->player.comm)&7;
}
if (key == KEY_d || key == KEY_a)
if (key == SDLK_d || key == SDLK_a)
{
sim->player2.pcomm = sim->player2.comm; //Saving last movement
sim->player2.comm = (int)(sim->player2.comm)&12; //Stop command
}
if (key == KEY_w)
if (key == SDLK_w)
{
sim->player2.comm = (int)(sim->player2.comm)&11;
}
if (key == KEY_s)
if (key == SDLK_s)
{
sim->player2.comm = (int)(sim->player2.comm)&7;
}
@@ -10,6 +10,7 @@
#include "gui/interface/Button.h"
#include "gui/interface/Colour.h"
#include "gui/interface/Keys.h"
#include "gui/interface/Mouse.h"
#include "gui/interface/Slider.h"
#include "gui/search/Thumbnail.h"
#include "simulation/SaveRenderer.h"
@@ -1142,13 +1143,13 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
{
currentMouse = ui::Point(x, y);
if (altBehaviour && !shiftBehaviour && !ctrlBehaviour)
button = BUTTON_MIDDLE;
button = SDL_BUTTON_MIDDLE;
if (!(zoomEnabled && !zoomCursorFixed))
{
if (selectMode != SelectNone)
{
isMouseDown = true;
if (button == BUTTON_LEFT && selectPoint1.X == -1)
if (button == SDL_BUTTON_LEFT && selectPoint1.X == -1)
{
selectPoint1 = c->PointTranslate(currentMouse);
selectPoint2 = selectPoint1;
@@ -1158,11 +1159,11 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
if (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES)
{
// update tool index, set new "last" tool so GameView can detect certain tools properly
if (button == BUTTON_LEFT)
if (button == SDL_BUTTON_LEFT)
toolIndex = 0;
if (button == BUTTON_RIGHT)
if (button == SDL_BUTTON_RIGHT)
toolIndex = 1;
if (button == BUTTON_MIDDLE)
if (button == SDL_BUTTON_MIDDLE)
toolIndex = 2;
Tool *lastTool = c->GetActiveTool(toolIndex);
c->SetLastTool(lastTool);
@@ -1201,7 +1202,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
isMouseDown = false;
if (selectMode != SelectNone)
{
if (button == BUTTON_LEFT && selectPoint1.X != -1 && selectPoint1.Y != -1 && selectPoint2.X != -1 && selectPoint2.Y != -1)
if (button == SDL_BUTTON_LEFT && selectPoint1.X != -1 && selectPoint1.Y != -1 && selectPoint2.X != -1 && selectPoint2.Y != -1)
{
if (selectMode == PlaceSave)
{
@@ -1276,7 +1277,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
}
}
// this shouldn't happen, but do this just in case
else if (selectMode != SelectNone && button != BUTTON_LEFT)
else if (selectMode != SelectNone && button != SDL_BUTTON_LEFT)
selectMode = SelectNone;
// update the drawing mode for the next line
@@ -1369,16 +1370,16 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
switch (key)
{
case KEY_RIGHT:
case SDLK_RIGHT:
c->TranslateSave(ui::Point(1, 0));
return;
case KEY_LEFT:
case SDLK_LEFT:
c->TranslateSave(ui::Point(-1, 0));
return;
case KEY_UP:
case SDLK_UP:
c->TranslateSave(ui::Point(0, -1));
return;
case KEY_DOWN:
case SDLK_DOWN:
c->TranslateSave(ui::Point(0, 1));
return;
case 'r':
@@ -1403,16 +1404,16 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
switch(key)
{
case KEY_LALT:
case KEY_RALT:
case SDLK_LALT:
case SDLK_RALT:
enableAltBehaviour();
break;
case KEY_LCTRL:
case KEY_RCTRL:
case SDLK_LCTRL:
case SDLK_RCTRL:
enableCtrlBehaviour();
break;
case KEY_LSHIFT:
case KEY_RSHIFT:
case SDLK_LSHIFT:
case SDLK_RSHIFT:
enableShiftBehaviour();
break;
case ' ': //Space
@@ -1432,20 +1433,20 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
c->SetZoomEnabled(true);
}
break;
case KEY_TAB: //Tab
case SDLK_TAB: //Tab
c->ChangeBrush();
break;
case '`':
c->ShowConsole();
break;
case 'p':
case KEY_F2:
case SDLK_F2:
screenshot();
break;
case KEY_F3:
case SDLK_F3:
SetDebugHUD(!GetDebugHUD());
break;
case KEY_F5:
case SDLK_F5:
c->ReloadSim();
break;
case 'r':
@@ -1477,7 +1478,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
else
c->AdjustGridSize(1);
break;
case KEY_F1:
case SDLK_F1:
if(!introText)
introText = 8047;
else
@@ -1510,7 +1511,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
case 'y':
c->SwitchAir();
break;
case KEY_ESCAPE:
case SDLK_ESCAPE:
case 'q':
ExitPrompt();
break;
@@ -1597,10 +1598,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
break;
}
//fancy case switch without break
case KEY_INSERT:
case SDLK_INSERT:
c->SetReplaceModeFlags(c->GetReplaceModeFlags()^REPLACE_MODE);
break;
case KEY_DELETE:
case SDLK_DELETE:
c->SetReplaceModeFlags(c->GetReplaceModeFlags()^SPECIFIC_DELETE);
break;
}
@@ -1617,16 +1618,16 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
{
switch(key)
{
case KEY_LALT:
case KEY_RALT:
case SDLK_LALT:
case SDLK_RALT:
disableAltBehaviour();
break;
case KEY_LCTRL:
case KEY_RCTRL:
case SDLK_LCTRL:
case SDLK_RCTRL:
disableCtrlBehaviour();
break;
case KEY_LSHIFT:
case KEY_RSHIFT:
case SDLK_LSHIFT:
case SDLK_RSHIFT:
disableShiftBehaviour();
break;
case 'z':
Oops, something went wrong.

0 comments on commit ecb0895

Please sign in to comment.