Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "..\Frostbite.h"
- #include <dinput.h>
- #include <XInput.h>
- #include "..\Cameras\CameraAssets.h"
- #pragma comment(lib, "dinput8.lib")
- #pragma comment(lib, "dxguid.lib")
- #pragma comment(lib, "XInput9_1_0.lib")
- enum ControllerType
- {
- XInput,
- DirectInput
- };
- class InputManager
- {
- public:
- void Init();
- fb::Keyboard* GetFBKeyboard() { return m_pKeyboard; }
- fb::Mouse* GetFBMouse() { return m_pMouse; }
- fb::Gamepad* GetFBGamepad() { return m_pGamepad; }
- bool GetGamepadData(GamepadInput& pState);
- HRESULT CreateDevice(LPCDIDEVICEINSTANCE);
- private:
- static InputManager* m_Instance;
- static void HotkeyThread();
- static void ControllerThread();
- bool FindDInputController();
- bool FindXInputController();
- void ParseDInputData(GamepadInput& pState, DIJOYSTATE2& state);
- void ParseXInputData(GamepadInput& pState, XINPUT_STATE& state);
- LPDIRECTINPUT8 lpdi;
- LPDIRECTINPUTDEVICE8 lpdiGamepad;
- fb::Keyboard* m_pKeyboard;
- fb::Mouse* m_pMouse;
- fb::Gamepad* m_pGamepad;
- int m_xinputID;
- XINPUT_STATE m_xiState;
- DIJOYSTATE2 m_diState;
- bool m_hasController;
- ControllerType m_controllerType;
- };
- struct GamepadInput
- {
- XMFLOAT2 LeftStick;
- XMFLOAT2 RightStick;
- double Trigger;
- BYTE LeftShoulder;
- BYTE RightShoulder;
- BYTE LeftThumbButton;
- BYTE RightThumbButton;
- BYTE DPad_Left;
- BYTE DPad_Right;
- BYTE DPad_Up;
- BYTE DPad_Down;
- BYTE Buttons[4];
- };
Add Comment
Please, Sign In to add comment