Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #pragma once
  2.  
  3. #define NOMINMAX
  4. #include <Windows.h>
  5. #include <cstdint>
  6. #include <functional>
  7. #include <map>
  8. #include <memory>
  9. #include <stdexcept>
  10. #include <d3d9.h>
  11.  
  12. #include "../../Utils/Singleton.hpp"
  13.  
  14. enum class KeyState
  15. {
  16. None = 1,
  17. Down,
  18. Up,
  19. Pressed /*Down and then up*/
  20. };
  21.  
  22. DEFINE_ENUM_FLAG_OPERATORS(KeyState);
  23.  
  24. class InputSys
  25. : public Singleton<InputSys>
  26. {
  27. friend class Singleton<InputSys>;
  28.  
  29. InputSys();
  30. ~InputSys();
  31.  
  32. public:
  33. void Initialize();
  34.  
  35. HWND GetMainWindow() const { return m_hTargetWindow; }
  36.  
  37. KeyState GetKeyState(uint32_t vk);
  38. bool IsKeyDown(uint32_t vk);
  39. bool WasKeyPressed(uint32_t vk);
  40.  
  41. void RegisterHotkey(uint32_t vk, std::function<void(void)> f);
  42. void RemoveHotkey(uint32_t vk);
  43.  
  44. private:
  45. static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  46.  
  47. bool ProcessMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  48. bool ProcessMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  49. bool ProcessKeybdMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  50.  
  51.  
  52. HWND m_hTargetWindow;
  53. LONG_PTR m_ulOldWndProc;
  54. KeyState m_iKeyMap[256];
  55.  
  56. std::function<void(void)> m_Hotkeys[256];
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement