SAMV71 Xplained Ultra Software Package 1.3

hid.h

00001 /*++
00002 
00003 Copyright (c) Microsoft 1998, All Rights Reserved
00004 
00005 Module Name:
00006 
00007     hid.h
00008 
00009 Abstract:
00010 
00011     This module contains the declarations and definitions for use with the
00012     hid user mode client sample driver.
00013 
00014 Environment:
00015 
00016     Kernel & user mode
00017 
00018 --*/
00019 
00020 #ifndef HID_H
00021 #define HID_H
00022 
00023 #include "hidsdi.h"
00024 #include "setupapi.h"
00025 
00026 typedef struct _SP_FNCLASS_DEVICE_DATA {
00027    DWORD cbSize;
00028    GUID  FunctionClassGuid;
00029    TCHAR DevicePath [ANYSIZE_ARRAY];
00030 } SP_FNCLASS_DEVICE_DATA, *PSP_FNCLASS_DEVICE_DATA;
00031 
00032 BOOLEAN
00033 SetupDiGetFunctionClassDeviceInfo (
00034    IN    HDEVINFO                DeviceInfoSet,
00035    IN    PSP_DEVINFO_DATA        DeviceInfoData,
00036    OUT   PSP_FNCLASS_DEVICE_DATA FunctionClassDeviceData,
00037    IN    DWORD                   FunctionClassDeviceDataSize,
00038    OUT   PDWORD                  RequiredSize
00039    );
00040 
00041 #define ASSERT(x)
00042 
00043 //
00044 // A structure to hold the steady state data received from the hid device.
00045 // Each time a read packet is received we fill in this structure.
00046 // Each time we wish to write to a hid device we fill in this structure.
00047 // This structure is here only for convenience.  Most real applications will
00048 // have a more efficient way of moving the hid data to the read, write, and
00049 // feature routines.
00050 //
00051 typedef struct _HID_DATA {
00052    BOOLEAN     IsButtonData;
00053    UCHAR       Reserved;
00054    USAGE       UsagePage;   // The usage page for which we are looking.
00055    ULONG       Status;      // The last status returned from the accessor function
00056                             // when updating this field.
00057    ULONG       ReportID;    // ReportID for this given data structure
00058    BOOLEAN     IsDataSet;   // Variable to track whether a given data structure
00059                             //  has already been added to a report structure
00060 
00061    union {
00062       struct {
00063          ULONG       UsageMin;       // Variables to track the usage minimum and max
00064          ULONG       UsageMax;       // If equal, then only a single usage
00065          ULONG       MaxUsageLength; // Usages buffer length.
00066          PUSAGE      Usages;         // list of usages (buttons ``down'' on the device.
00067 
00068       } ButtonData;
00069       struct {
00070          USAGE       Usage; // The usage describing this value;
00071          USHORT      Reserved;
00072 
00073          ULONG       Value;
00074          LONG        ScaledValue;
00075       } ValueData;
00076    };
00077 } HID_DATA, *PHID_DATA;
00078 
00079 typedef struct _HID_DEVICE {   
00080     PCHAR                DevicePath;
00081     HANDLE               HidDevice; // A file handle to the hid device.
00082     BOOL                 OpenedForRead;
00083     BOOL                 OpenedForWrite;
00084     BOOL                 OpenedOverlapped;
00085     BOOL                 OpenedExclusive;
00086     
00087     PHIDP_PREPARSED_DATA Ppd; // The opaque parser info describing this device
00088     HIDP_CAPS            Caps; // The Capabilities of this hid device.
00089     HIDD_ATTRIBUTES      Attributes;
00090 
00091     PCHAR                InputReportBuffer;
00092     PHID_DATA            InputData; // array of hid data structures
00093     ULONG                InputDataLength; // Num elements in this array.
00094     PHIDP_BUTTON_CAPS    InputButtonCaps;
00095     PHIDP_VALUE_CAPS     InputValueCaps;
00096 
00097     PCHAR                OutputReportBuffer;
00098     PHID_DATA            OutputData;
00099     ULONG                OutputDataLength;
00100     PHIDP_BUTTON_CAPS    OutputButtonCaps;
00101     PHIDP_VALUE_CAPS     OutputValueCaps;
00102 
00103     PCHAR                FeatureReportBuffer;
00104     PHID_DATA            FeatureData;
00105     ULONG                FeatureDataLength;
00106     PHIDP_BUTTON_CAPS    FeatureButtonCaps;
00107     PHIDP_VALUE_CAPS     FeatureValueCaps;
00108 } HID_DEVICE, *PHID_DEVICE;
00109 
00110 
00111 BOOLEAN
00112 OpenHidDevice (
00113     IN       PCHAR          DevicePath,
00114     IN       BOOL           HasReadAccess,
00115     IN       BOOL           HasWriteAccess,
00116     IN       BOOL           IsOverlapped,
00117     IN       BOOL           IsExclusive,
00118     IN OUT   PHID_DEVICE    HidDevice
00119 );
00120 
00121 BOOLEAN
00122 FindKnownHidDevices (
00123    OUT PHID_DEVICE * HidDevices, // A array of struct _HID_DEVICE
00124    OUT PULONG        NumberDevices // the length of this array.
00125    );
00126 
00127 BOOLEAN
00128 FillDeviceInfo(
00129     IN  PHID_DEVICE HidDevice
00130 );
00131 
00132 VOID
00133 CloseHidDevices (
00134    OUT PHID_DEVICE   HidDevices, // A array of struct _HID_DEVICE
00135    OUT ULONG         NumberDevices // the length of this array.
00136    );
00137 
00138 VOID
00139 CloseHidDevice (
00140     IN PHID_DEVICE   HidDevice
00141     );
00142 
00143 
00144 BOOLEAN
00145 Read (
00146    PHID_DEVICE    HidDevice
00147    );
00148 
00149 BOOLEAN
00150 ReadOverlapped (
00151     PHID_DEVICE     HidDevice,
00152     HANDLE          CompletionEvent
00153    );
00154    
00155 BOOLEAN
00156 Write (
00157    PHID_DEVICE    HidDevice
00158    );
00159 
00160 BOOLEAN
00161 UnpackReport (
00162    IN       PCHAR                ReportBuffer,
00163    IN       USHORT               ReportBufferLength,
00164    IN       HIDP_REPORT_TYPE     ReportType,
00165    IN OUT   PHID_DATA            Data,
00166    IN       ULONG                DataLength,
00167    IN       PHIDP_PREPARSED_DATA Ppd
00168    );
00169 
00170 BOOLEAN
00171 SetFeature (
00172    PHID_DEVICE    HidDevice
00173    );
00174 
00175 BOOLEAN
00176 GetFeature (
00177    PHID_DEVICE    HidDevice
00178    );
00179 
00180 #endif
00181 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines