This is an old revision of the document!


  • The next input in the linked list
kii_input_t		*next;
  • The focus we belong to
kii_u_t			focus;
  • Unique input device ID
kii_u_t			id;
  • Bit mask of generated events
kii_event_mask_t	events;
  • Bit mask of events to report
kii_event_mask_t	report;
  • Vendor and Model strings for info only
kii_ascii_t	        vendor[KII_MAX_VENDOR_STRING];
kii_ascii_t	        model[KII_MAX_MODEL_STRING];
  • Method for executing a command specific to the input
int	(*Command)(kii_input_t *, kii_u_t cmd, void *);
  • Method called to poll a new event
int	(*Poll)(kii_input_t *);
  • Method called to treat an event got by Poll method
void	(*Parse)(kii_input_t *, kii_event_t *, int);
  • Private data of the input
kii_private_t	        priv;

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.

Here is another example of registration:

snprintf(mouse->input.vendor, KII_MAX_VENDOR_STRING, "FreeBSD");
snprintf(mouse->input.model, KII_MAX_VENDOR_STRING,  "Syscons Emulation Mouse");

mouse->input.focus = KII_INVALID_FOCUS;
mouse->input.id = KII_INVALID_DEVICE;
mouse->input.events = KII_EM_POINTER & ~KII_EM_PTR_ABSOLUTE;
mouse->input.report = KII_EM_PTR_RELATIVE | KII_EM_PTR_BUTTON;
mouse->input.priv.priv_ptr = mouse;

/* XXX Force registration to focus 0 */
if (!(error = kii_register_input(0, &mouse->input))) {
	make_dev(&scectl_cdevsw, SC_CONSOLECTL,
		 UID_ROOT, GID_WHEEL, 0600, "consolectl");
} else {
	KRN_ERROR("Could not register sce_mouse");
}

The above registration comes from the scemul device provided by KII to FreeBSD. It emulates the /dev/consolectl interface to which the general purpose mouse daemon sends data on mouse events. This data is processed internally and sent back to userland by /dev/sysmouse or /dev/event.

In this example, no Parser or Poll methods are set. Instead, scemul responds to the mouse daemon inputs by sending directly the event to KII.

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
);
  • kgiinputapi.1108939383.txt.gz
  • Last modified: 2005/02/20 22:43
  • by NicholasSouchu