2
0

InputSystem.cpp 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #include "InputSystem.h"
  9. bool KeyboardState::GetKeyValue(SDL_Scancode code) const
  10. {
  11. return mCurrState[code] == 1;
  12. }
  13. ButtonState KeyboardState::GetKeyState(SDL_Scancode code) const
  14. {
  15. if (mCurrState[code] == 0)
  16. {
  17. if (mPrevState[code] == 0)
  18. {
  19. return ENone;
  20. }
  21. else
  22. {
  23. return EReleased;
  24. }
  25. }
  26. else // must be 1
  27. {
  28. if (mPrevState[code] == 0)
  29. {
  30. return EPressed;
  31. }
  32. else
  33. {
  34. return EHeld;
  35. }
  36. }
  37. }
  38. InputSystem::InputSystem()
  39. {
  40. }
  41. bool InputSystem::Initialize()
  42. {
  43. return true;
  44. }
  45. void InputSystem::Shutdown()
  46. {
  47. }
  48. void InputSystem::PrepareForUpdate()
  49. {
  50. }
  51. void InputSystem::Update()
  52. {
  53. }