Winsoft Native HID V1.0 Delphi C Builder 5 10.3 Full Source _TOP_
Download File ===> https://geags.com/2tvPo3
How to Use Winsoft Native HID v1.0 with Delphi and C++ Builder
Winsoft Native HID v1.0 is a library that allows you to access Human Interface Devices (HID) such as keyboards, mice, joysticks, gamepads, etc. using native Windows API. It supports Delphi and C++ Builder 5 to 10.3 and works with both 32-bit and 64-bit applications.
In this article, we will show you how to use Winsoft Native HID v1.0 with Delphi and C++ Builder to create a simple application that can read data from a USB joystick.
Step 1: Download and Install Winsoft Native HID v1.0
You can download Winsoft Native HID v1.0 from here. The download package includes the full source code of the library, a demo application, and a help file.
To install Winsoft Native HID v1.0, you need to copy the files from the Source folder to your Delphi or C++ Builder library path. You can also open the project file (NHID.dproj) in your IDE and compile it to generate the DCU or OBJ files.
Step 2: Add Winsoft Native HID v1.0 to Your Project
To use Winsoft Native HID v1.0 in your project, you need to add the unit NHID.pas to your uses clause in Delphi or include the header file NHID.hpp in C++ Builder.
For example, in Delphi:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, NHID;
In C++ Builder:
#pragma hdrstop
#include \"Unit1.h\"
#include \"NHID.hpp\"
Step 3: Declare and Initialize a TNHIDDevice Object
To access a HID device, you need to create an instance of the TNHIDDevice class and assign its properties accordingly.
The most important property is DevicePath, which specifies the unique identifier of the HID device you want to connect to. You can obtain the device path by using the TNHIDDeviceList class, which enumerates all the available HID devices on your system.
For example, in Delphi:
var
Device: TNHIDDevice;
DeviceList: TNHIDDeviceList;
begin
Device := TNHIDDevice.Create(nil);
DeviceList := TNHIDDeviceList.Create;
try
// find the first USB joystick
if DeviceList.Find(USB_JOYSTICK) then
Device.DevicePath := DeviceList.DevicePath;
// set other properties as needed
Device.OnData := DeviceData;
Device.OnError := DeviceError;
// open the device
Device.Open;
finally
DeviceList.Free;
end;
end;
In C++ Builder:
TNHIDDevice *Device;
TNHIDDeviceList *DeviceList;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Device = new TNHIDDevice(NULL);
DeviceList = new TNHIDDeviceList();
try
{
// find the first USB joystick
if (DeviceList->Find(USB_JOYSTICK))
Device->DevicePath = DeviceList->DevicePath;
// set other properties as needed
Device->OnData = DeviceData;
Device->OnError = DeviceError;
// open the device
Device->Open();
}
__finally
{
delete DeviceList;
}
}
Step 4: Handle the OnData and OnError Events
The OnData event is triggered when the HID device sends data to your application. The data is passed as a TBytes array that contains the raw bytes received from the device.
The OnError event is triggered when an error occurs while communicating with the HID device. The error code and message are passed as parameters.
You can use these aa16f39245