Set up the driver skeleton

To set up the driver, include the necessary headers for HID communication along with other QNX functionalities:

#include <sys/hiddi.h>
#include <sys/hidut.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Once you've included the headers, create structures to manage the driver state and device reports. The following example shows how to do this, where the included declarations are placeholders that should be replaced by your specific use cases:

typedef struct client_report {
    struct  client_report       *next;              // link
    struct hidd_report_instance *instance;          // pointer report instance from insertion
    struct hidd_report          *report;            // registration handle
    _uint16                     max_but;            // max buttons returned in a report
    _uint16                     report_len;         // max report length
    _uint16 *cbtnbuf, *pbtnbuf, *rbtnbuf;           // button buffers
    _uint32                     *cvalues;           // current value
    _uint32                     *pvalues;           // previous value
    _uint32                     status;
    _uint32                     data_flags;
} client_report_t;

typedef struct _client_ctrl {
    struct hidd_connection      *connection;        // device connection handle
    client_report_t             *reports;           // list of device reports
    _uint32                     verbose;            // logging level
} client_ctrl_t;
Page updated: