HID driver for 6DOF mouse

Hello everyone,

I am currently trying to get a 6DOF-Mouse (3dconnexion Space Navigator) working in QNX 6.6 running on a BeagleBone Black and have several questions:
1.) Is there any documentation to the sys/hiddi header file?
2.) Are there a sample mouse/Joystick driver available which I can use and modify for my needs?
3.) I managed to read out the X, Y and Z values using this code: https://www.ram.ewi.utwente.nl/ECSSoftware/luna-docs/extreme3dpro_8cpp_source.html. Maybe there is an easy fix to geth the other values as well? I attached my adapted code here:

[code]#include <stdlib.h>
#include <stdio.h>
#include <sys/neutrino.h>
#include <sys/hiddi.h>
#include <sys/hidut.h>
#include <unistd.h>
#include <errno.h>

#define VID_3DCONNEXION 0x256f //USB vendor ID fpr 3dconnexion
#define PID_SPACE_NAVIGATOR 0xc641 //USB product ID for SpaceNavigator

struct hidd_connection *d_connection;

_Uint32t x, y, z, rx, ry, rz;

typedef struct
{
struct hidd_report_instance *creport_instance;
struct hidd_report *creport;
}spacenav_report_t;

spacenav_report_t sn_report;

void dump(struct hidd_connection *connection, struct hidd_report *handle, void *report_data, _Uint32t report_len, _Uint32t flags, void *user)
{
struct hidd_collection *collection;
struct hidd_report_instance *report_instance;
report_instance = sn_report.creport_instance;
hidd_report_collection( report_instance, &collection );

//This only returns values for X/Y/Z. the other functions return error code 2.
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_X, report_data, &x);
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_Y, report_data, &y);
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_Z, report_data, &z);
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_RX, report_data, &rx);
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_RY, report_data, &ry);
hidd_get_usage_value( report_instance, NULL, HIDD_PAGE_DESKTOP, HIDD_USAGE_RZ, report_data, &rz);

/* This also only returns Values for X, Y and Z:
x =  ((int16_t*) report_data)[0];
y =  ((int16_t*) report_data)[1];
z =  ((int16_t*) report_data)[2];
rx =  ((int16_t*) report_data)[3];
ry =  ((int16_t*) report_data)[4];
rz =  ((int16_t*) report_data)[5];
 */

}

void oninsertion(struct hidd_connection *connection,hidd_device_instance_t *device_instance) {
struct hidd_collection **hidd_collections, **hidd_mcollections;
struct hidd_report_instance *report_instance;
struct hidd_report *report;
_uint16 num_col, num_mcol;
_uint16 usage_page, usage;
_uint16 max_but;
int i;

// Get root level HID collections
hidd_get_collections( device_instance, NULL, &hidd_collections, &num_col);

// for each top level collection
for(i = 0; i < num_col; i++)
{
	// Get usage for the collection
	hidd_collection_usage( hidd_collections[i], &usage_page, &usage);

	// Ignore collection if it doesn't describe joystick functionality
	if( usage_page != HIDD_PAGE_DESKTOP || usage != HIDD_USAGE_JOYSTICK)
		continue;

	// *** The following is a bad hack. Fix it as recursive search for report ****
	hidd_get_collections( NULL, hidd_collections[i], &hidd_mcollections, &num_mcol);

	if ( num_col && hidd_get_report_instance( hidd_mcollections[0], 0 , HID_INPUT_REPORT,
			&report_instance ) == 0 )
	{
		hidd_num_buttons( report_instance, &max_but );

		if( hidd_report_attach( connection, device_instance, report_instance, 0,
				(max_but * sizeof(_int32)) , &report ) == 0 )
		{
			sn_report.creport = report;
			sn_report.creport_instance = report_instance;
			break;
		}
	}

} // end for

}

int main(int argc, char *argv[]) {

//Get I/O privileges
if (ThreadCtl(_NTO_TCTL_IO_PRIV, 0) != 0) {
	printf("ThreadCtl\r\n");
	return (EXIT_FAILURE);
}

//set up connection parameters
hidd_device_ident_t interest = {VID_3DCONNEXION, PID_SPACE_NAVIGATOR,(_uint32)HIDD_CONNECT_WILDCARD};
hidd_funcs_t 		funcs 	 = {_HIDDI_NFUNCS, &oninsertion, NULL, &dump, NULL};
hidd_connect_parm_t parm 	 = {NULL, HID_VERSION, HIDD_VERSION, 0, 0, &interest, &funcs, HIDD_CONNECT_WAIT};

//Try to connect
if(hidd_connect(&parm, &d_connection)!=0)
{
	printf("hidd_connect(): Error\n");
	return EXIT_FAILURE;
}

while(1)
{
	sleep(1);
	printf("X:%i\t Y:%i\t Z:%i\t rX:%i\t rY:%i\t rZ:%i\n", x, y, z, rx, ry, rz);
}

return EXIT_SUCCESS;

}[/code]

Thanks in advance!