Update of /cvsroot/jvcl/dev/JVCL3/examples/JvHIDController/UsagesDemo In directory sc8-pr-cvs1:/tmp/cvs-serv23072/JVCL3/examples/JvHIDController/UsagesDemo Added Files: Info.dfm Info.pas UsagesDemo.dof UsagesDemo.dpr UsagesDemo.res UsagesInfo.pas UsagesMain.dfm UsagesMain.pas Log Message: new HID sample --- NEW FILE: Info.dfm --- object InfoForm: TInfoForm Left = 302 Top = 120 Width = 571 Height = 402 BorderIcons = [biSystemMenu] Caption = 'HID Device Usage Info' Color = clBtnFace Constraints.MinHeight = 250 Constraints.MinWidth = 300 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -13 Font.Name = 'MS Sans Serif' Font.Style = [] Icon.Data = { 000001000200101010000100100028010000260000002020100001001000E802 00004E0100002800000010000000200000000100040000000000C00000000000 0000000000000000000000000000000000000000800000800000008080008000 00008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF00 0000FF00FF00FFFF0000FFFFFF00000000000000000000000BBBB0000000000B B000BB000000000BB0000B000000000BBB000BB00000000BBB000BB000000000 00000BB00000000000000BB00000000000000BB00000000000000BB000000000 00000BB00000000000000BB00000000000000BB0000000000000BBBB00000000 000BBBBBB0000000000000000000FFFF0000F87F0000E73F0000E7BF0000E39F 0000E39F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F 0000FF0F0000FE070000FFFF0000280000002000000040000000010004000000 0000800200000000000000000000000000000000000000000000000080000080 000000808000800000008000800080800000C0C0C000808080000000FF0000FF 000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000 000000000000000000000000000000000000000000000000000000BBBBBB0000 00000000000000000000BBB0000BBB000000000000000000000BB00000000BBB 0000000000000000000BB00000000BBB000000000000000000BBBB0000000BBB B00000000000000000BBBB00000000BBBB0000000000000000BBBBB0000000BB BB0000000000000000BBBBB0000000BBBB0000000000000000BBBBB0000000BB BB00000000000000000BBB00000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB00000000000000000000000000BBBB BBB00000000000000000000000BBBBBBBBBBBB00000000000000000000000000 00000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFC0 FFFFFF1E3FFFFE7F8FFFFE7F8FFFFC3F87FFFC3FC3FFFC1FC3FFFC1FC3FFFC1F C3FFFE3FC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFF C3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFF C3FFFFFFC3FFFFFF01FFFFFC003FFFFFFFFFFFFFFFFF} OldCreateOrder = False Position = poOwnerFormCenter OnShow = FormShow DesignSize = ( 563 372) PixelsPerInch = 96 TextHeight = 16 object InfoMemo: TMemo Left = 0 Top = 0 Width = 561 Height = 337 Anchors = [akLeft, akTop, akRight, akBottom] Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -13 Font.Name = 'Courier New' Font.Style = [] ParentFont = False ReadOnly = True ScrollBars = ssBoth TabOrder = 0 WordWrap = False end object Save: TButton Left = 16 Top = 345 Width = 75 Height = 25 Anchors = [akLeft, akBottom] Caption = 'Save' TabOrder = 1 OnClick = SaveClick end object SaveDialog: TSaveDialog DefaultExt = 'txt' Filter = 'text files|*.txt|all files|*.*' Left = 104 Top = 328 end end --- NEW FILE: Info.pas --- unit Info; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, JvHidControllerClass; type TInfoForm = class(TForm) InfoMemo: TMemo; Save: TButton; SaveDialog: TSaveDialog; procedure FormShow(Sender: TObject); procedure CollectBtnInfo(Val: WORD; Title, TitleBar: string); procedure CollectValueInfo(Val: WORD; Title, TitleBar: string); procedure SaveClick(Sender: TObject); public Dev: TJvHidDevice; end; implementation {$R *.DFM} uses UsagesInfo, Hid; function BoolToStr(B: Boolean): string; const Strs: array [Boolean] of PChar = ('False', 'True'); begin Result := Strs[B]; end; procedure TInfoForm.CollectBtnInfo(Val: WORD; Title, TitleBar: string); var I: Integer; Ret: Integer; N: WORD; UsagePageText: string; UsageText: string; LinkUsagePageText: string; LinkUsageText: string; // more than enough Caps structures to read BtnCaps: array [0..255] of THIDPButtonCaps; begin N := Length(BtnCaps); Dev.ReportTypeParam := Val; Ret := Dev.GetButtonCaps(@BtnCaps[0], N); if Ret = HIDP_STATUS_SUCCESS then begin InfoMemo.Lines.Add(''); InfoMemo.Lines.Add(Title); InfoMemo.Lines.Add(TitleBar); for I := 0 to N-1 do begin UsageAndUsagePageText(BtnCaps[I].UsagePage, BtnCaps[I].Usage, UsagePageText, UsageText); UsageAndUsagePageText(BtnCaps[I].LinkUsagePage, BtnCaps[I].LinkUsage, LinkUsagePageText, LinkUsageText); InfoMemo.Lines.Add(''); InfoMemo.Lines.Add(Format('%u)', [I])); InfoMemo.Lines.Add(Format('UsagePage: %s ($%.4x)', [UsagePageText, BtnCaps[I].UsagePage])); InfoMemo.Lines.Add(Format('ReportID: %u', [BtnCaps[I].ReportID])); InfoMemo.Lines.Add(Format('IsAlias: %s', [BoolToStr(BtnCaps[I].IsAlias)])); InfoMemo.Lines.Add(Format('BitField: %u', [BtnCaps[I].BitField])); InfoMemo.Lines.Add(Format('LinkCollection: %u', [BtnCaps[I].LinkCollection])); InfoMemo.Lines.Add(Format('LinkUsage: %s ($%.4x)', [LinkUsageText, BtnCaps[I].LinkUsage])); InfoMemo.Lines.Add(Format('LinkUsagePage: %s ($%.4x)', [LinkUsagePageText, BtnCaps[I].LinkUsagePage])); InfoMemo.Lines.Add(Format('IsRange: %s', [BoolToStr(BtnCaps[I].IsRange)])); InfoMemo.Lines.Add(Format('IsStringRange: %s', [BoolToStr(BtnCaps[I].IsStringRange)])); InfoMemo.Lines.Add(Format('IsDesignatorRange: %s', [BoolToStr(BtnCaps[I].IsDesignatorRange)])); InfoMemo.Lines.Add(Format('IsAbsolute: %s', [BoolToStr(BtnCaps[I].IsAbsolute)])); if BtnCaps[I].IsRange then begin InfoMemo.Lines.Add(Format('UsageMin: %d UsageMax: %d', [BtnCaps[I].UsageMin, BtnCaps[I].UsageMax])); InfoMemo.Lines.Add(Format('StringMin: %d StringMax: %d', [BtnCaps[I].StringMin, BtnCaps[I].StringMax])); InfoMemo.Lines.Add(Format('DesignatorMin: %d DesignatorMax: %d', [BtnCaps[I].DesignatorMin, BtnCaps[I].DesignatorMax])); InfoMemo.Lines.Add(Format('DataIndexMin: %d DataIndexMax: %d', [BtnCaps[I].DataIndexMin, BtnCaps[I].DataIndexMax])); end else begin InfoMemo.Lines.Add(Format('Usage: %s ($%.4x)', [UsageText, BtnCaps[I].Usage])); InfoMemo.Lines.Add(Format('StringIndex: %u', [BtnCaps[I].StringIndex])); InfoMemo.Lines.Add(Format('DesignatorIndex: %u', [BtnCaps[I].DesignatorIndex])); InfoMemo.Lines.Add(Format('DataIndex: %u', [BtnCaps[I].DataIndex])); end; end; end; end; procedure TInfoForm.CollectValueInfo(Val: WORD; Title, TitleBar: string); var I: Integer; Ret: Integer; N: WORD; UsagePageText: string; UsageText: string; LinkUsagePageText: string; LinkUsageText: string; // more than enough Caps structures to read ValCaps: array [0..255] of THIDPValueCaps; begin N := Length(ValCaps); Dev.ReportTypeParam := Val; Ret := Dev.GetValueCaps(@ValCaps[0], N); if Ret = HIDP_STATUS_SUCCESS then begin InfoMemo.Lines.Add(''); InfoMemo.Lines.Add(Title); InfoMemo.Lines.Add(TitleBar); for I := 0 to N-1 do begin UsageAndUsagePageText(ValCaps[I].UsagePage, ValCaps[I].Usage, UsagePageText, UsageText); UsageAndUsagePageText(ValCaps[I].LinkUsagePage, ValCaps[I].LinkUsage, LinkUsagePageText, LinkUsageText); InfoMemo.Lines.Add(''); InfoMemo.Lines.Add(Format('%u)', [I])); InfoMemo.Lines.Add(Format('UsagePage: %s ($%.4x)', [UsagePageText, ValCaps[I].UsagePage])); InfoMemo.Lines.Add(Format('ReportID: %u', [ValCaps[I].ReportID])); InfoMemo.Lines.Add(Format('IsAlias: %s', [BoolToStr(ValCaps[I].IsAlias)])); InfoMemo.Lines.Add(Format('BitField: %u', [ValCaps[I].BitField])); InfoMemo.Lines.Add(Format('LinkCollection: %u', [ValCaps[I].LinkCollection])); InfoMemo.Lines.Add(Format('LinkUsage: %s ($%.4x)', [LinkUsageText, ValCaps[I].LinkUsage])); InfoMemo.Lines.Add(Format('LinkUsagePage: %s ($%.4x)', [LinkUsagePageText, ValCaps[I].LinkUsagePage])); InfoMemo.Lines.Add(Format('IsRange: %s', [BoolToStr(ValCaps[I].IsRange)])); InfoMemo.Lines.Add(Format('IsStringRange: %s', [BoolToStr(ValCaps[I].IsStringRange)])); InfoMemo.Lines.Add(Format('IsDesignatorRange: %s', [BoolToStr(ValCaps[I].IsDesignatorRange)])); InfoMemo.Lines.Add(Format('IsAbsolute: %s', [BoolToStr(ValCaps[I].IsAbsolute)])); InfoMemo.Lines.Add(Format('HasNull: %s', [BoolToStr(ValCaps[I].HasNull)])); InfoMemo.Lines.Add(Format('BitSize: %u', [ValCaps[I].BitSize])); InfoMemo.Lines.Add(Format('ReportCount: %u', [ValCaps[I].ReportCount])); InfoMemo.Lines.Add(Format('UnitsExp: %u', [ValCaps[I].UnitsExp])); InfoMemo.Lines.Add(Format('Units: %u', [ValCaps[I].Units])); InfoMemo.Lines.Add(Format('LogicalMin: %d', [ValCaps[I].LogicalMin])); InfoMemo.Lines.Add(Format('LogicalMax: %d', [ValCaps[I].LogicalMax])); InfoMemo.Lines.Add(Format('PhysicalMin: %d', [ValCaps[I].PhysicalMin])); InfoMemo.Lines.Add(Format('PhysicalMax: %d', [ValCaps[I].PhysicalMax])); if ValCaps[I].IsRange then begin InfoMemo.Lines.Add(Format('UsageMin: %d UsageMax: %d', [ValCaps[I].UsageMin, ValCaps[I].UsageMax])); InfoMemo.Lines.Add(Format('StringMin: %d StringMax: %d', [ValCaps[I].StringMin, ValCaps[I].StringMax])); InfoMemo.Lines.Add(Format('DesignatorMin: %d DesignatorMax: %d', [ValCaps[I].DesignatorMin, ValCaps[I].DesignatorMax])); InfoMemo.Lines.Add(Format('DataIndexMin: %d DataIndexMax: %d', [ValCaps[I].DataIndexMin, ValCaps[I].DataIndexMax])); end else begin InfoMemo.Lines.Add(Format('Usage: %s ($%.4x)', [UsageText, ValCaps[I].Usage])); InfoMemo.Lines.Add(Format('StringIndex: %u', [ValCaps[I].StringIndex])); InfoMemo.Lines.Add(Format('DesignatorIndex: %u', [ValCaps[I].DesignatorIndex])); InfoMemo.Lines.Add(Format('DataIndex: %u', [ValCaps[I].DataIndex])); end; end; end; end; procedure TInfoForm.FormShow(Sender: TObject); begin InfoMemo.Lines.Clear; if Dev.VendorName <> '' then InfoMemo.Lines.Add(Format('"%s" "%s" VID=$%.4x PID=$%.4x', [Dev.VendorName, Dev.ProductName, Dev.Attributes.VendorID, Dev.Attributes.ProductID])) else InfoMemo.Lines.Add(Format('VID=$%.4x PID=$%.4x', [Dev.Attributes.VendorID, Dev.Attributes.ProductID])); if Dev.SerialNumber <> '' then InfoMemo.Lines.Add(Format('SerialNumber=%s', [Dev.SerialNumber])); if Dev.Caps.InputReportByteLength > 0 then InfoMemo.Lines.Add(Format('Input Report Size=%d', [Dev.Caps.InputReportByteLength-1])) else InfoMemo.Lines.Add('Input Report Size=0'); if Dev.Caps.OutputReportByteLength > 0 then InfoMemo.Lines.Add(Format('Output Report Size=%d', [Dev.Caps.OutputReportByteLength-1])) else InfoMemo.Lines.Add('Output Report Size=0'); if Dev.Caps.FeatureReportByteLength > 0 then InfoMemo.Lines.Add(Format('Feature Report Size=%d', [Dev.Caps.FeatureReportByteLength-1])) else InfoMemo.Lines.Add('Feature Report Size=0'); CollectBtnInfo(HidP_Input, 'Button Input', '============'); CollectBtnInfo(HidP_Output, 'Button Output', '============='); CollectBtnInfo(HidP_Feature, 'Button Feature', '=============='); CollectValueInfo(HidP_Input, 'Value Input', '==========='); CollectValueInfo(HidP_Output, 'Value Output', '============'); CollectValueInfo(HidP_Feature, 'Value Feature', '============='); end; procedure TInfoForm.SaveClick(Sender: TObject); begin if SaveDialog.Execute then InfoMemo.Lines.SaveToFile(SaveDialog.FileName); end; end. --- NEW FILE: UsagesDemo.dof --- [FileVersion] Version=6.0 [Compiler] A=8 B=0 C=1 D=1 E=0 F=0 G=1 H=1 I=1 J=0 K=0 L=1 M=0 N=1 O=0 P=1 Q=0 R=0 S=0 T=0 U=0 V=1 W=1 X=1 Y=1 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir=..\..\..\BIN UnitOutputDir=..\..\..\DCU PackageDLLOutputDir= PackageDCPOutputDir= SearchPath=..\..\.. Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;dbrtl;adortl;vcldb;qrpt;bdertl;vcldbx;dsnap;cds;bdecds;teeui;teedb;tee;teeqr;ibxpress;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;dbexpress;dbxcds;indy;dclOffice2k;Package1;PBFolder;Slider;CoolTray;BetterADO;ClawButtonPkg;ClawLabelPkg;xxgp;DJCL60;CopyData;UsbController;visualclx;jvcljansR6;jvcljansD6;GlobusR6;GlobusD6 Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication= Launcher= UseLauncher=0 DebugCWD= [Language] ActiveLang= ProjectLang= RootDir= [Version Info] IncludeVerInfo=0 AutoIncBuild=0 MajorVer=1 MinorVer=0 Release=0 Build=0 Debug=0 PreRelease=0 Special=0 Private=0 DLL=0 Locale=1031 CodePage=1252 [Excluded Packages] d:\programme\borland\delphi6\Bin\dclsoap60.bpl=Borland SOAP Components [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlSearchPath] Count=2 Item0=..\..\.. Item1=..\.. [HistoryLists\hlUnitOutputDirectory] Count=2 Item0=..\..\..\DCU Item1=..\..\DCU [HistoryLists\hlOutputDirectorry] Count=2 Item0=..\..\..\BIN Item1=..\..\BIN --- NEW FILE: UsagesDemo.dpr --- program UsagesDemo; uses Forms, UsagesMain in 'UsagesMain.pas' {UsagesForm}, Info in 'Info.pas' {InfoForm}, UsagesInfo in 'UsagesInfo.pas'; {$R *.RES} begin Application.Initialize; Application.CreateForm(TUsagesForm, UsagesForm); Application.Run; end. --- NEW FILE: UsagesDemo.res --- (This appears to be a binary file; contents omitted.) --- NEW FILE: UsagesInfo.pas --- unit UsagesInfo; interface uses Hid, HidUsage; procedure UsageAndUsagePageText(UsagePage, Usage: TUsage; var UsagePageText, UsageText: string); implementation uses SysUtils; procedure UsageAndUsagePageText(UsagePage, Usage: TUsage; var UsagePageText, UsageText: string); begin UsagePageText := ''; UsageText := ''; case UsagePage of [...3279 lines suppressed...] UsageText := 'Track Data'; HID_USAGE_MSR_TRACK_1_DATA: UsageText := 'Track 1 Data'; HID_USAGE_MSR_TRACK_2_DATA: UsageText := 'Track 2 Data'; HID_USAGE_MSR_TRACK_3_DATA: UsageText := 'Track 3 Data'; HID_USAGE_MSR_TRACK_JIS_DATA: UsageText := 'Track JIS Data'; end; end; end; if UsagePageText = '' then UsagePageText := Format('%x', [UsagePage]); if UsageText = '' then UsageText := Format('%x', [Usage]); end; end. --- NEW FILE: UsagesMain.dfm --- object UsagesForm: TUsagesForm Left = 192 Top = 116 AutoScroll = False Caption = 'HID Usage Info' ClientHeight = 484 ClientWidth = 442 Color = clBtnFace Constraints.MinHeight = 500 Constraints.MinWidth = 450 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] Icon.Data = { 000001000200101010000100100028010000260000002020100001001000E802 00004E0100002800000010000000200000000100040000000000C00000000000 0000000000000000000000000000000000000000800000800000008080008000 00008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF00 0000FF00FF00FFFF0000FFFFFF00000000000000000000000BBBB0000000000B B000BB000000000BB0000B000000000BBB000BB00000000BBB000BB000000000 00000BB00000000000000BB00000000000000BB00000000000000BB000000000 00000BB00000000000000BB00000000000000BB0000000000000BBBB00000000 000BBBBBB0000000000000000000FFFF0000F87F0000E73F0000E7BF0000E39F 0000E39F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F0000FF9F 0000FF0F0000FE070000FFFF0000280000002000000040000000010004000000 0000800200000000000000000000000000000000000000000000000080000080 000000808000800000008000800080800000C0C0C000808080000000FF0000FF 000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000 000000000000000000000000000000000000000000000000000000BBBBBB0000 00000000000000000000BBB0000BBB000000000000000000000BB00000000BBB 0000000000000000000BB00000000BBB000000000000000000BBBB0000000BBB B00000000000000000BBBB00000000BBBB0000000000000000BBBBB0000000BB BB0000000000000000BBBBB0000000BBBB0000000000000000BBBBB0000000BB BB00000000000000000BBB00000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB0000000000000000000000000000BB BB0000000000000000000000000000BBBB00000000000000000000000000BBBB BBB00000000000000000000000BBBBBBBBBBBB00000000000000000000000000 00000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFC0 FFFFFF1E3FFFFE7F8FFFFE7F8FFFFC3F87FFFC3FC3FFFC1FC3FFFC1FC3FFFC1F C3FFFE3FC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFF C3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFF C3FFFFFFC3FFFFFF01FFFFFC003FFFFFFFFFFFFFFFFF} OldCreateOrder = False Position = poScreenCenter OnShow = FormShow DesignSize = ( 442 484) PixelsPerInch = 96 TextHeight = 13 object Info: TSpeedButton Left = 8 Top = 451 Width = 49 Height = 22 Anchors = [akLeft, akBottom] Caption = 'Info' OnClick = InfoClick end object Description: TLabel Left = 80 Top = 8 Width = 277 Height = 39 Caption = 'Shows extensive info about the Usages data of all plugged'#13#10'Human' + ' Interface Devices (a subclass of USB devices).'#13#10'This is interes' + 'ting information for USB developers.' end object DevListBox: TListBox Left = -1 Top = 56 Width = 442 Height = 385 Anchors = [akLeft, akTop, akRight, akBottom] ItemHeight = 13 TabOrder = 0 end object HidCtl: TJvHidDeviceController OnEnumerate = HidCtlEnumerate OnDeviceChange = HidCtlDeviceChange Left = 408 Top = 8 end end --- NEW FILE: UsagesMain.pas --- unit UsagesMain; interface uses Windows, SysUtils, Classes, Controls, Forms, StdCtrls, Buttons, JvHidControllerClass, Hid, HidUsage; type TUsagesForm = class(TForm) DevListBox: TListBox; HidCtl: TJvHidDeviceController; Info: TSpeedButton; Description: TLabel; procedure HidCtlDeviceChange(Sender: TObject); function HidCtlEnumerate(HidDev: TJvHidDevice; const Idx: Integer): Boolean; procedure InfoClick(Sender: TObject); procedure FormShow(Sender: TObject); public end; var UsagesForm: TUsagesForm; implementation uses Info; {$R *.DFM} procedure TUsagesForm.FormShow(Sender: TObject); begin // this compensates the possibility that HidCtlDeviceChange // may not be able to fill the listbox the first time HidCtlDeviceChange(Self); end; procedure TUsagesForm.HidCtlDeviceChange(Sender: TObject); var Dev: TJvHidDevice; I: Integer; begin // HidCtlDeviceChange happens before TUsagesForm.Create completed // DevListBox may have not been created yet if Assigned(DevListBox) then begin // hand back all the devices assigned to the list entries for I := 0 to DevListBox.Count-1 do begin Dev := TJvHidDevice(DevListBox.Items.Objects[I]); HidCtl.CheckIn(Dev); DevListBox.Items.Objects[I] := nil; end; DevListBox.Items.Clear; HidCtl.Enumerate; end; end; function TUsagesForm.HidCtlEnumerate(HidDev: TJvHidDevice; const Idx: Integer): Boolean; var Dev: TJvHidDevice; N: Integer; begin // add a descriptive entry to the listbox for the device if HidDev.ProductName <> '' then N := DevListBox.Items.Add(HidDev.ProductName) else N := DevListBox.Items.Add(Format('Device VID=%x PID=%x', [HidDev.Attributes.VendorID, HidDev.Attributes.ProductID])); // check out the device and assign it to the list entry HidCtl.CheckOutByIndex(Dev, Idx); DevListBox.Items.Objects[N] := Dev; Result := True; end; procedure TUsagesForm.InfoClick(Sender: TObject); begin // show info about the device assigned to the list entry if (DevListBox.Items.Count > 0) and (DevListBox.ItemIndex >= 0) then with TInfoForm.Create(Self) do begin Dev := TJvHidDevice(DevListBox.Items.Objects[DevListBox.ItemIndex]); ShowModal; Free; end; end; end. |