This is an old revision of the document!
kii_input_t
struct kii_input_s
{
kii_input_t *next; /* next in linked list */
kii_u_t focus; /* the focus we belong to */
kii_u_t id; /* unique input device ID */
kii_event_mask_t events; /* event types generated */
kii_event_mask_t report; /* events to report */
kii_ascii_t vendor[KII_MAX_VENDOR_STRING]; /* who built this device */
kii_ascii_t model[KII_MAX_MODEL_STRING]; /* what model */
/* Comment: method for executing a command specific to the input */
int (*Command)(kii_input_t *, kii_u_t cmd, void *);
/* Comment: method called to poll a new event */
int (*Poll)(kii_input_t *);
/* Comment: method called to treat an event got by Poll method */
void (*Parse)(kii_input_t *, kii_event_t *, int);
kii_private_t priv; /* private data of the input */
};
kii_register_input()
kii_register_input() is typically called when a new input driver is loaded.
kii_error_t kii_register_input( /* Comment: the focus to register to */ kii_u_t focus, /* Comment: preinitialized data about the input to register */ kii_input_t *dev );
The return code is null (KII_EOK) on succes. Otherwise, the appropriate return code is given back.
A typical registration of an input is like this:
snprintf(sc->kii_input.vendor, KII_MAX_VENDOR_STRING, "KII FreeBSD keyboard"); snprintf(sc->kii_input.model, KII_MAX_VENDOR_STRING, kbd->kb_name); sc->kii_input.events = KII_EM_KEY | KII_EM_RAW_DATA; sc->kii_input.report = KII_EM_KEY | KII_EM_RAW_DATA; sc->kii_input.priv.priv_ptr = sc; sc->kii_input.Poll = kbdriver_poll; sc->kii_input.Parse = kbdriver_parser; kii_error = kii_register_input((~0), &sc->kii_input);
In the above example, KII_INVALID_FOCUS is passed as focus id to let [“KII”] auto register the input according to its capabilities e.g sc→kii_input.events. sc→kii_input.priv.priv_ptr is initialized with the software data pointer of the kbd device.
kbdriver_parser() takes scancodes from the RAW output of a kbd and fills the event structure passed in. Event is only reported to [“KII”] if the event type corresponds (e.g bit set) in sc→kii_input.report.
kii_unregister_input()
kii_unregister_input() is typically called when the module of an input driver is unloaded.
void kii_unregister_input( /* Comment: the input to unregister from its focus */ kii_input_t *dev );