Win32Hid.cs
author sl
Tue, 23 Dec 2014 21:17:17 +0100
changeset 40 b3e177062849
parent 24 974f5fdaebfb
child 50 e6c103ebb155
permissions -rw-r--r--
Adding colums to our listview.
     1 using System;
     2 using System.Runtime.InteropServices;
     3 using Microsoft.Win32.SafeHandles;
     4 using System.Text;
     5 
     6 namespace Win32
     7 {
     8 
     9     static partial class Function
    10     {
    11         [DllImport("hid.dll", CharSet = CharSet.Unicode)]
    12         public static extern HidStatus HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, ushort LinkCollection, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] USAGE_AND_PAGE[] ButtonList, ref uint UsageLength, IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPArray)] byte[] Report, uint ReportLength);
    13 
    14         [DllImport("hid.dll", CharSet = CharSet.Auto, SetLastError = true)]
    15         public static extern Boolean HidD_GetManufacturerString(SafeFileHandle HidDeviceObject, StringBuilder Buffer, Int32 BufferLength);
    16 
    17         [DllImport("hid.dll", CharSet = CharSet.Auto, SetLastError = true)]
    18         public static extern Boolean HidD_GetProductString(SafeFileHandle HidDeviceObject, StringBuilder Buffer, Int32 BufferLength);
    19 
    20         [DllImport("hid.dll", CharSet = CharSet.Auto, SetLastError = true)]
    21         public static extern Boolean HidD_GetAttributes(SafeFileHandle HidDeviceObject, ref HIDD_ATTRIBUTES Attributes);
    22     }
    23 
    24 
    25     static partial class Macro
    26     {
    27 
    28 
    29     }
    30 
    31 
    32     static partial class Const
    33     {
    34 
    35 
    36     }
    37 
    38 
    39     public enum HIDP_REPORT_TYPE : ushort
    40     {
    41         HidP_Input = 0,
    42         HidP_Output,
    43         HidP_Feature
    44     }
    45 
    46 
    47     public enum HidStatus : uint
    48     {
    49         HIDP_STATUS_SUCCESS = 0x110000,
    50         HIDP_STATUS_NULL = 0x80110001,
    51         HIDP_STATUS_INVALID_PREPARSED_DATA = 0xc0110001,
    52         HIDP_STATUS_INVALID_REPORT_TYPE = 0xc0110002,
    53         HIDP_STATUS_INVALID_REPORT_LENGTH = 0xc0110003,
    54         HIDP_STATUS_USAGE_NOT_FOUND = 0xc0110004,
    55         HIDP_STATUS_VALUE_OUT_OF_RANGE = 0xc0110005,
    56         HIDP_STATUS_BAD_LOG_PHY_VALUES = 0xc0110006,
    57         HIDP_STATUS_BUFFER_TOO_SMALL = 0xc0110007,
    58         HIDP_STATUS_INTERNAL_ERROR = 0xc0110008,
    59         HIDP_STATUS_I8042_TRANS_UNKNOWN = 0xc0110009,
    60         HIDP_STATUS_INCOMPATIBLE_REPORT_ID = 0xc011000a,
    61         HIDP_STATUS_NOT_VALUE_ARRAY = 0xc011000b,
    62         HIDP_STATUS_IS_VALUE_ARRAY = 0xc011000c,
    63         HIDP_STATUS_DATA_INDEX_NOT_FOUND = 0xc011000d,
    64         HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE = 0xc011000e,
    65         HIDP_STATUS_BUTTON_NOT_PRESSED = 0xc011000f,
    66         HIDP_STATUS_REPORT_DOES_NOT_EXIST = 0xc0110010,
    67         HIDP_STATUS_NOT_IMPLEMENTED = 0xc0110020,
    68         HIDP_STATUS_I8242_TRANS_UNKNOWN = 0xc0110009
    69     }
    70 
    71 
    72     [StructLayout(LayoutKind.Sequential)]
    73     public struct USAGE_AND_PAGE
    74     {
    75         public ushort Usage;
    76         public ushort UsagePage;
    77     };
    78 
    79     [StructLayout(LayoutKind.Sequential)]
    80     public struct HIDD_ATTRIBUTES
    81     {
    82         public uint Size;
    83         public ushort VendorID;
    84         public ushort ProductID;
    85         public ushort VersionNumber;
    86     }
    87 
    88 
    89 }