CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

USB descriptor help-- gamepad

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

USB descriptor help-- gamepad
PostPosted: Sun Feb 13, 2011 5:56 pm     Reply with quote

I'm trying to take the mouse example from the USB developers kit, and change it to a gamepad as they suggest in the documentation for the kit, but I'm having some troubles.

I'm using the following descriptor:

Code:

const char USB_CLASS_SPECIFIC_DESC[] =       
   {
0x05, 0x01, // ; USAGE_PAGE (Generic Desktop)
0x09, 0x05, //; USAGE (Gamepad)
0xA1, 0x01, //; COLLECTION (Application)
0x09, 0x01, //;   USAGE (Pointer)
0xA1, 0x00, //;   COLLECTION (Physical)
0x09, 0x30, //;     USAGE (X)
0x09, 0x31, //;     USAGE (Y)
0x15, 0x81, //;     LOGICAL_MINIMUM (-127)
0x26, 0x7F,  //;     LOGICAL_MAXIMUM (127)
0x75, 0x08, //;     REPORT_SIZE (8)
0x95, 0x02, //;     REPORT_COUNT (2)
0x81, 0x02, //;     INPUT (Data,Var,Abs)
0xC0, //;   END_COLLECTION
0x05, 0x09, //;   USAGE_PAGE (Button)
0x19, 0x01, //;   USAGE_MINIMUM (Button 1)
0x29, 0x06, //;   USAGE_MAXIMUM (Button 6)
0x15, 0x00, //;   LOGICAL_MINIMUM (0)
0x25, 0x01, //;   LOGICAL_MAXIMUM (1)
0x75, 0x01, //;   REPORT_SIZE (1)
0x95, 0x06, //;   REPORT_COUNT (6)
0x81, 0x02, //;   INPUT (Data,Var,Abs)
0x95, 0x02, //;   REPORT_COUNT (2)
0x81, 0x03, //;   INPUT (Constant,Var,Abs)
0xC0 //; END_COLLECTION

   };



The output array is
int8 out_data[3]={0,0,0};

and I'm trying to write x and y data to out_data[0] and out_data[1]

I haven't changed anything else in the HID mouse example from the dev kit.

Oddly enough, the device is recognized as a mouse, not a gamepad, and I get "This device cannot start. (Code 10)"

This is my first attempt at USB other than the step-by-step examples, and I could use a hand through this.

Thanks
Scott
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 11:07 am     Reply with quote

Let me try one more time--

I'm trying to follow the example in the USB Dev Kit. I have the HID mouse example running, but the Docs clearly say that by changing the HID descriptor I should be able to change this to a gamepad just by changing the Usage Page to Gamepad and redefining the application collection to show x and y.

I'm having a ton of problems doing this. I changed the Class specific descriptor as shown below and the device won't mount properly. Is there anything else that needs to be changed?

I'm new to USB firmware, so if I'm not asking the right question, can you point me to the right resource? I'm reading USB complete, and its also not helping me with this issue.

Thanks
Scott
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 11:38 am     Reply with quote

I'm running USB View--

The output for this try seems to end with Open Pipes= 0

For the device that works, open pipes=1, and the report continues to the endpoint descriptor and keeps going
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 12:18 pm     Reply with quote

Even more data. In debugging, by toggling LEDs, it seems like the line in my main:

Code:

if (usb_put_packet(1,out_data,3,USB_DTS_TOGGLE))
   count++;


is never testing true!!

The device, however, is being enumerated.

out_data is declared:

Code:
 int8 out_data[3]={0,0,0};


Is there any reason anyone can see why usb_put_packet should not return true??
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Mon Feb 21, 2011 10:43 am     Reply with quote

Solved-

I think the problem was that windows seemed stuck on the driver that was being used for the HID Mouse example (maybe its using the device ID, which I haven't been changing between examples, and just using the last known good driver). All I needed to do was "search for a new driver" from the device settings window.

Odd debugging simultaneously on the firmware and on the OS. Strange new world for me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group