kii_input_t             *next;

        kii_u_t                 focus;

        kii_u_t                 id;

        kii_event_mask_t        events;

        kii_event_mask_t        report;

        kii_ascii_t             vendor[KII_MAX_VENDOR_STRING];
        kii_ascii_t             model[KII_MAX_MODEL_STRING];

        int     (*Command)(kii_input_t *, kii_u_t cmd, void *);

        int     (*Poll)(kii_input_t *);

        void    (*Parse)(kii_input_t *, kii_event_t *, int);

        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_EM_KEY | KII_EM_RAW_DATA;
        sc-> = 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-> 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->

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-> = KII_INVALID_DEVICE;
        mouse-> = KII_EM_POINTER & ~KII_EM_PTR_ABSOLUTE;
        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 (last edited 2008-06-17 21:37:58 by localhost)