javax.usb.examples
Class MouseDriver

java.lang.Object
  extended by javax.usb.examples.MouseDriver

public class MouseDriver
extends Object

Example driver for USB mice.

This shows how to get events from a USB mouse. This class should not be used except by other example code.

WARNING : The code in the class is intended for example use only! Some functionality (e.g. HID usage detection) is simplified for example purposes, and should not be reproduced in non-example code. Also this code is designed to be example code, not robust well-written code, and so the design should not be duplicated in normal code.

Author:
Dan Streetman

Nested Class Summary
static class MouseDriver.HidMouseRunnable
          Class to listen in a dedicated Thread for mouse movement events.
 
Field Summary
static byte GET_REPORT_DESCRIPTOR_REQUEST
           
static byte GET_REPORT_DESCRIPTOR_REQUESTTYPE
           
static short GET_REPORT_DESCRIPTOR_VALUE
           
static byte HID_CLASS
           
static byte HID_DESCRIPTOR_TYPE_REPORT
           
static short HID_MOUSE_USAGE_ID
           
static short HID_MOUSE_USAGE_PAGE
           
static byte HID_PROTOCOL_MOUSE
           
static byte HID_SUBCLASS_BOOT_INTERFACE
           
 
Constructor Summary
MouseDriver()
           
 
Method Summary
static boolean checkHidInterface(UsbInterface usbInterface, short usagePage, short usageID)
          Check the HID-class UsbInterface to see if matches the usagePage and usageID.
static boolean checkUsbInterfaceIsMouse(UsbInterface usbInterface)
          Check if the HID-class UsbInterface is a boot-type USB mouse.
static void driveHidMouse(UsbInterface usbInterface)
          Drive the HID mouse until the user aborts.
static void main(String[] argv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HID_CLASS

public static final byte HID_CLASS
See Also:
Constant Field Values

HID_SUBCLASS_BOOT_INTERFACE

public static final byte HID_SUBCLASS_BOOT_INTERFACE
See Also:
Constant Field Values

HID_PROTOCOL_MOUSE

public static final byte HID_PROTOCOL_MOUSE
See Also:
Constant Field Values

HID_MOUSE_USAGE_PAGE

public static final short HID_MOUSE_USAGE_PAGE
See Also:
Constant Field Values

HID_MOUSE_USAGE_ID

public static final short HID_MOUSE_USAGE_ID
See Also:
Constant Field Values

HID_DESCRIPTOR_TYPE_REPORT

public static final byte HID_DESCRIPTOR_TYPE_REPORT
See Also:
Constant Field Values

GET_REPORT_DESCRIPTOR_REQUESTTYPE

public static final byte GET_REPORT_DESCRIPTOR_REQUESTTYPE
See Also:
Constant Field Values

GET_REPORT_DESCRIPTOR_REQUEST

public static final byte GET_REPORT_DESCRIPTOR_REQUEST
See Also:
Constant Field Values

GET_REPORT_DESCRIPTOR_VALUE

public static final short GET_REPORT_DESCRIPTOR_VALUE
See Also:
Constant Field Values
Constructor Detail

MouseDriver

public MouseDriver()
Method Detail

main

public static void main(String[] argv)

driveHidMouse

public static void driveHidMouse(UsbInterface usbInterface)
Drive the HID mouse until the user aborts.

Parameters:
usbInterface - The UsbInterface for the mouse.

checkUsbInterfaceIsMouse

public static boolean checkUsbInterfaceIsMouse(UsbInterface usbInterface)
Check if the HID-class UsbInterface is a boot-type USB mouse.

Parameters:
usbInterface - The HID-class UsbInterface to check.
Returns:
If the UsbInterface is a boot-type USB mouse.

checkHidInterface

public static boolean checkHidInterface(UsbInterface usbInterface,
                                        short usagePage,
                                        short usageID)
Check the HID-class UsbInterface to see if matches the usagePage and usageID.

Parameters:
usbInterface - The HID-class UsbInterface to check.
Returns:
If the UsbInterface matches or not.


Copyright © 2012 LSST. All Rights Reserved.