mirror of https://github.com/PCSX2/pcsx2.git
lilypad: Use Windows SDK headers for HID functions
Has been available since the switch to the Windows 8.1 SDK.
This commit is contained in:
parent
c6ed5ee9c6
commit
be7af60ab5
|
@ -19,12 +19,14 @@
|
|||
#include "InputManager.h"
|
||||
|
||||
#include "DeviceEnumerator.h"
|
||||
#ifdef _WIN32
|
||||
#include "WindowsMessaging.h"
|
||||
#include "DirectInput.h"
|
||||
#include "RawInput.h"
|
||||
#include "XInputEnum.h"
|
||||
#include "HidDevice.h"
|
||||
#include "DualShock3.h"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include "Linux/KeyboardMouse.h"
|
||||
|
|
|
@ -18,65 +18,13 @@
|
|||
#include "Global.h"
|
||||
#include "HidDevice.h"
|
||||
#include <setupapi.h>
|
||||
|
||||
// Tons of annoying junk to avoid the hid dependencies, so no one has to download the
|
||||
// DDK to compile.
|
||||
#define HIDP_STATUS_SUCCESS 0x110000
|
||||
|
||||
struct HIDD_ATTRIBUTES {
|
||||
ULONG Size;
|
||||
|
||||
USHORT VendorID;
|
||||
USHORT ProductID;
|
||||
USHORT VersionNumber;
|
||||
};
|
||||
struct HIDP_PREPARSED_DATA;
|
||||
|
||||
typedef BOOLEAN (__stdcall *_HidD_GetAttributes) (HANDLE HidDeviceObject, HIDD_ATTRIBUTES *Attributes);
|
||||
typedef void (__stdcall *_HidD_GetHidGuid) (GUID* HidGuid);
|
||||
typedef BOOLEAN (__stdcall *_HidD_GetPreparsedData) (HANDLE HidDeviceObject, HIDP_PREPARSED_DATA **PreparsedData);
|
||||
typedef NTSTATUS (__stdcall *_HidP_GetCaps) (HIDP_PREPARSED_DATA* PreparsedData, HIDP_CAPS *caps);
|
||||
typedef BOOLEAN (__stdcall *_HidD_FreePreparsedData) (HIDP_PREPARSED_DATA *PreparsedData);
|
||||
typedef BOOLEAN (__stdcall *_HidD_GetFeature) (HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength);
|
||||
typedef BOOLEAN (__stdcall *_HidD_SetFeature) (HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength);
|
||||
|
||||
GUID GUID_DEVINTERFACE_HID;
|
||||
_HidD_GetHidGuid pHidD_GetHidGuid;
|
||||
_HidD_GetAttributes pHidD_GetAttributes;
|
||||
_HidD_GetPreparsedData pHidD_GetPreparsedData;
|
||||
_HidP_GetCaps pHidP_GetCaps;
|
||||
_HidD_FreePreparsedData pHidD_FreePreparsedData;
|
||||
_HidD_GetFeature pHidD_GetFeature;
|
||||
_HidD_SetFeature pHidD_SetFeature;
|
||||
|
||||
HMODULE hModHid = 0;
|
||||
|
||||
int InitHid() {
|
||||
if (hModHid) {
|
||||
return 1;
|
||||
}
|
||||
hModHid = LoadLibraryA("hid.dll");
|
||||
if (hModHid) {
|
||||
if ((pHidD_GetHidGuid = (_HidD_GetHidGuid) GetProcAddress(hModHid, "HidD_GetHidGuid")) &&
|
||||
(pHidD_GetAttributes = (_HidD_GetAttributes) GetProcAddress(hModHid, "HidD_GetAttributes")) &&
|
||||
(pHidD_GetPreparsedData = (_HidD_GetPreparsedData) GetProcAddress(hModHid, "HidD_GetPreparsedData")) &&
|
||||
(pHidP_GetCaps = (_HidP_GetCaps) GetProcAddress(hModHid, "HidP_GetCaps")) &&
|
||||
(pHidD_FreePreparsedData = (_HidD_FreePreparsedData) GetProcAddress(hModHid, "HidD_FreePreparsedData")) &&
|
||||
(pHidD_GetFeature = (_HidD_GetFeature) GetProcAddress(hModHid, "HidD_GetFeature")) &&
|
||||
(pHidD_SetFeature = (_HidD_SetFeature) GetProcAddress(hModHid, "HidD_SetFeature"))) {
|
||||
pHidD_GetHidGuid(&GUID_DEVINTERFACE_HID);
|
||||
return 1;
|
||||
}
|
||||
UninitHid();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#include <hidsdi.h>
|
||||
|
||||
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid) {
|
||||
if (!InitHid()) return 0;
|
||||
GUID GUID_DEVINTERFACE_HID;
|
||||
int numFoundDevs = 0;
|
||||
*foundDevs = 0;
|
||||
HDEVINFO hdev = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_HID, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
HDEVINFO hdev = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if (hdev != INVALID_HANDLE_VALUE) {
|
||||
SP_DEVICE_INTERFACE_DATA devInterfaceData;
|
||||
devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
@ -94,16 +42,16 @@ int FindHids(HidDeviceInfo **foundDevs, int vid, int pid) {
|
|||
|
||||
if (!SetupDiGetDeviceInterfaceDetail(hdev, &devInterfaceData, devInterfaceDetails, size, &size, &devInfoData)) continue;
|
||||
|
||||
HANDLE hfile = CreateFileW(devInterfaceDetails->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||
HANDLE hfile = CreateFile(devInterfaceDetails->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||
if (hfile != INVALID_HANDLE_VALUE) {
|
||||
HIDD_ATTRIBUTES attributes;
|
||||
attributes.Size = sizeof(attributes);
|
||||
if (pHidD_GetAttributes(hfile, &attributes)) {
|
||||
if (HidD_GetAttributes(hfile, &attributes)) {
|
||||
if (attributes.VendorID == vid && attributes.ProductID == pid) {
|
||||
HIDP_PREPARSED_DATA *pData;
|
||||
PHIDP_PREPARSED_DATA pData;
|
||||
HIDP_CAPS caps;
|
||||
if (pHidD_GetPreparsedData(hfile, &pData)) {
|
||||
if (HIDP_STATUS_SUCCESS == pHidP_GetCaps(pData, &caps)) {
|
||||
if (HidD_GetPreparsedData(hfile, &pData)) {
|
||||
if (HidP_GetCaps(pData, &caps) == HIDP_STATUS_SUCCESS) {
|
||||
if (numFoundDevs % 32 == 0) {
|
||||
*foundDevs = (HidDeviceInfo*) realloc(*foundDevs, sizeof(HidDeviceInfo) * (32 + numFoundDevs));
|
||||
}
|
||||
|
@ -113,7 +61,7 @@ int FindHids(HidDeviceInfo **foundDevs, int vid, int pid) {
|
|||
dev->pid = attributes.ProductID;
|
||||
dev->path = wcsdup(devInterfaceDetails->DevicePath);
|
||||
}
|
||||
pHidD_FreePreparsedData(pData);
|
||||
HidD_FreePreparsedData(pData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,10 +73,3 @@ int FindHids(HidDeviceInfo **foundDevs, int vid, int pid) {
|
|||
}
|
||||
return numFoundDevs;
|
||||
}
|
||||
|
||||
void UninitHid() {
|
||||
if (hModHid) {
|
||||
FreeLibrary(hModHid);
|
||||
hModHid = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,31 +18,7 @@
|
|||
#ifndef HID_DEVICE_H
|
||||
#define HID_DEVICE_H
|
||||
|
||||
int InitHid();
|
||||
|
||||
typedef USHORT USAGE;
|
||||
struct HIDP_CAPS {
|
||||
USAGE Usage;
|
||||
USAGE UsagePage;
|
||||
USHORT InputReportByteLength;
|
||||
USHORT OutputReportByteLength;
|
||||
USHORT FeatureReportByteLength;
|
||||
USHORT Reserved[17];
|
||||
|
||||
USHORT NumberLinkCollectionNodes;
|
||||
|
||||
USHORT NumberInputButtonCaps;
|
||||
USHORT NumberInputValueCaps;
|
||||
USHORT NumberInputDataIndices;
|
||||
|
||||
USHORT NumberOutputButtonCaps;
|
||||
USHORT NumberOutputValueCaps;
|
||||
USHORT NumberOutputDataIndices;
|
||||
|
||||
USHORT NumberFeatureButtonCaps;
|
||||
USHORT NumberFeatureValueCaps;
|
||||
USHORT NumberFeatureDataIndices;
|
||||
};
|
||||
#include <hidsdi.h>
|
||||
|
||||
struct HidDeviceInfo {
|
||||
HIDP_CAPS caps;
|
||||
|
@ -51,7 +27,6 @@ struct HidDeviceInfo {
|
|||
unsigned short pid;
|
||||
};
|
||||
|
||||
void UninitHid();
|
||||
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
#include "DeviceEnumerator.h"
|
||||
#ifdef _MSC_VER
|
||||
#include "WndProcEater.h"
|
||||
#include "HidDevice.h"
|
||||
#endif
|
||||
#include "KeyboardQueue.h"
|
||||
#include "svnrev.h"
|
||||
#include "DualShock3.h"
|
||||
#include "HidDevice.h"
|
||||
|
||||
#define WMA_FORCE_UPDATE (WM_APP + 0x537)
|
||||
#define FORCE_UPDATE_WPARAM ((WPARAM)0x74328943)
|
||||
|
@ -316,7 +316,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, void* lpvReserved) {
|
|||
while (openCount)
|
||||
PADclose();
|
||||
PADshutdown();
|
||||
UninitHid();
|
||||
UninitLibUsb();
|
||||
DeleteCriticalSection( &updateLock );
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;hid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<ModuleDefinitionFile>.\LilyPad.def</ModuleDefinitionFile>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
|
@ -151,7 +151,7 @@
|
|||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;hid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>.\LilyPad.def</ModuleDefinitionFile>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
|
@ -194,7 +194,7 @@
|
|||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;hid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
|
@ -226,7 +226,7 @@
|
|||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Setupapi.lib;Winmm.lib;Comdlg32.lib;dinput8.lib;dxguid.lib;comctl32.lib;hid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)64.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>.\LilyPad.def</ModuleDefinitionFile>
|
||||
|
|
Loading…
Reference in New Issue