📄 hid.pas
字号:
{******************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ Public Definitions of HID functions from HID.DLL }
{ }
{ Portions created by Microsoft are }
{ Copyright (C) 1995-1999 Microsoft Corporation. }
{ All Rights Reserved. }
{ }
{ The original file are: hidsdi.h, hidpi.h, released March 1999. }
{ The original Pascal code is: Hid.pas, released 29 Jan 2000. }
{ The initial developer of the Pascal code is Robert Marquardt }
{ (robert_marquardt att gmx dott de) }
{ }
{ Portions created by Robert Marquardt are }
{ Copyright (C) 1999, 2000 Robert Marquardt. }
{ }
{ Contributor(s): Marcel van Brakel (brakelm att bart dott nl) }
{ }
{ Obtained through: }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/NPL/NPL-1_1Final.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{******************************************************************}
unit Hid;
interface
{$WEAKPACKAGEUNIT}
// (rom) loads HID.DLL dynamically
{$DEFINE HID_LINKONREQUEST}
// (rom) enable for functions only in HID.DLL of Windows 98 SE or better
{ $ DEFINE WIN2000}
// (rom) enable for functions only in HID.DLL of Windows XP
{ $ DEFINE WINXP}
{$IFDEF WINXP}
{$DEFINE WIN2000}
{$ENDIF WINXP}
uses
Windows;
{$ALIGN ON}
type
// (rom) moved from HidUsage.pas
PUsage = ^TUsage;
TUsage = Word;
// (rom) from WINNT.H
NTSTATUS = Longint;
{$EXTERNALSYM NTSTATUS}
// FACILITY_HID_ERROR_CODE defined in ntstatus.h
const
FACILITY_HID_ERROR_CODE = $11;
{$EXTERNALSYM FACILITY_HID_ERROR_CODE}
//
// Define NT Status codes with Facility Code of FACILITY_HID_ERROR_CODE
// (rom) vv
HIDP_STATUS_SUCCESS = NTSTATUS($00110000);
HIDP_STATUS_NULL = NTSTATUS($80110001);
HIDP_STATUS_INVALID_PREPARSED_DATA = NTSTATUS($C0110001);
HIDP_STATUS_INVALID_REPORT_TYPE = NTSTATUS($C0110002);
HIDP_STATUS_INVALID_REPORT_LENGTH = NTSTATUS($C0110003);
HIDP_STATUS_USAGE_NOT_FOUND = NTSTATUS($C0110004);
HIDP_STATUS_VALUE_OUT_OF_RANGE = NTSTATUS($C0110005);
HIDP_STATUS_BAD_LOG_PHY_VALUES = NTSTATUS($C0110006);
HIDP_STATUS_BUFFER_TOO_SMALL = NTSTATUS($C0110007);
HIDP_STATUS_INTERNAL_ERROR = NTSTATUS($C0110008);
HIDP_STATUS_I8042_TRANS_UNKNOWN = NTSTATUS($C0110009);
HIDP_STATUS_INCOMPATIBLE_REPORT_ID = NTSTATUS($C011000A);
HIDP_STATUS_NOT_VALUE_ARRAY = NTSTATUS($C011000B);
HIDP_STATUS_IS_VALUE_ARRAY = NTSTATUS($C011000C);
HIDP_STATUS_DATA_INDEX_NOT_FOUND = NTSTATUS($C011000D);
HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE = NTSTATUS($C011000E);
HIDP_STATUS_BUTTON_NOT_PRESSED = NTSTATUS($C011000F);
HIDP_STATUS_REPORT_DOES_NOT_EXIST = NTSTATUS($C0110010);
HIDP_STATUS_NOT_IMPLEMENTED = NTSTATUS($C0110020);
//
// We blundered this status code.
//
HIDP_STATUS_I8242_TRANS_UNKNOWN = HIDP_STATUS_I8042_TRANS_UNKNOWN;
// Special Link collection values for using the query functions
//
// Root collection references the collection at the base of the link
// collection tree.
// Unspecifies, references all collections in the link collection tree.
HIDP_LINK_COLLECTION_ROOT = -1;
HIDP_LINK_COLLECTION_UNSPECIFIED = 0;
// A bitmap of the current shift state of the keyboard when using the
// below keyboard usages to i8042 translation function.
const
// (rom) values for the bits of THIDPKeyboardModifierState
kmsLeftControl = $0001;
kmsLeftShift = $0002;
kmsLeftAlt = $0004;
kmsLeftGUI = $0008;
kmsRightControl = $0010;
kmsRightShift = $0020;
kmsRightAlt = $0040;
kmsRightGUI = $0080;
kmsCapsLock = $0100;
kmsScollLock = $0200;
kmsNumLock = $0400;
type
THIDPKeyboardModifierState = DWORD;
// (rom) bit value to check IsAlias of THIDPLinkCollectionNode
const
lcnIsAlias = 1;
type
// (rom) to represent the union names
THIDVariantFlags = (Range, NotRange);
PHIDDConfiguration = ^THIDDConfiguration;
HIDD_CONFIGURATION = record
cookie: Pointer;
size: ULONG;
RingBufferSize: ULONG;
end;
THIDDConfiguration = HIDD_CONFIGURATION;
PHIDDAttributes = ^THIDDAttributes;
HIDD_ATTRIBUTES = record
Size: ULONG; // size of structure (set before call)
VendorID: Word;
ProductID: Word;
VersionNumber: Word;
//
// Additional fields will be added to the end of this structure.
//
end;
THIDDAttributes = HIDD_ATTRIBUTES;
PHIDPPreparsedData = Pointer;
const
HidP_Input = 0;
HidP_Output = 1;
HidP_Feature = 2;
type
PHIDPReportType = ^THIDPReportType;
THIDPReportType = DWORD;
const
// Produce Make or Break Codes
HidP_Keyboard_Break = 0;
HidP_Keyboard_Make = 1;
type
PHIDPKeyboardDirection = ^THIDPKeyboardDirection;
THIDPKeyboardDirection = DWORD;
PUsageAndPage = ^TUsageAndPage;
USAGE_AND_PAGE = record
Usage: TUsage;
UsagePage: TUsage;
end;
TUsageAndPage = USAGE_AND_PAGE;
PHIDPButtonCaps = ^THIDPButtonCaps;
HIDP_BUTTON_CAPS = record
UsagePage: TUsage;
ReportID: BYTE;
IsAlias: ByteBool;
BitField: Word;
LinkCollection: Word; // A unique internal index pointer
LinkUsage: TUsage;
LinkUsagePage: TUsage;
IsRange: ByteBool;
IsStringRange: ByteBool;
IsDesignatorRange: ByteBool;
IsAbsolute: ByteBool;
Reserved: array [0..9] of ULONG;
case THIDVariantFlags of
Range:
( UsageMin, UsageMax: TUsage;
StringMin, StringMax,
DesignatorMin, DesignatorMax,
DataIndexMin, DataIndexMax: Word );
NotRange:
( Usage, Reserved1: TUsage;
StringIndex, Reserved2,
DesignatorIndex, Reserved3,
DataIndex, Reserved4: Word );
end;
THIDPButtonCaps = HIDP_BUTTON_CAPS;
PHIDPValueCaps = ^THIDPValueCaps;
HIDP_VALUE_CAPS = record
UsagePage: TUsage;
ReportID: BYTE;
IsAlias: ByteBool;
BitField: Word;
LinkCollection: Word; // A unique internal index pointer
LinkUsage: TUsage;
LinkUsagePage: TUsage;
IsRange: ByteBool;
IsStringRange: ByteBool;
IsDesignatorRange: ByteBool;
IsAbsolute: ByteBool;
HasNull: ByteBool; // Does this channel have a null report union
Reserved: BYTE;
BitSize: Word; // How many bits are devoted to this value?
ReportCount: Word; // See Note below. Usually set to 1.
Reserved_: array [0..4] of Word;
// (rom) name change Reserved2 gives name clash in Pascal
UnitsExp: ULONG;
Units: ULONG;
LogicalMin: Integer;
LogicalMax: Integer;
PhysicalMin: Integer;
PhysicalMax: Integer;
case THIDVariantFlags of
Range:
( UsageMin, UsageMax: TUsage;
StringMin, StringMax,
DesignatorMin, DesignatorMax,
DataIndexMin, DataIndexMax: Word );
NotRange:
( Usage, Reserved1: TUsage;
StringIndex, Reserved2,
DesignatorIndex, Reserved3,
DataIndex, Reserved4: Word );
end;
THIDPValueCaps = HIDP_VALUE_CAPS;
//
// Notes:
//
// ReportCount: When a report descriptor declares an Input, Output, or
// Feature main item with fewer usage declarations than the report count, then
// the last usage applies to all remaining unspecified count in that main item.
// (As an example you might have data that required many fields to describe,
// possibly buffered bytes.) In this case, only one value cap structure is
// allocated for these associtated fields, all with the same usage, and Report
// Count reflects the number of fields involved. Normally ReportCount is 1.
// To access all of the fields in such a value structure would require using
// HidP_GetUsageValueArray and HidP_SetUsageValueArray. HidP_GetUsageValue/
// HidP_SetScaledUsageValue will also work, however, these functions will only
// work with the first field of the structure.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -