* @throws NameNotFoundException
* @see org.jnode.driver.Driver#startDevice()
*/
protected void startDevice() throws DriverException {
try {
final USBDevice dev = (USBDevice) getDevice();
final USBConfiguration conf = dev.getConfiguration(0);
// dev.setConfiguration(conf);
final USBInterface intf = conf.getInterface(0);
this.ep = null;
for (int i = 0; i < intf.getDescriptor().getNumEndPoints(); i++) {
ep = intf.getEndPoint(i);
if (((ep.getDescriptor().getAttributes() & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) &&
((ep.getDescriptor().getEndPointAddress() & USB_DIR_IN) == 0))
break;
}
if (this.ep == null)
throw new DriverException(
"Found no interrupt endpoint, HID specs required at least one.");
//
log.debug("Interval " + ep.getDescriptor().getInterval());
// Create the interrupt request
old = new byte[8];
intData = new USBPacket(ep.getDescriptor().getMaxPacketSize());
intPipe = (USBDataPipe) ep.getPipe();
intPipe.addListener(this);
intPipe.open();
final USBRequest req = intPipe.createRequest(intData);
intPipe.asyncSubmit(req);
// Configure the default keyboard layout and register the KeyboardAPI
KeyboardLayoutManager mgr = InitialNaming.lookup(KeyboardLayoutManager.NAME);
apiAdapter.setKbInterpreter(mgr.createDefaultKeyboardInterpreter());
dev.registerAPI(KeyboardAPI.class, apiAdapter);
// Start the key event thread
keyEventThread =
new ByteQueueProcessorThread(dev.getId() + "-daemon", keyCodeQueue, this);
keyEventThread.start();
} catch (USBException ex) {
throw new DriverException(ex);
} catch (NameNotFoundException ex) {
throw new DriverException("Cannot find keyboard layout manager", ex);