Set up the driver skeleton

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>

Create structures to manage the driver state and device reports. Note that these structure declarations are mere suggestions. Declare a structure that fits your use case best.

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: