mirror of
https://github.com/libretro/Mesen.git
synced 2024-12-12 19:36:23 +00:00
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include <dinput.h>
|
|
#include "../Utilities/SimpleLock.h"
|
|
|
|
struct DirectInputData
|
|
{
|
|
LPDIRECTINPUTDEVICE8 joystick;
|
|
DIJOYSTATE2 state;
|
|
DIJOYSTATE2 defaultState;
|
|
bool stateValid;
|
|
DIDEVICEINSTANCE instanceInfo;
|
|
};
|
|
|
|
class DirectInputManager
|
|
{
|
|
private:
|
|
static HWND _hWnd;
|
|
static bool _needToUpdate;
|
|
static LPDIRECTINPUT8 _directInput;
|
|
static vector<DirectInputData> _joysticks;
|
|
static std::vector<GUID> _xinputDeviceGuids;
|
|
static std::vector<GUID> _directInputDeviceGuids;
|
|
|
|
bool Initialize();
|
|
void UpdateInputState(DirectInputData& joystick);
|
|
static bool ProcessDevice(const DIDEVICEINSTANCE* pdidInstance, bool checkOnly);
|
|
static bool IsXInputDevice(const GUID* pGuidProductFromDirectInput);
|
|
static int __stdcall NeedToUpdateCallback(const DIDEVICEINSTANCE* pdidInstance, void* pContext);
|
|
static int __stdcall EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, void* pContext);
|
|
static int __stdcall EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, void* pContext);
|
|
|
|
public:
|
|
DirectInputManager(HWND window);
|
|
~DirectInputManager();
|
|
|
|
void RefreshState();
|
|
bool NeedToUpdate();
|
|
bool UpdateDeviceList();
|
|
int GetJoystickCount();
|
|
bool IsPressed(int port, int button);
|
|
};
|