In Linux, key, touch screen, mouse and so on input devices can rely on the input subsystem to provide interface functions to achieve their device driver, in the input subsystem, the system has completed the characteristics of these input devices, so according to the interface provided by the subsystem, The device driver for an input device can be completed only by completing its own uniqueness.
In Linux, the input subsystem consists of three layers, the device driver layer, the core layer, and the event processing layer. The device driver layer says that the response of the underlying input device translates into a standard input event, and the event processing layer provides the application with a unified device access interface to interact with the underlying data, and the core layer is the bridge between the driver layer and the event processing layer.
The important structure in the input subsystem is the INPUT_DEV structure, which is the subject of our work, and each input device corresponds to such a structure, and some of the important contents are as follows:
unsigned long evbit[nbits (EV_MAX)];//supported event types
unsigned long keybit[nbits (KEY_MAX)];//supported key bitmap
unsigned long relbit[nbits (Rel_max)];//bitmap that supports relative coordinates
unsigned long absbit[nbits (Abs_max)];//bitmap that supports absolute coordinates
unsigned long mscbit[nbits (Msc_max)];
unsigned long ledbit[nbits (Led_max)];
unsigned long sndbit[nbits (Snd_max)];
unsigned long ffbit[nbits (Ff_max)];
unsigned long swbit[nbits (Sw_max)];
Writing a driver that conforms to the input subsystem framework typically consists of the following steps:
-
assign a input_dev struct
-
set INPUT_DEV structure (set events, etc.)
-
register
-
hardware related operations get "(labor income, don't like to spray)" "Free Support Update"
Related APIs:
(1). Assigning an input device
struct Input_dev *input_allocate_device (void)//The function allocates memory for struct Input_dev struct, returns a struct that executes the allocation successfully, fails to return null
(2). Register an input device
Input_register_device (struct Input_dev *dev)//This function is used to register an input device with the input subsystem core
3). Release the memory occupied by the struct Input_dev struct
Input_free_device (struct Input_dev *dev)
(4). Write off the input device structure of the device
Input_unregister_device (struct Input_dev *dev)
(5). Tell the subsystem which events it supports
Set_bit (int nr, volatile void * addr)
Java read and write Excel file example