ulfben

Windows basic keyboard InputManager

Nov 14th, 2017
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  Provides InputManager::isKeyDown(int ascii) using Windows native functions.
  3.  Ergo: very basic game controls when SDL and other libraries are unavailable.
  4. */
  5. #pragma once
  6. #include "Windows.h"
  7. class InputManager{
  8. public:
  9.     //expects windows virtual key VK_* codes
  10.     //https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  11.     static bool InputManager::isKeyDown(int key){
  12.         return (::GetAsyncKeyState(key) & (1 << 16));
  13.     }
  14. };
  15. static const int VK_0 = int('0');
  16. static const int VK_1 = int('1');
  17. static const int VK_2 = int('2');
  18. static const int VK_3 = int('3');
  19. static const int VK_4 = int('4');
  20. static const int VK_5 = int('5');
  21. static const int VK_6 = int('6');
  22. static const int VK_7 = int('7');
  23. static const int VK_8 = int('8');
  24. static const int VK_9 = int('9');
  25. static const int VK_AT= int('@');
  26. static const int VK_A = int('A');
  27. static const int VK_B = int('B');
  28. static const int VK_C = int('C');
  29. static const int VK_D = int('D');
  30. static const int VK_E = int('E');
  31. static const int VK_F = int('F');
  32. static const int VK_G = int('G');
  33. static const int VK_H = int('H');
  34. static const int VK_I = int('I');
  35. static const int VK_J = int('J');
  36. static const int VK_K = int('K');
  37. static const int VK_L = int('L');
  38. static const int VK_M = int('M');
  39. static const int VK_N = int('N');
  40. static const int VK_O = int('O');
  41. static const int VK_P = int('P');
  42. static const int VK_Q = int('Q');
  43. static const int VK_R = int('R');
  44. static const int VK_S = int('S');
  45. static const int VK_T = int('T');
  46. static const int VK_U = int('U');
  47. static const int VK_V = int('V');
  48. static const int VK_X = int('X');
  49. static const int VK_Y = int('Y');
  50. static const int VK_Z = int('Z');
  51. static const int VK_Å = int('Å');
  52. static const int VK_Ä = int('Ä');
  53. static const int VK_Ö = int('Ö');
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×