Advertisement
Hattiwatti

Untitled

Dec 16th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #pragma once
  2. #include "..\Frostbite.h"
  3. #include <dinput.h>
  4. #include <XInput.h>
  5. #include "..\Cameras\CameraAssets.h"
  6. #pragma comment(lib, "dinput8.lib")
  7. #pragma comment(lib, "dxguid.lib")
  8. #pragma comment(lib, "XInput9_1_0.lib")
  9.  
  10. enum ControllerType
  11. {
  12.     XInput,
  13.     DirectInput
  14. };
  15.  
  16. class InputManager
  17. {
  18. public:
  19.     void Init();
  20.  
  21.     fb::Keyboard* GetFBKeyboard() { return m_pKeyboard; }
  22.     fb::Mouse* GetFBMouse() { return m_pMouse; }
  23.     fb::Gamepad* GetFBGamepad() { return m_pGamepad; }
  24.  
  25.     bool GetGamepadData(GamepadInput& pState);
  26.     HRESULT CreateDevice(LPCDIDEVICEINSTANCE);
  27.  
  28. private:
  29.     static InputManager* m_Instance;
  30.     static void HotkeyThread();
  31.     static void ControllerThread();
  32.  
  33.     bool FindDInputController();
  34.     bool FindXInputController();
  35.  
  36.     void ParseDInputData(GamepadInput& pState, DIJOYSTATE2& state);
  37.     void ParseXInputData(GamepadInput& pState, XINPUT_STATE& state);
  38.  
  39.     LPDIRECTINPUT8 lpdi;
  40.     LPDIRECTINPUTDEVICE8 lpdiGamepad;
  41.  
  42.     fb::Keyboard* m_pKeyboard;
  43.     fb::Mouse* m_pMouse;
  44.     fb::Gamepad* m_pGamepad;
  45.  
  46.     int m_xinputID;
  47.  
  48.     XINPUT_STATE m_xiState;
  49.     DIJOYSTATE2 m_diState;
  50.  
  51.     bool m_hasController;
  52.     ControllerType m_controllerType;
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement