USB Library for Android

USB Library for Android demo example
Delphi and C++ Builder USB and HID library for Android.
  • uses standard Android USB API
  • available for Delphi/C++ Builder XE7 - 10.2
  • source code included in registered version
  • royalty free distribution in applications

API

TUsbManager = class
  constructor Create;

  property Manager: JUsbManager read;
  property DeviceCount: Integer read;
  property Device[Index: Integer]: TUsbDevice read;
  property OnDeviceAttached: TUsbDeviceAttachedEvent read write;
  property OnDeviceDetached: TUsbDeviceDetachedEvent read write;
end;

TUsbDevice = class
  function Open: TUsbConnection;
  procedure RequestPermission;

  property &Class: Integer read;
  property ClassName: string read;
  property ConfigurationCount: Integer read;
  property Configuration[Index: Integer]: TUsbConfiguration read;
  property Device: JUsbDevice read;
  property HasPermission: Boolean read;
  property Id: Integer read;
  property InterfaceCount: Integer read;
  property &Interface[Index: Integer]: TUsbInterface read;
  property Manager: TUsbManager read;
  property ManufacturerName: string read;
  property Name: string read;
  property ProductId: Integer read;
  property ProductName: string read;
  property Protocol: Integer read;
  property SerialNumber: string read;
  property Subclass: Integer read;
  property VendorId: Integer read;
  property Version: string read;
end;

TUsbConfiguration = class
  property Id: Integer read;
  property InterfaceCount: Integer read;
  property MaxPower: Integer read;
  property Name: string read;
  property IsRemoteWakeup: Boolean read;
  property IsSelfPowered: Boolean read;
end;

TUsbInterface = class
  property AlternateSetting: Integer read;
  property &Class: Integer read;
  property ClassName: string read;
  property Device: TUsbDevice read;
  property EndpointCount: Integer read;
  property Endpoint[Index: Integer]: TUsbEndpoint read;
  property Id: Integer read;
  property IsHid: Boolean read;
  property &Interface: JUsbInterface read;
  property Name: string read;
  property Protocol: Integer read;
  property Subclass: Integer read;
end;

TUsbEndpoint = class
  property Address: Integer read;
  property Attributes: Integer read;
  property Direction: TEndpointDirection read;
  property Endpoint: JUsbEndpoint read;
  property Interval: Integer read;
  property MaxPacketSize: Integer read;
  property Number: Integer read;
  property &Type: TEndpointType read;
end;

TUsbConnection = class
  function BulkTransfer(Endpoint: TUsbEndpoint; Data: Pointer; Length, Timeout: Integer): Integer;
  function BulkTransfer(Endpoint: TUsbEndpoint; Data: TBytes; Timeout: Integer): Integer;
  function ClaimInterface(&Interface: TUsbInterface; Force: Boolean): Boolean;
  procedure Close;
  function ControlTransfer(RequestType, Request, Value, Index: Integer; Data: TBytes; Timeout: Integer): Integer;
  function ControlTransfer(RequestType, Request, Value, Index: Integer; Data: Pointer; Length: Integer; Timeout: Integer): Integer;
  function GetConfigurationDescriptorRequest(Index, LanguageID: Word; Timeout: Integer): TBytes;
  function GetConfigurationRequest(Timeout: Integer): Byte;
  function GetDescriptorRequest(&Type, Index: Byte; LanguageID: Word; Timeout: Integer): TBytes;
  function GetDeviceDescriptor(LanguageID: Word; Timeout: Integer): TDeviceDescriptor;
  function GetDeviceDescriptorRequest(LanguageID: Word; Timeout: Integer): TBytes;
  function GetLanguageIDs(Timeout: Integer): TLanguageIDs;
  function GetString(Index, LanguageID: Word; Timeout: Integer): string;
  function GetStringDescriptorRequest(Index, LanguageID: Word; Timeout: Integer): TBytes;
  function ReleaseInterface(&Interface: TUsbInterface): Boolean;
  function RequestCancel: Boolean;
  procedure RequestClose;
  procedure RequestCreate(Endpoint: TUsbEndpoint);
  procedure RequestQueueIn(Length: Integer);
  procedure RequestQueueOut(Data: TArray);
  function RequestWait(Timeout: Int64 = 0): TArray;
  procedure SetConfigurationRequest(Value: Byte; Timeout: Integer);

  property Connection: JUsbDeviceConnection read;
  property FileDescriptor: Integer read;
  property RawDescriptors: TBytes read;
  property Request: JUsbRequest read;
  property Serial: string read;
end;
							

Download and order

Related links