### start() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Starts all threads (enumeration, data read etc) as configured. ```APIDOC ## start() ### Description Start all threads (enumeration, data read etc) as configured. ### Method N/A (Method call) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### HidManager.getHidServices() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/class-use/HidServices.html Retrieves a HidServices instance with generally safe default configurations. This is the simplest way to get started with HID services. ```APIDOC ## HidManager.getHidServices() ### Description Provides a HidServices instance with default configurations suitable for most common use cases. ### Method `static HidServices` ### Example ```java HidServices hidServices = HidManager.getHidServices(); ``` ``` -------------------------------- ### HidServicesSpecification.isAutoStart() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Checks if auto start is enabled. This is an instance method in the HidServicesSpecification class. ```APIDOC ## isAutoStart() ### Description Checks if auto start is enabled. ### Method Instance method ### Class org.hid4java.HidServicesSpecification ``` -------------------------------- ### hid_get_product_string Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets the product string from a HID device. ```APIDOC ## hid_get_product_string ### Description Retrieves the product string (product name) associated with a HID device. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **str** (com.sun.jna.Structure.ByReference) - A structure to hold the product string. This should be a `WString` or similar structure. * **len** (int) - The maximum length of the string buffer. ### Request Example ```java // Assuming 'device' is a valid HID device pointer byte[] buffer = new byte[256]; // Sufficient buffer size com.sun.jna.Structure.ByReference str = new com.sun.jna.Structure.ByReference(buffer.length) { @Override protected java.util.List getFieldOrder() { return java.util.Collections.singletonList("bytes"); } public byte[] bytes; }; data.toArray(buffer); int result = HidApiLibrary.hid_get_product_string(device, str, buffer.length); String product = null; if (result >= 0) { product = new String(buffer, 0, result, java.nio.charset.StandardCharsets.UTF_16LE); } ``` ### Response Returns the number of characters written to the buffer, or -1 if an error occurred. ``` -------------------------------- ### getProduct Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the product name of a HID device. ```APIDOC ## getProduct() ### Description Gets the product name of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - String representing the product name ``` -------------------------------- ### Auto Start Configuration Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServicesSpecification.html Methods for checking and setting the auto-start behavior for HID services. ```APIDOC ## isAutoStart() ### Description Checks if the HidServices should start automatically before any listeners are registered. ### Method `boolean isAutoStart()` ### Returns True if auto-start is enabled, false otherwise. ``` ```APIDOC ## setAutoStart(boolean autoStart) ### Description Sets whether the HidServices should start automatically before any listeners are registered. The default is backwards compatible to version 0.6.0 and below. ### Method `void setAutoStart(boolean autoStart)` ### Parameters - **autoStart** (boolean) - True if the HidServices should start before any listeners are registered. ``` -------------------------------- ### Is Auto Start - HidServicesSpecification Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServicesSpecification.html Determines if HID services are configured to start automatically before listeners are registered. ```java public boolean isAutoStart() ``` -------------------------------- ### getPath Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the system path of a HID device. ```APIDOC ## getPath() ### Description Gets the system path of the HID device. This path is generally unique and well-supported across different operating systems. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - String representing the system path of the device ``` -------------------------------- ### Get Product Name Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the product name of the HID device. ```java public String getProduct() ``` -------------------------------- ### Set Auto Start - HidServicesSpecification Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServicesSpecification.html Configures whether HID services should start automatically before any listeners are registered. The default behavior is backwards compatible with versions 0.6.0 and below. ```java public void setAutoStart(boolean autoStart) ``` -------------------------------- ### getUsage Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the usage code of a HID device. ```APIDOC ## getUsage() ### Description Gets the usage code of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - An integer or object representing the usage code ``` -------------------------------- ### Get Usage Page Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the usage page information for the HID device. ```java public int getUsagePage() ``` -------------------------------- ### Get Usage Information Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the usage information for the HID device. ```java public int getUsage() ``` -------------------------------- ### HidServices Management Methods Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServices.html Methods for managing the HID services, including starting, stopping, and shutting down the service, as well as manual scanning for device changes. ```APIDOC ## start() ### Description Start all threads (enumeration, data read etc) as configured. ## stop() ### Description Stop all threads (enumeration, data read etc), close all devices and clear all listeners. Normally part of an application shutdown. ## shutdown() ### Description Stop all device threads and shut down the `HidApi`. ## scan() ### Description Manually scans for HID device connection changes and triggers listener events as required. ``` -------------------------------- ### getUsagePage Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the usage page code of a HID device. ```APIDOC ## getUsagePage() ### Description Gets the usage page code of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - An integer or object representing the usage page code ``` -------------------------------- ### Get Listeners Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/event/HidServicesListenerList.html Retrieves the list of registered HID services listeners. ```APIDOC ## getListeners() ### Description Retrieves the list of registered HID services listeners. ### Method ```java protected final List getListeners() ``` ### Returns - **List** - The listeners list ``` -------------------------------- ### HidServicesSpecification Scan Mode Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/class-use/ScanMode.html Demonstrates how to get and set the scan mode using the HidServicesSpecification class. ```APIDOC ## Get Scan Mode ### Description Retrieves the current scan mode configuration. ### Method `getScanMode()` ### Returns `ScanMode` - The current scan mode. ## Set Scan Mode ### Description Sets the scan mode for the HID services. ### Method `setScanMode(ScanMode scanMode)` ### Parameters #### Path Parameters - **scanMode** (ScanMode) - Required - The desired scan mode to set. ``` -------------------------------- ### Get Feature Report Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Retrieves a feature report from a HID device. The first byte of the data buffer should be set to the Report ID of the desired report. The report data will be returned starting from the second byte of the buffer. ```Java int hid_get_feature_report(com.sun.jna.Pointer device, com.sun.jna.Structure.ByReference data, int length) ``` -------------------------------- ### Get Feature Report from HID Device Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Retrieves a feature report from a HID device. The first byte of the data buffer is used for the Report ID and will contain the report data starting from the second byte upon return. ```java public static int getFeatureReport(HidDeviceStructure device, byte[] data, byte reportId) ``` -------------------------------- ### Get Feature Report - HidDevice Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves a feature report from a HID device. The first byte of the data buffer is used for the Report ID and will contain the Report ID upon return. The report data starts from the second byte. ```java public int getFeatureReport(byte[] data, byte reportId) ``` -------------------------------- ### HidDevice.open() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Opens this device and obtains a device structure. This is an instance method in the HidDevice class. ```APIDOC ## open() ### Description Open this device and obtain a device structure. ### Method Instance method ### Class org.hid4java.HidDevice ``` -------------------------------- ### Get Product ID Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the integer representation of the device's product ID. ```java public int getProductId() ``` -------------------------------- ### HidDeviceStructure.ptr() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the native pointer for the device structure. This is an instance method in the HidDeviceStructure class. ```APIDOC ## ptr() ### Description Gets the native pointer for the device structure. ### Method Instance method ### Class org.hid4java.jna.HidDeviceStructure ``` -------------------------------- ### HidApi.init() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Initialises the HID API library. This is a static method in the HidApi class. ```APIDOC ## init() ### Description Initialise the HID API library. ### Method Static method ### Class org.hid4java.jna.HidApi ``` -------------------------------- ### Get Product String - HID API Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Retrieves the product string from a HID device. The buffer should be a wide string buffer with adequate capacity. ```java int hid_get_product_string(com.sun.jna.Pointer device, com.sun.jna.Structure.ByReference str, int len) ``` -------------------------------- ### HidDevice Constructor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/class-use/HidDeviceInfoStructure.html Shows how a HidDevice is constructed using HidDeviceInfoStructure. ```APIDOC ## HidDevice Constructor ### Description Constructs a new HidDevice instance using the provided device information structure, device manager, and HID services specification. ### Parameters - **infoStructure** (HidDeviceInfoStructure) - Required - The structure containing information about the HID device. - **hidDeviceManager** (org.hid4java.HidDeviceManager) - Required - The HID device manager instance. - **hidServicesSpecification** (HidServicesSpecification) - Required - The HID services specification to use. ``` -------------------------------- ### Device Management Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Methods for initializing, exiting, opening, and closing HID devices. ```APIDOC ## init ### Description Initialise the HID API library. Should always be called before using any other API calls. ### Method `public static void init()` ## exit ### Description Finalise the HID API library ### Method `public static void exit()` ## open ### Description Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. ### Method `public static HidDeviceStructure open(int vendor, int product, String serialNumber)` ### Parameters #### Path Parameters - **vendor** (int) - The vendor ID - **product** (int) - The product ID - **serialNumber** (String) - The serial number ### Returns - The device or null if not found ## open ### Description Open a HID device by its path name. ### Method `public static HidDeviceStructure open(String path)` ### Parameters #### Path Parameters - **path** (String) - The device path (e.g. "0003:0002:00") ### Returns - The device or null if not found ## close ### Description Close a HID device. ### Method `public static void close(HidDeviceStructure device)` ### Parameters #### Path Parameters - **device** (HidDeviceStructure) - The HID device structure ``` -------------------------------- ### Get HID API Library Version Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Returns the full version string of the underlying hidapi library. ```java public static String getVersion() ``` -------------------------------- ### Get HID Device Product ID Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Retrieves the product ID string for a given HID device. ```java public static String getProductId(HidDeviceStructure device) ``` -------------------------------- ### hid_get_report_descriptor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets the report descriptor from a HID device. ```APIDOC ## hid_get_report_descriptor ### Description Retrieves the report descriptor from a HID device. The report descriptor defines the structure and capabilities of the device's reports. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **buffer** (byte[]) - A byte array to store the report descriptor. * **size** (int) - The size of the buffer in bytes. ### Request Example ```java // Assuming 'device' is a valid HID device pointer byte[] reportDescriptor = new byte[1024]; // Allocate a buffer for the descriptor int bytesRead = HidApiLibrary.hid_get_report_descriptor(device, reportDescriptor, reportDescriptor.length); if (bytesRead > 0) { // Process the report descriptor (bytesRead contains the actual size) } else if (bytesRead == -1) { // Handle error } ``` ### Response Returns the number of bytes read into the buffer, or -1 if an error occurred. The actual size of the report descriptor is returned on success. ``` -------------------------------- ### HidApi Initialization and Exit Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Methods to initialize and finalize the HID API library. ```APIDOC ## init ### Description Initialise the HID API library. ### Method static void ### Signature init() ``` ```APIDOC ## exit ### Description Finalise the HID API library. ### Method static void ### Signature exit() ``` -------------------------------- ### hid_open Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Opens a HID device using its Vendor ID (VID) and Product ID (PID), optionally filtering by a serial number. If the serial number is null, the first matching device is opened. ```APIDOC ## hid_open ### Description Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. If serial_number is NULL, the first device with the specified VID and PID is opened. ### Method `com.sun.jna.Pointer hid_open(short vendor_id, short product_id, com.sun.jna.WString serial_number)` ### Parameters #### Path Parameters - **vendor_id** (short) - The vendor ID - **product_id** (short) - The product ID - **serial_number** (com.sun.jna.WString) - The serial number (or null for wildcard) ### Returns A pointer to a HidDevice on success or null on failure ``` -------------------------------- ### hid_version_str Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets the version string of the hidapi library. ```APIDOC ## hid_version_str ### Description Returns a string representing the version of the underlying HIDAPI library. ### Method String ### Parameters None ### Request Example ```java String version = HidApiLibrary.hid_version_str(); System.out.println("HIDAPI Version: " + version); ``` ### Response A string containing the HIDAPI library version. ``` -------------------------------- ### hid_open Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Opens a HID device using Vendor ID, Product ID, and optionally a serial number. ```APIDOC ## hid_open ### Description Opens a HID device using its Vendor ID (VID), Product ID (PID), and an optional serial number. ### Method com.sun.jna.Pointer ### Parameters * **vendor_id** (short) - The Vendor ID of the device. * **product_id** (short) - The Product ID of the device. * **serial_number** (com.sun.jna.WString) - The serial number of the device (can be null). ### Request Example ```java short vendorId = (short) 0x1234; short productId = (short) 0x5678; com.sun.jna.WString serial = new com.sun.jna.WString("12345"); com.sun.jna.Pointer device = HidApiLibrary.hid_open(vendorId, productId, serial); ``` ### Response Returns a pointer to the opened HID device. Returns null if the device could not be opened. ``` -------------------------------- ### hid_get_manufacturer_string Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets the manufacturer string from a HID device. ```APIDOC ## hid_get_manufacturer_string ### Description Retrieves the manufacturer string associated with a HID device. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **str** (com.sun.jna.Structure.ByReference) - A structure to hold the manufacturer string. This should be a `WString` or similar structure. * **len** (int) - The maximum length of the string buffer. ### Request Example ```java // Assuming 'device' is a valid HID device pointer byte[] buffer = new byte[256]; // Sufficient buffer size com.sun.jna.Structure.ByReference str = new com.sun.jna.Structure.ByReference(buffer.length) { @Override protected java.util.List getFieldOrder() { return java.util.Collections.singletonList("bytes"); } public byte[] bytes; }; data.toArray(buffer); int result = HidApiLibrary.hid_get_manufacturer_string(device, str, buffer.length); String manufacturer = null; if (result >= 0) { manufacturer = new String(buffer, 0, result, java.nio.charset.StandardCharsets.UTF_16LE); } ``` ### Response Returns the number of characters written to the buffer, or -1 if an error occurred. ``` -------------------------------- ### Open HID Device by Vendor/Product ID and Serial Number Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Opens a HID device using its Vendor ID (VID), Product ID (PID), and an optional serial number. Returns the device structure or null if not found. ```java public static HidDeviceStructure open(int vendor, int product, String serialNumber) ``` -------------------------------- ### hid_get_feature_report Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets a feature report from a HID device. ```APIDOC ## hid_get_feature_report ### Description Gets a feature report from a HID device. Feature reports are used for device configuration and status retrieval. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **data** (com.sun.jna.Structure.ByReference) - A structure to hold the feature report data. The first byte should be the report ID. * **length** (int) - The size of the buffer in bytes. ### Request Example ```java byte[] buffer = new byte[65]; // Max feature report size is 64 bytes + 1 for report ID com.sun.jna.Structure.ByReference data = new com.sun.jna.Structure.ByReference(buffer.length) { @Override protected java.util.List getFieldOrder() { return java.util.Collections.singletonList("bytes"); } public byte[] bytes; }; data.toArray(buffer); int bytesRead = HidApiLibrary.hid_get_feature_report(device, data, buffer.length); ``` ### Response Returns the number of bytes read, or -1 if an error occurred. ``` -------------------------------- ### HidDeviceInfoStructure.show() Method Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidDeviceInfoStructure.html Returns a string representation of the attached HID device. ```APIDOC ## Method Detail ### show ```java public String show() ``` Returns: A string representation of the attached device ``` -------------------------------- ### Get Device Path Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Returns the system-specific path for the HID device. This path is well-supported across different operating systems. ```java public String getPath() ``` -------------------------------- ### HidDevice Constructors Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Constructors for creating a HidDevice instance. ```APIDOC ## HidDevice Constructor ### Description Initializes a new instance of the HidDevice class. ### Parameters - **infoStructure** (HidDeviceInfoStructure) - The HID device info structure providing details. - **hidDeviceManager** (org.hid4java.HidDeviceManager) - The HID device manager providing access to device enumeration for post IO scanning. - **hidServicesSpecification** (HidServicesSpecification) - The HID services specification providing configuration details. ### Since 0.1.0 ``` -------------------------------- ### getVendorId Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the vendor ID of a HID device. ```APIDOC ## getVendorId() ### Description Gets the vendor ID of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the vendor ID ``` -------------------------------- ### Initialize HID API Library Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Initializes the HID API library. This method must be called before any other API functions. ```java public static void init() ``` -------------------------------- ### hid_init Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Initializes the HIDAPI library. This method must be called before any other HIDAPI functions. ```APIDOC ## hid_init ### Description Initializes the HIDAPI library. ### Method void ### Parameters None ### Request Example ```java HidApiLibrary.hid_init(); ``` ### Response None ``` -------------------------------- ### getSerialNumber Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the serial number of a HID device. ```APIDOC ## getSerialNumber() ### Description Gets the serial number of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - String representing the serial number ``` ```APIDOC ## getSerialNumber(HidDeviceStructure) ### Description Gets the serial number of the HID device from its structure. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure ### Response #### Success Response - String representing the serial number ``` -------------------------------- ### getReportDescriptor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets a report descriptor from a HID device. ```APIDOC ## getReportDescriptor(byte[]) ### Description Get a report descriptor from a HID device. A report descriptor provides significant detail on the characteristics of an attached device using a defined format. ### Method Method ### Endpoint N/A (Java Method) ### Parameters - **buffer** (byte[]) - A preallocated buffer to store the report descriptor ### Response #### Success Response - byte[] containing the report descriptor ``` ```APIDOC ## getReportDescriptor(HidDeviceStructure, byte[], int) ### Description Get a report descriptor from a HID device. User has to provide a preallocated buffer (4096 bytes recommended) where descriptor will be copied to. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure - **buffer** (byte[]) - A preallocated buffer to store the report descriptor (4096 bytes recommended) - **bufferLength** (int) - The length of the provided buffer ### Response #### Success Response - byte[] containing the report descriptor ``` -------------------------------- ### getProductId Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the product ID of a HID device. ```APIDOC ## getProductId() ### Description Gets the product ID of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the product ID ``` ```APIDOC ## getProductId(HidDeviceStructure) ### Description Gets the product ID of the HID device from its structure. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure ### Response #### Success Response - Integer representing the product ID ``` -------------------------------- ### Open HID Device by Path Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Opens a HID device using its unique path name. Returns the device structure or null if not found. ```java public static HidDeviceStructure open(String path) ``` -------------------------------- ### Get Configurable HidServices - hid4java Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidManager.html Obtains a HidServices instance with custom configurations. Use this when specific HID service parameters need to be set for specialized environments or devices. ```java public static HidServices getHidServices(HidServicesSpecification hidServicesSpecification) throws HidException ``` -------------------------------- ### Open HID Device by VID/PID Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Opens a HID device using its Vendor ID (VID) and Product ID (PID). Optionally, a serial number can be provided to open a specific device. If the serial number is null, the first matching device is opened. ```Java com.sun.jna.Pointer hid_open(short vendor_id, short product_id, com.sun.jna.WString serial_number) ``` -------------------------------- ### HidDeviceInfoStructure.next() Method Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidDeviceInfoStructure.html Returns a reference to the next HidDeviceInfoStructure in a linked list, if available. ```APIDOC ## Method Detail ### next ```java public HidDeviceInfoStructure next() ``` ``` -------------------------------- ### getManufacturer Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the manufacturer name of a HID device. ```APIDOC ## getManufacturer() ### Description Gets the manufacturer name of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - String representing the manufacturer name ``` ```APIDOC ## getManufacturer(HidDeviceStructure) ### Description Gets the manufacturer name of the HID device from its structure. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure ### Response #### Success Response - String representing the manufacturer name ``` -------------------------------- ### org.hid4java.HidDevice.isOpen() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/deprecated-list.html The isOpen() method in org.hid4java.HidDevice is deprecated. Use isClosed() instead to improve code clarity. ```APIDOC ## Deprecated Method: org.hid4java.HidDevice.isOpen() ### Description This method is deprecated and should not be used. It is recommended to use `isClosed()` instead for better code clarity. ### Reason for Deprecation To improve code clarity by using a more direct method name. ### Replacement `isClosed()` ``` -------------------------------- ### getInterfaceNumber Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the interface number of a HID device. ```APIDOC ## getInterfaceNumber() ### Description Gets the interface number of a HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the interface number ``` -------------------------------- ### getId Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the unique identifier for a HID device. ```APIDOC ## getId() ### Description The "path" is well-supported across Windows, Mac and Linux so makes a better choice for a unique ID. See hid4java issue #8 for details. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - String representing the unique ID (path) of the device ``` -------------------------------- ### HidApi.open(int, int, String) Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Opens a HID device using a Vendor ID (VID), Product ID (PID), and optionally a serial number. This is a static method in the HidApi class. ```APIDOC ## open(int, int, String) ### Description Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. ### Method Static method ### Parameters #### Path Parameters - **vendorId** (int) - Required - The Vendor ID (VID) of the HID device. - **productId** (int) - Required - The Product ID (PID) of the HID device. - **serialNumber** (String) - Optional - The serial number of the HID device. ### Class org.hid4java.jna.HidApi ``` -------------------------------- ### getFeatureReport Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets a feature report from a HID device. ```APIDOC ## getFeatureReport(byte[], byte) ### Description Get a feature report from a HID device. Under the covers the HID library will set the first byte of data[] to the Report ID of the report to be read. ### Method Method ### Endpoint N/A (Java Method) ### Parameters - **data** (byte[]) - Buffer to store the feature report - **reportId** (byte) - The Report ID of the report to be read ### Response #### Success Response - byte[] containing the feature report ``` ```APIDOC ## getFeatureReport(HidDeviceStructure, byte[], byte) ### Description Get a feature report from a HID device. Under the covers the HID library will set the first byte of data[] to the Report ID of the report to be read. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure - **data** (byte[]) - Buffer to store the feature report - **reportId** (byte) - The Report ID of the report to be read ### Response #### Success Response - byte[] containing the feature report ``` -------------------------------- ### hid_error Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets a string describing the last error that occurred. ```APIDOC ## hid_error ### Description Retrieves a string describing the last error that occurred on the HIDAPI library for a given device. ### Method String ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. Can be null to get the last global error. ### Request Example ```java String errorMessage = HidApiLibrary.hid_error(device); if (errorMessage != null) { System.err.println("HIDAPI Error: " + errorMessage); } ``` ### Response Returns a string describing the last error, or null if no error has occurred. ``` -------------------------------- ### hid_get_serial_number_string Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets the serial number string from a HID device. ```APIDOC ## hid_get_serial_number_string ### Description Retrieves the serial number string associated with a HID device. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **str** (com.sun.jna.Structure.ByReference) - A structure to hold the serial number string. This should be a `WString` or similar structure. * **len** (int) - The maximum length of the string buffer. ### Request Example ```java // Assuming 'device' is a valid HID device pointer byte[] buffer = new byte[256]; // Sufficient buffer size com.sun.jna.Structure.ByReference str = new com.sun.jna.Structure.ByReference(buffer.length) { @Override protected java.util.List getFieldOrder() { return java.util.Collections.singletonList("bytes"); } public byte[] bytes; }; data.toArray(buffer); int result = HidApiLibrary.hid_get_serial_number_string(device, str, buffer.length); String serialNumber = null; if (result >= 0) { serialNumber = new String(buffer, 0, result, java.nio.charset.StandardCharsets.UTF_16LE); } ``` ### Response Returns the number of characters written to the buffer, or -1 if an error occurred. ``` -------------------------------- ### HidDevice Constructor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/class-use/HidServicesSpecification.html Constructor for HidDevice that accepts HidServicesSpecification. ```APIDOC ## HidDevice(HidDeviceInfoStructure infoStructure, org.hid4java.HidDeviceManager hidDeviceManager, HidServicesSpecification hidServicesSpecification) ### Description This constructor initializes a HidDevice object. It takes the device information structure, the HidDeviceManager instance, and a HidServicesSpecification to configure the device. ### Method `HidDevice` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Assuming HidDeviceInfoStructure, HidDeviceManager are instantiated elsewhere HidDeviceInfoStructure info = ...; HidDeviceManager manager = ...; HidServicesSpecification spec = ...; HidDevice device = new HidDevice(info, manager, spec); ``` ### Response #### Success Response (200) - **HidDevice** (HidDevice) - A new HidDevice instance. #### Response Example ```java // Example response structure (actual object returned) { "hidDevice": "instance of HidDevice" } ``` ``` -------------------------------- ### HidServices Main Method Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServices.html The main entry point for the HidServices class, typically used for version interrogation when run as a JAR. ```APIDOC ## main(String[] args) ### Description Jar entry point to allow for version interrogation. ### Parameters - `args` (String[]) - Nothing required. ``` -------------------------------- ### getScanMode Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the scan mode from the HID services specification. ```APIDOC ## getScanMode() ### Description Gets the scan mode from the HID services specification. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - An object or value representing the scan mode ``` -------------------------------- ### getScanInterval Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the scan interval from the HID services specification. ```APIDOC ## getScanInterval() ### Description Gets the scan interval from the HID services specification. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the scan interval ``` -------------------------------- ### getPauseInterval Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the pause interval from the HID services specification. ```APIDOC ## getPauseInterval() ### Description Gets the pause interval from the HID services specification. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the pause interval ``` -------------------------------- ### Utility Methods Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Miscellaneous utility methods for the HidDevice class. ```APIDOC ## isVidPidSerial(int vendorId, int productId, String serialNumber) ### Description Checks if the device matches the provided Vendor ID, Product ID, and serial number. ### Method isVidPidSerial ### Parameters - **vendorId** (int) - The Vendor ID to check. - **productId** (int) - The Product ID to check. - **serialNumber** (String) - The serial number to check. ### Returns (boolean) - True if the device matches, false otherwise. ``` ```APIDOC ## toString() ### Description Returns a string representation of the HidDevice object. ### Method toString ### Parameters None ### Returns (String) - The string representation of the device. ``` -------------------------------- ### Configuration Flags Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Global configuration flags for HID API behavior. ```APIDOC ## darwinOpenDevicesNonExclusive ### Description When false - all devices will be opened in exclusive mode. (Default) When true - all devices will be opened in non-exclusive mode. See `DarwinHidApiLibrary.hid_darwin_set_open_exclusive(int)` for more information. ### Type `public static boolean darwinOpenDevicesNonExclusive` ## logTraffic ### Description Enables HID traffic logging to stdout to assist debugging. This will show all bytes (including the extra report ID) that were sent or received via HIDAPI buffers. It does not log direct string calls (e.g. getEnumeratedString()). Format is '>' for host to device then '[count]' then hex bytes. This may present a security issue if left enabled in production, although a packet sniffer would see the same data. ### Type `public static boolean logTraffic` ``` -------------------------------- ### hid_get_indexed_string Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Gets a string from a HID device based on its string index. ```APIDOC ## hid_get_indexed_string ### Description Retrieves a string from a HID device based on its string index. String indices are device-specific. ### Method int ### Parameters * **device** (com.sun.jna.Pointer) - A pointer to the HID device. * **idx** (int) - The index of the string to retrieve. * **string** (com.sun.jna.Structure.ByReference) - A structure to hold the string. This should be a `WString` or similar structure. * **len** (int) - The maximum length of the string buffer. ### Request Example ```java // Assuming 'device' is a valid HID device pointer byte[] buffer = new byte[256]; // Sufficient buffer size com.sun.jna.Structure.ByReference str = new com.sun.jna.Structure.ByReference(buffer.length) { @Override protected java.util.List getFieldOrder() { return java.util.Collections.singletonList("bytes"); } public byte[] bytes; }; data.toArray(buffer); int result = HidApiLibrary.hid_get_indexed_string(device, 1, str, buffer.length); // Index 1 for example String indexedString = null; if (result >= 0) { indexedString = new String(buffer, 0, result, java.nio.charset.StandardCharsets.UTF_16LE); } ``` ### Response Returns the number of characters written to the buffer, or -1 if an error occurred. ``` -------------------------------- ### HidDeviceInfoStructure Constructor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidDeviceInfoStructure.html The HidDeviceInfoStructure class has a default constructor. ```APIDOC ## Constructor Summary Constructors Constructor and Description --- `HidDeviceInfoStructure()` ``` -------------------------------- ### Get Interface Number Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the interface number of the HID device. ```java public int getInterfaceNumber() ``` -------------------------------- ### HidServicesSpecification Constructor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidServicesSpecification.html Initializes a new instance of the HidServicesSpecification class. ```APIDOC ## HidServicesSpecification() ### Description Initializes a new instance of the HidServicesSpecification class. ### Constructor `HidServicesSpecification()` ``` -------------------------------- ### HidDevice Usage in Events Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/class-use/HidDevice.html Demonstrates how HidDevice objects are used within the org.hid4java.event package, particularly in event handling and construction. ```APIDOC ## HidServicesEvent Constructor ### Description Constructs a HidServicesEvent with a specified HidDevice. ### Constructor Signature `HidServicesEvent(HidDevice device)` ## HidServicesEvent Constructor with Data ### Description Constructs a HidServicesEvent with a specified HidDevice and received data. ### Constructor Signature `HidServicesEvent(HidDevice device, byte[] dataReceived)` ## HidServicesListenerList Methods ### Description These methods in HidServicesListenerList are responsible for firing various HID-related events, passing the HidDevice object as a parameter. ### Method Signatures `void fireHidDataReceived(HidDevice hidDevice, byte[] dataReceived)` `void fireHidDeviceAttached(HidDevice hidDevice)` `void fireHidDeviceDetached(HidDevice hidDevice)` `void fireHidFailure(HidDevice hidDevice)` ``` -------------------------------- ### Get Release Number Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the release number of the HID device. ```java public int getReleaseNumber() ``` -------------------------------- ### Get Serial Number Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the serial number of the HID device. ```java public String getSerialNumber() ``` -------------------------------- ### Initialize HIDAPI Library Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Initializes the HIDAPI library. While not strictly necessary as it's called automatically by other functions, it's recommended to call this at the beginning if multiple threads might open HIDAPI handles simultaneously. ```Java void hid_init() ``` -------------------------------- ### hid_open_path Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Opens a HID device using its path name. ```APIDOC ## hid_open_path ### Description Opens a HID device specified by its unique path name. ### Method com.sun.jna.Pointer ### Parameters * **path** (String) - The path name of the HID device to open. ### Request Example ```java String devicePath = "/dev/hidraw0"; // Example path com.sun.jna.Pointer device = HidApiLibrary.hid_open_path(devicePath); ``` ### Response Returns a pointer to the opened HID device. Returns null if the device could not be opened. ``` -------------------------------- ### getIndexedString Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets a string from a HID device based on its string index. ```APIDOC ## getIndexedString(int) ### Description Get a string from a HID device, based on its string index. ### Method Method ### Endpoint N/A (Java Method) ### Parameters - **index** (int) - The index of the string to retrieve ### Response #### Success Response - String from the device at the specified index ``` ```APIDOC ## getIndexedString(HidDeviceStructure, int) ### Description Get a string from a HID device, based on its string index. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **deviceStructure** (HidDeviceStructure) - The HID device structure - **index** (int) - The index of the string to retrieve ### Response #### Success Response - String from the device at the specified index ``` -------------------------------- ### getDataReadInterval Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the data read interval from the HID services specification. ```APIDOC ## getDataReadInterval() ### Description Gets the data read interval from the HID services specification. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the data read interval ``` -------------------------------- ### HidDeviceInfoStructure.next Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/class-use/HidDeviceInfoStructure.html Retrieves the next HidDeviceInfoStructure in a linked list. ```APIDOC ## HidDeviceInfoStructure.next ### Description Returns a reference to the next `HidDeviceInfoStructure` in a linked list of devices. This is used to traverse the list returned by enumeration methods. ### Method `HidDeviceInfoStructure` ### Returns The next `HidDeviceInfoStructure` in the list, or null if this is the last element. ``` -------------------------------- ### getVersion Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Returns the full version of the underlying hidapi library. ```APIDOC ## getVersion ### Description Returns the full version of the underlying hidapi library. ### Method `public static String getVersion()` ### Returns The version in major.minor.patch format. ``` -------------------------------- ### Get Associated HidDevice Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/event/HidServicesEvent.html Retrieves the HidDevice object associated with this event. ```java public HidDevice getHidDevice() ``` -------------------------------- ### Enumerate HID Devices - HID API Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApiLibrary.html Enumerates HID devices on the system, optionally filtering by vendor and product ID. Returns a linked list of matching devices. ```java HidDeviceInfoStructure hid_enumerate( short vendor_id, short product_id) ``` -------------------------------- ### HidDeviceInfoStructure Methods Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidDeviceInfoStructure.html Details the methods available in the HidDeviceInfoStructure class, including navigation and display functionalities. ```java protected List getFieldOrder() ``` ```java boolean hasNext() ``` ```java HidDeviceInfoStructure next() ``` ```java String show() ``` -------------------------------- ### HidServices Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Provides services for interacting with HID devices. ```APIDOC ## addHidServicesListener(HidServicesListener) ### Description Adds a listener to the HID services to receive notifications about HID device events. ### Method addHidServicesListener ### Parameters #### Path Parameters - **listener** (HidServicesListener) - Required - The listener to be added. ``` -------------------------------- ### Get Manufacturer Name Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the manufacturer's name for the HID device. ```java public String getManufacturer() ``` -------------------------------- ### Device Management Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Methods for managing the state of a HID device connection. ```APIDOC ## open() ### Description Opens this device and obtains a device structure. ### Method open ### Parameters None ### Returns (boolean) - True if the device was opened successfully, false otherwise. ``` ```APIDOC ## close() ### Description Closes this device, freeing the HidApi resources. ### Method close ### Parameters None ### Returns void ``` ```APIDOC ## isOpen() ### Description Checks if the device is currently open. ### Method isOpen ### Parameters None ### Returns (boolean) - True if the device is open, false otherwise. ``` ```APIDOC ## isClosed() ### Description Checks if the device is currently closed. ### Method isClosed ### Parameters None ### Returns (boolean) - True if the device is closed, false otherwise. ``` ```APIDOC ## setNonBlocking(boolean nonBlocking) ### Description Sets the device handle to be non-blocking. In non-blocking mode, calls to hid_read() will return immediately with a value of 0 if there is no data to be read. ### Method setNonBlocking ### Parameters - **nonBlocking** (boolean) - True to set the device to non-blocking mode, false otherwise. ### Returns void ``` -------------------------------- ### Enumerate HID Devices Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Enumerates attached HID devices matching the provided Vendor ID and Product ID. Returns the device information list or null if no matching devices are found. ```java public static HidDeviceInfoStructure enumerateDevices(int vendor, int product) ``` -------------------------------- ### HidDevice Methods Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html High-level wrapper to provide simplified access to the underlying JNA HidDeviceStructure. ```APIDOC ## hashCode() ### Description Returns a hash code value for the object. ### Method `hashCode` ### Class `org.hid4java.HidDevice` ``` -------------------------------- ### scan() Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Manually scans for HID device connection changes and triggers listener events as required. ```APIDOC ## scan() ### Description Manually scans for HID device connection changes and triggers listener events as required. ### Method N/A (Method call) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### Get Vendor ID Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/HidDevice.html Retrieves the integer representation of the device's vendor ID. ```java public int getVendorId() ``` -------------------------------- ### HidDeviceInfoStructure Constructor Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidDeviceInfoStructure.html Provides the default constructor for the HidDeviceInfoStructure. ```java public HidDeviceInfoStructure() ``` -------------------------------- ### getReleaseNumber Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Gets the release number (often equivalent to version number) of a HID device. ```APIDOC ## getReleaseNumber() ### Description Gets the release number of the HID device. ### Method Method ### Endpoint N/A (Java Method) ### Parameters None ### Response #### Success Response - Integer representing the release number ``` -------------------------------- ### getHidServices Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/index-all.html Provides access to HID services. ```APIDOC ## getHidServices() ### Description Simple service provider providing generally safe defaults. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters None ### Response #### Success Response - HidServices object with default configuration ``` ```APIDOC ## getHidServices(HidServicesSpecification) ### Description Fully configurable service provider. ### Method Static Method ### Endpoint N/A (Java Static Method) ### Parameters - **specification** (HidServicesSpecification) - The specification for configuring the HID services ### Response #### Success Response - HidServices object with custom configuration ``` -------------------------------- ### Get HID Device Manufacturer Source: https://javadoc.io/doc/org.hid4java/hid4java/0.8.0/org/hid4java/jna/HidApi.html Retrieves the manufacturer string for a given HID device. ```java public static String getManufacturer(HidDeviceStructure device) ```