【问题标题】:How to read HID Device Data by using TJvHidDevice如何使用 TJvHidDevice 读取 HID 设备数据
【发布时间】:2011-02-16 14:52:05
【问题描述】:

如何在 Delphi2010 中使用 TJvHidDevice 读取 HID Device 数据。我想阅读InkTablet 的Ink position(X 和 Y)。我的设备名称是DigiMemo,它是一款笔和平板电脑 HID 设备。 谢谢大家

【问题讨论】:

    标签: delphi hid tablet


    【解决方案1】:

    我用它通过电脑上的 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;
    

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 2011-04-08
      • 1970-01-01
      • 2016-10-28
      • 2011-11-29
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多