unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, JvComponentBase, JvHidControllerClass, HID, HidUsage, StdCtrls;
type
TForm4 =
class(TForm)
JvHidDeviceController: TJvHidDeviceController;
Memo1: TMemo;
procedure OnArrival(HidDev: TJvHidDevice);
procedure OnRemoval(HidDev: TJvHidDevice);
procedure OnDeviceData(HidDev: TJvHidDevice; ReportID: Byte;
const Data: Pointer; Size: Word);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
const
VendorID = $16C0;
ProductID = $05DF;
ProductName = '
AVR USB';
var
Form4: TForm4;
HIDDevice: TJvHidDevice;
ReceivedData :
Array[0..5]
of Byte;
implementation
{$R *.dfm}
procedure TForm4.OnDeviceData(HidDev: TJvHidDevice; ReportID: Byte;
const Data: Pointer; Size: Word);
begin
CopyMemory(@ReceivedData, Data, Size);
Memo1.Lines.Add('
Got Data!');
//test
end;
procedure TForm4.OnArrival(HidDev: TJvHidDevice);
var
i : integer;
begin
if ((HidDev.Attributes.VendorID = VendorID)
AND
(HidDev.Attributes.ProductID = ProductID)
AND
(HidDev.ProductName = ProductName ))
then
begin
//store device:
Memo1.Lines.Add('
Device found');
HIDDevice := HidDev;
//device found, lets do the init:
if HIDDevice.CheckOut
then
begin
//set feature type
HIDDevice.ReportTypeParam := HidP_Feature;
HIDDevice.UsagePageParam := HID_USAGE_PAGE_GENERIC;
HIDDevice.LinkCollectionParam := $01;
// CollectionType=Application
HIDDevice.UsageParam := HID_USAGE_CONSUMER_UNDEFINED;
end;
end;
end;
procedure TForm4.OnRemoval(HidDev: TJvHidDevice);
begin
if ((Assigned(HIDDevice))
and (
NOT HIDDevice.IsPluggedIn))
then
begin
JvHidDeviceController.CheckIn(HIDDevice);
end;
end;
end.