Embodiments pertain to routing input data from multiple input devices to multiple applications for processing where the applications selectively register to receive data.
A computing device may support a keyboard device. The keyboard device may be the primary mechanism by which a user interacts with the computing device and an application program running within the computing device. A keyboard device of a computing device is generally closely coupled with the user interface. For example, an application program that handles the user interface will register to obtain all keystroke data typed on a keyboard device. That is, a user may type on the keyboard, i.e., keystrokes that depress or designate keys, and these keystrokes are interpreted and displayed via the user interface display. Typically, when a Universal Serial Bus (USB) Human Interface Device (HID) device is initially plugged into a computer, the USB drivers on the computer enumerate the device to extract information such as Vendor Identification (ID), Product ID, and one or more Device Descriptors. These fields are defined in the USB Specification. Generally, a USB interface is a standard interface between PCs and peripherals, and has become a de facto commercial interface for keyboard devices, i.e., for USB keyboards that may plug directly into a USB port on a computing device, such as a multifunction peripheral (MFP) device.
Presently, if more than one USB keyboard device is attached to the computing device, the input by way of each of the two or more keyboard devices attached to the computing device are not readily distinguishable from one another. For example, if a keyboard device A and keyboard device B are both attached to one computing device, and the user types on both keyboards simultaneously, the input from both keyboard devices will be routed to the same application that has registered for keyboard data. This causes the keystrokes of both keyboard devices to be intermingled on the user interface.
There are several approaches available in the industry today to support simultaneous access to Human Interface Device (HID) type devices. The following describes some approaches, and their limitations. The Apple™ HID Manager is the standard USB HID Application Programming Interface (API) on Mac™ OS X. It also includes Apple™ Desktop Bus (ADB) devices, like PowerBook™ keyboards and trackpads. The Linux™ Input Subsystem, represented by “input.h,” is a very clean and simple API that unifies a number of APIs: USB HID, PS/2, Wacom, serial mice, ADB, and more. It has become the standard method for handling input devices in the vast majority of GNU/Linux distributions. The Microsoft™ Windows™ Driver Development Kit (DDK) HID API is similar to the Apple™ HID Manager in that is a low-level API that closely follows USB HID.
Distinguishing the input among the various USB keyboard devices attached to one computer becomes a requirement when using devices that emulate keyboards. Such is the case with USB smartcard readers. Many USB smartcard readers today offer keyboard emulation models that allow smartcard data to be presented to the computer system as keystroke data. To avoid the keystroke data from the smartcard reader being indistinguishably intermingled with the keyboard data from an actual keyboard, embodiments described herein provide for distinguishing keystroke data among the several keyboard devices attached to, in communication with, or otherwise engaging the computing system, e.g., an MFP device.
Accordingly, embodiments pertain to systems and devices for, and methods of, enabling data input from multiple USB keyboard devices to be routed to multiple applications running on a computing device, e.g., a MFP device. Each connected USB keyboard device is associated with a separate thread that serves to monitor and manage the associated connected USB keyboard device. Threads are dynamically spawned when a keyboard device is attached, and threads are deleted when the device is detached. A keyboard manager thread embodiment performs the following functions: (a) manages multiple keyboard devices connected to the same machine; (b) provides a list of monitored keyboard devices available on the system; (c) processes and provides data for each keyboard device from the USB subsystem; (d) buffers data in memory pre-allocated for each device; (e) allows applications to register for events for each device; (f) sends events to registered applications; and (g) references a matching device criteria database to dynamically configure the particular devices that are to be monitored.
Exemplary embodiments include methods of accommodating a plurality of interface devices via a USB comprising: (a) receiving a set of interface device settings for an interface device, by a computing device comprising: (i) a processor and (ii) addressable memory comprising a set of device-matching criteria having one or more entries comprising interface device characteristics; (b) comparing, by the processor, the received set of interface device settings with one or more entries of the set of device-matching criteria database; and (c) if the received set of input device settings matches an entry of the set of device-matching criteria database, then spawning an interface device manager thread. If the received set of interface device settings matches an entry of the set of device-matching criteria database, then the method may include generating an input/output (“I/O”) device handle associated with the interface device. The spawning of the interface device manager thread is based on the generated I/O device handle. The interface device may be a keyboard device, and the computing device may be a multifunction peripheral device. The method may further include reading data from the interface device based on the generated I/O device handle.
A computing device embodiment may include; (a) a processor, and addressable memory comprising a set of device-matching criteria; where the processor is configured, e.g., by loading computer executable instructions, circuitry, or a combination of both, to: (i) compare a received set of interface device settings with one or more entries of the set of the device-matching criteria; and (ii) determine whether the received set of interface device settings matches an entry of the set of device-matching criteria, and, (iii) if a match is determined, then spawn an interface device manager thread. The processor may be further configured to generate an I/O device handle associated with the interface device if a match is determined. The processor may be further configured to spawn the interface device manager thread based on the generated I/O device handle. The interface device may be a keyboard device, e.g., a USB keyboard device, and the computing device may be a MFP device where the MFP device is configured to receive input from two or more USB keyboard devices. The processor may be further configured to read data from the interface device based on the generated I/O device handle.
Embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, and in which:
Another exemplary computing device is an exemplary MFP device illustrated in greater exemplary functional detail in
The computing device (
An exemplary structure for multiple keyboard attachment may be within a USB layered architecture.
As an example of USB device management, the keyboard manager manages one keyboard device. A responsibility of the keyboard manager is to obtain data from the USB subsystem, and pass the data to the upper application layer. Multi-keyboard support employs dedicated keyboard manager threads where each thread is used to manage a particular connected USB keyboard device. Each thread may be dynamically spawned when a keyboard device is attached, and each thread may be deleted when the keyboard device is detached. Each thread uniquely identifies the device being managed and provides this information to applications interested in keystrokes from that device.
The keyboard type is an element to multi-keyboard support. A type “KEYBOARD” may be defined to identify keyboards, and a type “READER” may be defined to identify the reader. Each keyboard manager thread may uniquely identify the type of device it is managing, and each keyboard manager thread may provide this identity type information to the application, e.g., via the keyboard manager handle. The keyboard type is identified by the keyboard drivers 426 when the keyboard device is attached to the system 425. The keyboard driver provides this identifying information to the keyboard manager functions during the device attach callback step.
The Keyboard Matching Criteria Database may be in the form of an XML file. Records may be added by modifying the XML file or added dynamically through system administration functionality. When the computing device, such as an MFP device, detects a newly attached keyboard device, the keyboard device information enumerated by the USB subsystem may be presented on the one or more administrative pages of the keyboard device, and the MFP device may allow the keyboard device to be added to the database automatically. Accordingly, differentiating keyboard devices allows the MFP device to route keystroke data appropriately via multiple managing threads in the system.
The keyboard manager handle 640 enables the application of multiple keyboard manager threads. The handle may be created or generated when the USB subsystem detects a matching keyboard, and the handle is deleted when the application no longer requires services from this thread. The handle memory may be dynamically allocated prior to spawning the keyboard manager thread. The handle memory may be initialized to include the device name as well as other thread-specific information. This handle 640 may then be passed to the keyboard manager 620 at task entry, and may be made available to applications 610 that register for keystroke data. The information within the keyboard manager handle 640 may comprise: (a) a device name; (b) a device ID; (c) a device type; (d) a key buffer; and (e) system resources. The keyboard manager initializes the system resource encapsulated within the keyboard manager handle. An exemplary initialization includes allocating the memory buffers and generating semaphores specific to the attached device.
The keyboard manager obtains data via keyboard drivers. The keyboard driver I/O functionality is internally mapped to the system I/O functions: read; write; open; close; and “ioctl,” i.e., I/O control. When a device is attached to the system, it is the keyboard driver that generates a new device handle for the attached device, and generates the I/O device name associated with the handle, e.g., “/usbKb/0.” The USB device, such as the keyboard device, may then be added to an internal device list maintained by the drivers. In addition to the management of the internal keyboard I/O device handle, the keyboard driver creates a keyboard manager handle associated with this device and stores a reference to the I/O device handle in the keyboard manager handle.
In addition to generating a handle, the handle is initialized, and the keyboard manager thread is spawned for managing that device. When a keyboard device is disconnected, the keyboard drivers release memory and remove the keyboard device from the internal device list maintained by the drivers.
Applications receive keystrokes by registering with the keyboard manager. To do this, applications exercise the public APIs provided by the keyboard manager to provide a list of events that the application will service. The identification of a keyboard manager thread is based on the handle of the appropriate keyboard manager thread. To register for events, the application may provide the list of events to identify the keyboard manager thread with which to register. An exemplary process by which applications may obtain the keyboard manager handle is at the stage of task entry. That is, the keyboard manager thread itself may be used to spawn the application thread, and to provide its own handle at the application task entry. Another exemplary process by which applications may obtain the keyboard manager handle may be for the keyboard manager to maintain a list of all running threads, and provide this list through a public API.
It is contemplated that various combinations and/or sub-combinations of the specific features and aspects of the above embodiments may be made and still fall within the scope of the invention. Accordingly, it should be understood that various features and aspects of the disclosed embodiments may be combined with or substituted for one another in order to form varying modes of the disclosed invention. Further it is intended that the scope of the present invention herein disclosed by way of examples and section headings, should not be limited by the particular language of the section headings and/or the disclosed embodiments described above.