0
如何在Delphi2010中使用TJvHidDevice
讀取HID Device
數據。我想閱讀InkTable
t的Ink position
(X和Y)。我的設備名稱是DigiMemo
,它是筆和平板電腦HID設備。 謝謝所有如何使用TJvHidDevice讀取HID設備數據
如何在Delphi2010中使用TJvHidDevice
讀取HID Device
數據。我想閱讀InkTable
t的Ink position
(X和Y)。我的設備名稱是DigiMemo
,它是筆和平板電腦HID設備。 謝謝所有如何使用TJvHidDevice讀取HID設備數據
我用它通過pc上的USB藍牙適配器讀取PS3藍光遙控器。您可以使用它來讀取任何其他HID設備,只需稍微嘗試即可檢索每個操作的代碼。
function JvHidDeviceController1Enumerate(HidDev: TJvHidDevice; const Idx: Integer): Boolean;
procedure PS3Read(HidDev: TJvHidDevice; ReportID: Byte; const Data: Pointer; Size: Word);
PS3Dev: TJvHidDevice;
PS3Box: TGroupBox;
PS3BDRemote: TCheckBox;
ps3DemoLabel: TLabel;
function JvHidDeviceController1Enumerate(HidDev: TJvHidDevice; const Idx: Integer): Boolean;
Var Dev: TJvHidDevice;
begin
if HidDev.ProductName = 'BD Remote Control' then
begin
PS3Box.Caption:= 'PS3 - Status: found';
JvHidDeviceController1.CheckOutByIndex(Dev, Idx);
Dev.NumInputBuffers := 128;
Dev.NumOverlappedBuffers := 128;
Dev.OnData := PS3Read;
PS3Dev:= Dev;
end;
Result := True;
end;
procedure test;
begin
if not PS3BDRemote.Checked then
begin
if Assigned(PS3Dev) then
begin
JvHidDeviceController1.CheckIn(PS3Dev);
PS3Dev.OnData := nil;
PS3Dev:= nil;
end;
PS3Box.Caption:= 'PS3 - Disabled';
end
else
begin
if not Assigned(PS3Dev) then JvHidDeviceController1.Enumerate
else PS3Box.Caption:= 'PS3 - Status: found';
end;
end;
procedure PS3Read(HidDev: TJvHidDevice; ReportID: Byte; const Data: Pointer; Size: Word);
var I: Integer;
Str: string;
begin
Str := Format('RD %.2x ', [ReportID]);
for I := 0 to Size - 1 do
Str := Str + Format('%.2x ', [Cardinal(PChar(Data)[I])]);
MyKillChar(Str,' ',false);
if Str = 'RD010000080BFFFFFFFFFF0103' then
begin
// enter was pressed, do stuff here (button down)
Exit;
end;
if Str = 'RD01000000FFFFFFFFFFFF0003' then
begin
// enter was pressed, do stuff here (button up)
Exit;
end;
ps3DemoLabel.Caption:= Str;
Logs.Memo1.lines.add(str);
end;