com.codeminders.hidapi
Class HIDManager

java.lang.Object
  extended by com.codeminders.hidapi.HIDManager

public abstract class HIDManager
extends java.lang.Object

HIDManager.java High-level interface to enumerate, find , open HID devices and get connect/disconnect notifications.

Version:
1.0
Author:
lord

Field Summary
protected  long peer
           
 
Constructor Summary
protected HIDManager()
          Constructor to create HID object manager.
 
Method Summary
abstract  void deviceAdded(HIDDeviceInfo dev)
          Abstract callback method which will be called when HID device is connected.
abstract  void deviceRemoved(HIDDeviceInfo dev)
          Abstract callback method which will be called when new HID device is disconnected.
protected  void finalize()
          Release HID manager.
static HIDDeviceInfo[] listDevices()
          Get list of all the HID devices attached to the system.
static HIDDevice openById(int vendor_id, int product_id, java.lang.String serial_number)
          Convenience method to open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
static HIDDevice openByPath(java.lang.String path)
          Convenience method to find and open device by path
 void release()
          Release underlying HID layer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

peer

protected long peer
Constructor Detail

HIDManager

protected HIDManager()
              throws java.io.IOException
Constructor to create HID object manager. It must be invoked from subclass constructor to ensure proper initialization.

Throws:
java.io.IOException
Method Detail

deviceAdded

public abstract void deviceAdded(HIDDeviceInfo dev)
Abstract callback method which will be called when HID device is connected.

Parameters:
dev - Reference to the hid device info object.

deviceRemoved

public abstract void deviceRemoved(HIDDeviceInfo dev)
Abstract callback method which will be called when new HID device is disconnected.

Parameters:
dev - Reference to the hid device info object.

listDevices

public static HIDDeviceInfo[] listDevices()
                                   throws java.io.IOException
Get list of all the HID devices attached to the system.

Returns:
list of devices
Throws:
java.io.IOException

release

public void release()
Release underlying HID layer. This method must be called when HIDManager object is no longer needed. Failure to do so could cause memory leaks or unterminated threads. It is safe to call this method multiple times.


finalize

protected void finalize()
                 throws java.lang.Throwable
Release HID manager. Will call release().

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

openByPath

public static HIDDevice openByPath(java.lang.String path)
                            throws java.io.IOException,
                                   HIDDeviceNotFoundException
Convenience method to find and open device by path

Parameters:
path - USB device path
Returns:
open device reference HIDDevice object
Throws:
java.io.IOException - in case of internal error
HIDDeviceNotFoundException - if devive was not found

openById

public static HIDDevice openById(int vendor_id,
                                 int product_id,
                                 java.lang.String serial_number)
                          throws java.io.IOException,
                                 HIDDeviceNotFoundException
Convenience method to open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.

Parameters:
vendor_id - USB vendor ID
product_id - USB product ID
serial_number - USB device serial number (could be null)
Returns:
open device
Throws:
java.io.IOException - in case of internal error
HIDDeviceNotFoundException - if devive was not found