sdl

FORK: Simple Directmedia Layer
git clone https://git.neptards.moe/neptards/sdl.git
Log | Files | Refs

SDL_hid.h (7489B)


      1 /*
      2   Simple DirectMedia Layer
      3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
      4 
      5   This software is provided 'as-is', without any express or implied
      6   warranty.  In no event will the authors be held liable for any damages
      7   arising from the use of this software.
      8 
      9   Permission is granted to anyone to use this software for any purpose,
     10   including commercial applications, and to alter it and redistribute it
     11   freely, subject to the following restrictions:
     12 
     13   1. The origin of this software must not be misrepresented; you must not
     14      claim that you wrote the original software. If you use this software
     15      in a product, an acknowledgment in the product documentation would be
     16      appreciated but is not required.
     17   2. Altered source versions must be plainly marked as such, and must not be
     18      misrepresented as being the original software.
     19   3. This notice may not be removed or altered from any source distribution.
     20 */
     21 #include "../../SDL_internal.h"
     22 
     23 #ifndef SDL_hid_h_
     24 #define SDL_hid_h_
     25 
     26 #include "SDL_windows.h"
     27 
     28 #ifndef __WINRT__
     29 
     30 typedef LONG NTSTATUS;
     31 typedef USHORT USAGE;
     32 typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA;
     33 
     34 typedef struct _HIDD_ATTRIBUTES
     35 {
     36     ULONG Size;
     37     USHORT VendorID;
     38     USHORT ProductID;
     39     USHORT VersionNumber;
     40 } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
     41 
     42 typedef enum {
     43     HidP_Input = 0,
     44     HidP_Output = 1,
     45     HidP_Feature = 2
     46 } HIDP_REPORT_TYPE;
     47 
     48 typedef struct {
     49     USAGE   UsagePage;
     50     UCHAR   ReportID;
     51     BOOLEAN IsAlias;
     52     USHORT  BitField;
     53     USHORT  LinkCollection;
     54     USAGE   LinkUsage;
     55     USAGE   LinkUsagePage;
     56     BOOLEAN IsRange;
     57     BOOLEAN IsStringRange;
     58     BOOLEAN IsDesignatorRange;
     59     BOOLEAN IsAbsolute;
     60     ULONG   Reserved[ 10 ];
     61     union {
     62         struct {
     63             USAGE   UsageMin;
     64             USAGE   UsageMax;
     65             USHORT  StringMin;
     66             USHORT  StringMax;
     67             USHORT  DesignatorMin;
     68             USHORT  DesignatorMax;
     69             USHORT  DataIndexMin;
     70             USHORT  DataIndexMax;
     71         } Range;
     72         struct {
     73             USAGE   Usage;
     74             USAGE   Reserved1;
     75             USHORT  StringIndex;
     76             USHORT  Reserved2;
     77             USHORT  DesignatorIndex;
     78             USHORT  Reserved3;
     79             USHORT  DataIndex;
     80             USHORT  Reserved4;
     81         } NotRange;
     82     };
     83 } HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;
     84 
     85 typedef struct {
     86     USAGE   UsagePage;
     87     UCHAR   ReportID;
     88     BOOLEAN IsAlias;
     89     USHORT  BitField;
     90     USHORT  LinkCollection;
     91     USAGE   LinkUsage;
     92     USAGE   LinkUsagePage;
     93     BOOLEAN IsRange;
     94     BOOLEAN IsStringRange;
     95     BOOLEAN IsDesignatorRange;
     96     BOOLEAN IsAbsolute;
     97     BOOLEAN HasNull;
     98     UCHAR   Reserved;
     99     USHORT  BitSize;
    100     USHORT  ReportCount;
    101     USHORT  Reserved2[ 5 ];
    102     ULONG   UnitsExp;
    103     ULONG   Units;
    104     LONG    LogicalMin;
    105     LONG    LogicalMax;
    106     LONG    PhysicalMin;
    107     LONG    PhysicalMax;
    108     union {
    109         struct {
    110             USAGE   UsageMin;
    111             USAGE   UsageMax;
    112             USHORT  StringMin;
    113             USHORT  StringMax;
    114             USHORT  DesignatorMin;
    115             USHORT  DesignatorMax;
    116             USHORT  DataIndexMin;
    117             USHORT  DataIndexMax;
    118         } Range;
    119         struct {
    120             USAGE   Usage;
    121             USAGE   Reserved1;
    122             USHORT  StringIndex;
    123             USHORT  Reserved2;
    124             USHORT  DesignatorIndex;
    125             USHORT  Reserved3;
    126             USHORT  DataIndex;
    127             USHORT  Reserved4;
    128         } NotRange;
    129     };
    130 } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
    131 
    132 typedef struct {
    133     USAGE   Usage;
    134     USAGE   UsagePage;
    135     USHORT  InputReportByteLength;
    136     USHORT  OutputReportByteLength;
    137     USHORT  FeatureReportByteLength;
    138     USHORT  Reserved[ 17 ];
    139     USHORT  NumberLinkCollectionNodes;
    140     USHORT  NumberInputButtonCaps;
    141     USHORT  NumberInputValueCaps;
    142     USHORT  NumberInputDataIndices;
    143     USHORT  NumberOutputButtonCaps;
    144     USHORT  NumberOutputValueCaps;
    145     USHORT  NumberOutputDataIndices;
    146     USHORT  NumberFeatureButtonCaps;
    147     USHORT  NumberFeatureValueCaps;
    148     USHORT  NumberFeatureDataIndices;
    149 } HIDP_CAPS, *PHIDP_CAPS;
    150 
    151 typedef struct {
    152     USHORT  DataIndex;
    153     USHORT  Reserved;
    154     union {
    155         ULONG   RawValue;
    156         BOOLEAN On;
    157     };
    158 } HIDP_DATA, *PHIDP_DATA;
    159 
    160 #define HIDP_ERROR_CODES( p1, p2 ) ((NTSTATUS)(((p1) << 28) | (0x11 << 16) | (p2)))
    161 #define HIDP_STATUS_SUCCESS                 HIDP_ERROR_CODES( 0x0, 0x0000 )
    162 #define HIDP_STATUS_NULL                    HIDP_ERROR_CODES( 0x8, 0x0001 )
    163 #define HIDP_STATUS_INVALID_PREPARSED_DATA  HIDP_ERROR_CODES( 0xC, 0x0001 )
    164 #define HIDP_STATUS_INVALID_REPORT_TYPE     HIDP_ERROR_CODES( 0xC, 0x0002 )
    165 #define HIDP_STATUS_INVALID_REPORT_LENGTH   HIDP_ERROR_CODES( 0xC, 0x0003 )
    166 #define HIDP_STATUS_USAGE_NOT_FOUND         HIDP_ERROR_CODES( 0xC, 0x0004 )
    167 #define HIDP_STATUS_VALUE_OUT_OF_RANGE      HIDP_ERROR_CODES( 0xC, 0x0005 )
    168 #define HIDP_STATUS_BAD_LOG_PHY_VALUES      HIDP_ERROR_CODES( 0xC, 0x0006 )
    169 #define HIDP_STATUS_BUFFER_TOO_SMALL        HIDP_ERROR_CODES( 0xC, 0x0007 )
    170 #define HIDP_STATUS_INTERNAL_ERROR          HIDP_ERROR_CODES( 0xC, 0x0008 )
    171 #define HIDP_STATUS_I8042_TRANS_UNKNOWN     HIDP_ERROR_CODES( 0xC, 0x0009 )
    172 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID  HIDP_ERROR_CODES( 0xC, 0x000A )
    173 #define HIDP_STATUS_NOT_VALUE_ARRAY         HIDP_ERROR_CODES( 0xC, 0x000B )
    174 #define HIDP_STATUS_IS_VALUE_ARRAY          HIDP_ERROR_CODES( 0xC, 0x000C )
    175 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND    HIDP_ERROR_CODES( 0xC, 0x000D )
    176 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE HIDP_ERROR_CODES( 0xC, 0x000E )
    177 #define HIDP_STATUS_BUTTON_NOT_PRESSED      HIDP_ERROR_CODES( 0xC, 0x000F )
    178 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST   HIDP_ERROR_CODES( 0xC, 0x0010 )
    179 #define HIDP_STATUS_NOT_IMPLEMENTED         HIDP_ERROR_CODES( 0xC, 0x0020 )
    180 
    181 
    182 extern int WIN_LoadHIDDLL(void);
    183 extern void WIN_UnloadHIDDLL(void);
    184 
    185 typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);
    186 typedef BOOLEAN (WINAPI *HidD_GetPreparsedData_t)(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData);
    187 typedef BOOLEAN (WINAPI *HidD_FreePreparsedData_t)(PHIDP_PREPARSED_DATA PreparsedData);
    188 typedef NTSTATUS (WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities);
    189 typedef NTSTATUS (WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
    190 typedef NTSTATUS (WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
    191 typedef ULONG (WINAPI *HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData);
    192 typedef NTSTATUS (WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
    193 
    194 extern HidD_GetString_t SDL_HidD_GetManufacturerString;
    195 extern HidD_GetString_t SDL_HidD_GetProductString;
    196 extern HidD_GetPreparsedData_t SDL_HidD_GetPreparsedData;
    197 extern HidD_FreePreparsedData_t SDL_HidD_FreePreparsedData;
    198 extern HidP_GetCaps_t SDL_HidP_GetCaps;
    199 extern HidP_GetButtonCaps_t SDL_HidP_GetButtonCaps;
    200 extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps;
    201 extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength;
    202 extern HidP_GetData_t SDL_HidP_GetData;
    203 
    204 #endif /* !__WINRT__ */
    205 
    206 #endif /* SDL_hid_h_ */
    207 
    208 /* vi: set ts=4 sw=4 expandtab: */