File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,6 +209,16 @@ void Game::run()
209209 break ;
210210 }
211211 break ;
212+ case SDL_KEYDOWN :
213+ case SDL_KEYUP :
214+ if (Options::getBool (" strafe" ) && (_event.type == SDL_KEYDOWN ) && (&_event)->key .keysym .sym == SDLK_LCTRL )
215+ {
216+ setCtrlKeyDown (true );
217+ }
218+ if ((_event.type == SDL_KEYUP ) && (&_event)->key .keysym .sym == SDLK_LCTRL )
219+ {
220+ setCtrlKeyDown (false );
221+ }
212222 case SDL_MOUSEMOTION :
213223 case SDL_MOUSEBUTTONDOWN :
214224 case SDL_MOUSEBUTTONUP :
@@ -480,4 +490,21 @@ void Game::setMouseActive(bool active)
480490 _cursor->setVisible (active);
481491}
482492
493+ bool Game::_ctrlKeyDown;
494+ /* *
495+ * Sets whether the control key is down
496+ */
497+ void Game::setCtrlKeyDown (bool ctrlKey)
498+ {
499+ _ctrlKeyDown = ctrlKey;
500+ }
501+
502+ /* *
503+ * Returns whether the control key is down
504+ */
505+ bool Game::getCtrlKeyDown ()
506+ {
507+ return _ctrlKeyDown;
508+ }
509+
483510}
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class Game
5555 bool _quit, _init;
5656 FpsCounter *_fpsCounter;
5757 bool _mouseActive;
58+ static bool _ctrlKeyDown; // Used so player can indicate strafing movement.
5859public:
5960 // / Creates a new game and initializes SDL.
6061 Game (const std::string &title);
@@ -98,6 +99,10 @@ class Game
9899 void loadRuleset ();
99100 // / Sets whether the mouse cursor is activated.
100101 void setMouseActive (bool active);
102+ // / Sets whether the Ctrl Key is down
103+ static void setCtrlKeyDown (bool ctrlKey);
104+ // / Returns whether the control key is down
105+ static bool getCtrlKeyDown ();
101106};
102107
103108}
You can’t perform that action at this time.
0 commit comments