Arduino Leonardo problem with coding a joystick

Hi,

I want to code a joystick on my arduino leonardo and I always got a problem. When I upload my code to my arduino I got no error so its upload to my arduino but my computer do not recognize it. I modified the code from http://www.imaginaryindustries.com/blog/?p=80 to have 6 axis at 16 bit.

I modified those line and it won’t work
From the HID.cpp files

0x15, 0x00,			// LOGICAL_MINIMUM (0)
		0x26, 0xff, 0xff,		// LOGICAL_MAXIMUM (65535)
		0x75, 0x08,			// REPORT_SIZE (8)

		0x09, 0x01,			// USAGE (Pointer)
		0xA1, 0x00,			// COLLECTION (Physical)
			0x09, 0x30,		// USAGE (x)
			0x09, 0x31,		// USAGE (y)
			0x09, 0x32,		// USAGE (z)
			0x09, 0x33,		// USAGE (rx)
			0x09, 0x34,		// USAGE (ry)
			0x09, 0x35,		// USAGE (rz)
			0x95, 0x06,		// REPORT_COUNT (6)
			0x81, 0x02,		// INPUT (Data,Var,Abs)
		0xc0,				// END_COLLECTION

The original files look like that

0x15, 0x00,			// LOGICAL_MINIMUM (0)
		0x26, 0xff, 0x00,		// LOGICAL_MAXIMUM (255)
		0x75, 0x08,			// REPORT_SIZE (8)

		0x09, 0x01,			// USAGE (Pointer)
		0xA1, 0x00,			// COLLECTION (Physical)
			0x09, 0x30,		// USAGE (x)
			0x09, 0x31,		// USAGE (y)
			0x09, 0x32,		// USAGE (z)
			0x09, 0x33,		// USAGE (rx)
			0x09, 0x34,		// USAGE (ry)
			0x09, 0x35,		// USAGE (rz)
			0x95, 0x06,		// REPORT_COUNT (2)
			0x81, 0x02,		// INPUT (Data,Var,Abs)
		0xc0,				// END_COLLECTION
// the report section
#define joyBytes 20 		// should be equivalent to sizeof(JoyState_t)

void Joystick_::setState(JoyState_t *joySt)
{
	uint8_t data[joyBytes];
	uint32_t  buttonTmp;
        uint16_t  xAxisTmp;
        uint16_t  yAxisTmp;
        uint16_t  zAxisTmp;
        uint16_t  xRotAxisTmp;
        uint16_t  yRotAxisTmp;
        uint16_t  zRotAxisTmp;
	
        buttonTmp = joySt->buttons;
        xAxisTmp = joySt->xAxis;
        yAxisTmp = joySt->yAxis;
        zAxisTmp = joySt->zAxis;
        xRotAxisTmp = joySt->xRotAxis;
        yRotAxisTmp = joySt->yRotAxis;
        zRotAxisTmp = joySt->zRotAxis;
        
	data[0] = buttonTmp & 0xFF;		// Break 32 bit button-state out into 4 bytes, to send over USB
	buttonTmp >>= 8;
	data[1] = buttonTmp & 0xFF;
	buttonTmp >>= 8;
	data[2] = buttonTmp & 0xFF;
	buttonTmp >>= 8;
	data[3] = buttonTmp & 0xFF;

	data[4] = joySt->throttle;		// Throttle
	data[5] = joySt->rudder;		// Steering
        data[6] = joySt->brake;	    	        // Brake
        data[7] = joySt->clutch;		// Clutch

	data[8] = (joySt->hatSw2 << 4) | joySt->hatSw1;		// Pack hat-switch states into a single byte

	data[9] = xAxisTmp & 0xFF;		// X axis
	xAxisTmp >>= 8;
	data[10] = xAxisTmp & 0xFF;

	data[11] = yAxisTmp & 0xFF;		// Y axis
	yAxisTmp >>= 8;
	data[12] = yAxisTmp & 0xFF;		

	data[13] = zAxisTmp & 0xFF;		// Z axis
	zAxisTmp >>= 8;
	data[14] = zAxisTmp & 0xFF;
			
	data[15] = xRotAxisTmp & 0xFF;		// x Rot axis
	xRotAxisTmp >>= 8;
	data[16] = xRotAxisTmp & 0xFF;	

	data[17] = yRotAxisTmp & 0xFF;		// Y Rot axis
	yRotAxisTmp >>= 8;
	data[18] = yRotAxisTmp & 0xFF;

	data[18] = zRotAxisTmp & 0xFF;		// z Rot axis
	zRotAxisTmp >>= 8;
	data[19] = zRotAxisTmp & 0xFF;

	//HID_SendReport(Report number, array of values in same order as HID descriptor, length)
	HID_SendReport(3, data, joyBytes);
	// The joystick is specified as using report 3 in the descriptor. That's where the "3" comes from
}

And The code from Imaginary industries is

0x09, 0x01,			// USAGE (Pointer)
		0xA1, 0x00,			// COLLECTION (Physical)
			0x09, 0x30,		// USAGE (x)
			0x09, 0x31,		// USAGE (y)
			0x09, 0x32,		// USAGE (z)
			0x09, 0x33,		// USAGE (rx)
			0x09, 0x34,		// USAGE (ry)
			0x09, 0x35,		// USAGE (rz)
			0x95, 0x06,		// REPORT_COUNT (2)
			0x81, 0x02,		// INPUT (Data,Var,Abs)
		0xc0,				// END_COLLECTION

// report section
#define joyBytes 13 		// should be equivalent to sizeof(JoyState_t)

void Joystick_::setState(JoyState_t *joySt)
{
	uint8_t data[joyBytes];
	uint32_t buttonTmp;
	buttonTmp = joySt->buttons;

	data[0] = buttonTmp & 0xFF;		// Break 32 bit button-state out into 4 bytes, to send over USB
	buttonTmp >>= 8;
	data[1] = buttonTmp & 0xFF;
	buttonTmp >>= 8;
	data[2] = buttonTmp & 0xFF;
	buttonTmp >>= 8;
	data[3] = buttonTmp & 0xFF;

	data[4] = joySt->throttle;		// Throttle
	data[5] = joySt->rudder;		// Steering

	data[6] = (joySt->hatSw2 << 4) | joySt->hatSw1;		// Pack hat-switch states into a single byte

	data[7] = joySt->xAxis;		// X axis
	data[8] = joySt->yAxis;		// Y axis
	data[9] = joySt->zAxis;		// Z axis
	data[10] = joySt->xRotAxis;		// rX axis
	data[11] = joySt->yRotAxis;		// rY axis
	data[12] = joySt->zRotAxis;		// rZ axis

	//HID_SendReport(Report number, array of values in same order as HID descriptor, length)
	HID_SendReport(3, data, joyBytes);
	// The joystick is specified as using report 3 in the descriptor. That's where the "3" comes from
}

My modified usapi.h

typedef struct JoyState 		// Pretty self explanitory. Simple state to store all the joystick parameters
{
	uint16_t		xAxis;
	uint16_t		yAxis;
	uint16_t		zAxis;

	uint16_t		xRotAxis;
	uint16_t		yRotAxis;
	uint16_t		zRotAxis;

	uint8_t		throttle;
	uint8_t		rudder;
        uint8_t		brake;
        uint8_t		clutch;
        
	uint8_t		hatSw1;
	uint8_t		hatSw2;

	uint32_t	buttons;		// 32 general buttons

} JoyState_t;

usapi.h from imaginary industries

typedef struct JoyState 		// Pretty self explanitory. Simple state to store all the joystick parameters
{
	uint8_t		xAxis;
	uint8_t		yAxis;
	uint8_t		zAxis;

	uint8_t		xRotAxis;
	uint8_t		yRotAxis;
	uint8_t		zRotAxis;

	uint8_t		throttle;
	uint8_t		rudder;

	uint8_t		hatSw1;
	uint8_t		hatSw2;

	uint32_t	buttons;		// 32 general buttons

} JoyState_t;

So when I upload my files, my rx and tx leds flash one time every 4 seconds, What I am doing wrong is it the hid.cpp.If you want to know what is my .ino there it is

JoyState_t joySt;

void setup()
{
	

        
	joySt.xAxis = 0;
	joySt.yAxis = 0;
	joySt.zAxis = 0;
	joySt.xRotAxis = 0;
	joySt.yRotAxis = 0;
	joySt.zRotAxis = 0;

	joySt.throttle = 0;
	joySt.buttons = 0;
	joySt.brake = 0;
        joySt.clutch = 0;
	
       
        
}

void loop()
{
        
	joySt.xAxis = random(255);
	joySt.yAxis = random(255);
	joySt.zAxis = random(255);
	joySt.xRotAxis = random(255);
	joySt.yRotAxis = random(255);
	joySt.zRotAxis = random(255);
	
	joySt.throttle = random(255);
	joySt.brake = random(255);
        joySt.clutch = random(255);
        
        

//     Avec des pots oui avec des rotary encoder non
//	joySt.xRotAxis = (analogRead(A1) / 4); 
//	joySt.throttle = (analogRead(A2) / 4);
//	joySt.brake = (analogRead(A3) / 4);
//      joySt.clutch = (analogRead(A4) / 4);

	
	joySt.buttons <<= 1;
	if (joySt.buttons == 0)
		joySt.buttons = 1;



	delay(100);

	// Call Joystick.move
	Joystick.setState(&joySt);

}

Sorry for my bad english… Hope you can help me!

Thanks

EDIT: I forgot to mentioned that I already try the code from imaginary industries and it work. And Why i want to have 16 bit of reading it because I want to put rotary encoders for my diy project it will be 3 rotary encoders for diy Sim racing pedals