Path: blob/master/thirdparty/sdl/core/windows/SDL_hid.h
9905 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/20#include "SDL_internal.h"2122#ifndef SDL_hid_h_23#define SDL_hid_h_2425#include "SDL_windows.h"2627typedef LONG NTSTATUS;28typedef USHORT USAGE;29typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA;3031typedef struct _HIDD_ATTRIBUTES32{33ULONG Size;34USHORT VendorID;35USHORT ProductID;36USHORT VersionNumber;37} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;3839typedef enum40{41HidP_Input = 0,42HidP_Output = 1,43HidP_Feature = 244} HIDP_REPORT_TYPE;4546typedef struct47{48USAGE UsagePage;49UCHAR ReportID;50BOOLEAN IsAlias;51USHORT BitField;52USHORT LinkCollection;53USAGE LinkUsage;54USAGE LinkUsagePage;55BOOLEAN IsRange;56BOOLEAN IsStringRange;57BOOLEAN IsDesignatorRange;58BOOLEAN IsAbsolute;59ULONG Reserved[10];60union61{62struct63{64USAGE UsageMin;65USAGE UsageMax;66USHORT StringMin;67USHORT StringMax;68USHORT DesignatorMin;69USHORT DesignatorMax;70USHORT DataIndexMin;71USHORT DataIndexMax;72} Range;73struct74{75USAGE Usage;76USAGE Reserved1;77USHORT StringIndex;78USHORT Reserved2;79USHORT DesignatorIndex;80USHORT Reserved3;81USHORT DataIndex;82USHORT Reserved4;83} NotRange;84};85} HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;8687typedef struct88{89USAGE UsagePage;90UCHAR ReportID;91BOOLEAN IsAlias;92USHORT BitField;93USHORT LinkCollection;94USAGE LinkUsage;95USAGE LinkUsagePage;96BOOLEAN IsRange;97BOOLEAN IsStringRange;98BOOLEAN IsDesignatorRange;99BOOLEAN IsAbsolute;100BOOLEAN HasNull;101UCHAR Reserved;102USHORT BitSize;103USHORT ReportCount;104USHORT Reserved2[5];105ULONG UnitsExp;106ULONG Units;107LONG LogicalMin;108LONG LogicalMax;109LONG PhysicalMin;110LONG PhysicalMax;111union112{113struct114{115USAGE UsageMin;116USAGE UsageMax;117USHORT StringMin;118USHORT StringMax;119USHORT DesignatorMin;120USHORT DesignatorMax;121USHORT DataIndexMin;122USHORT DataIndexMax;123} Range;124struct125{126USAGE Usage;127USAGE Reserved1;128USHORT StringIndex;129USHORT Reserved2;130USHORT DesignatorIndex;131USHORT Reserved3;132USHORT DataIndex;133USHORT Reserved4;134} NotRange;135};136} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;137138typedef struct139{140USAGE Usage;141USAGE UsagePage;142USHORT InputReportByteLength;143USHORT OutputReportByteLength;144USHORT FeatureReportByteLength;145USHORT Reserved[17];146USHORT NumberLinkCollectionNodes;147USHORT NumberInputButtonCaps;148USHORT NumberInputValueCaps;149USHORT NumberInputDataIndices;150USHORT NumberOutputButtonCaps;151USHORT NumberOutputValueCaps;152USHORT NumberOutputDataIndices;153USHORT NumberFeatureButtonCaps;154USHORT NumberFeatureValueCaps;155USHORT NumberFeatureDataIndices;156} HIDP_CAPS, *PHIDP_CAPS;157158typedef struct159{160USHORT DataIndex;161USHORT Reserved;162union163{164ULONG RawValue;165BOOLEAN On;166};167} HIDP_DATA, *PHIDP_DATA;168169#define HIDP_ERROR_CODES(p1, p2) ((NTSTATUS)(((p1) << 28) | (0x11 << 16) | (p2)))170#define HIDP_STATUS_SUCCESS HIDP_ERROR_CODES(0x0, 0x0000)171#define HIDP_STATUS_NULL HIDP_ERROR_CODES(0x8, 0x0001)172#define HIDP_STATUS_INVALID_PREPARSED_DATA HIDP_ERROR_CODES(0xC, 0x0001)173#define HIDP_STATUS_INVALID_REPORT_TYPE HIDP_ERROR_CODES(0xC, 0x0002)174#define HIDP_STATUS_INVALID_REPORT_LENGTH HIDP_ERROR_CODES(0xC, 0x0003)175#define HIDP_STATUS_USAGE_NOT_FOUND HIDP_ERROR_CODES(0xC, 0x0004)176#define HIDP_STATUS_VALUE_OUT_OF_RANGE HIDP_ERROR_CODES(0xC, 0x0005)177#define HIDP_STATUS_BAD_LOG_PHY_VALUES HIDP_ERROR_CODES(0xC, 0x0006)178#define HIDP_STATUS_BUFFER_TOO_SMALL HIDP_ERROR_CODES(0xC, 0x0007)179#define HIDP_STATUS_INTERNAL_ERROR HIDP_ERROR_CODES(0xC, 0x0008)180#define HIDP_STATUS_I8042_TRANS_UNKNOWN HIDP_ERROR_CODES(0xC, 0x0009)181#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID HIDP_ERROR_CODES(0xC, 0x000A)182#define HIDP_STATUS_NOT_VALUE_ARRAY HIDP_ERROR_CODES(0xC, 0x000B)183#define HIDP_STATUS_IS_VALUE_ARRAY HIDP_ERROR_CODES(0xC, 0x000C)184#define HIDP_STATUS_DATA_INDEX_NOT_FOUND HIDP_ERROR_CODES(0xC, 0x000D)185#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE HIDP_ERROR_CODES(0xC, 0x000E)186#define HIDP_STATUS_BUTTON_NOT_PRESSED HIDP_ERROR_CODES(0xC, 0x000F)187#define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES(0xC, 0x0010)188#define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES(0xC, 0x0020)189190extern bool WIN_LoadHIDDLL(void);191extern void WIN_UnloadHIDDLL(void);192193typedef BOOLEAN (WINAPI *HidD_GetAttributes_t)(HANDLE HidDeviceObject, PHIDD_ATTRIBUTES Attributes);194typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);195typedef NTSTATUS (WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities);196typedef NTSTATUS (WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);197typedef NTSTATUS (WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);198typedef ULONG (WINAPI *HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData);199typedef NTSTATUS (WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);200201extern HidD_GetAttributes_t SDL_HidD_GetAttributes;202extern HidD_GetString_t SDL_HidD_GetManufacturerString;203extern HidD_GetString_t SDL_HidD_GetProductString;204extern HidP_GetCaps_t SDL_HidP_GetCaps;205extern HidP_GetButtonCaps_t SDL_HidP_GetButtonCaps;206extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps;207extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength;208extern HidP_GetData_t SDL_HidP_GetData;209210void WIN_InitDeviceNotification(void);211Uint64 WIN_GetLastDeviceNotification(void);212void WIN_QuitDeviceNotification(void);213214#endif // SDL_hid_h_215216217