Go Down

Topic: Interfacing Logitech Gamepad with Arduino using USB Host Shield (Read 1 time) previous topic - next topic


Hi to all Arduino developers!

I am trying to interface Logitech Dual Action Gamepad http://www.logitech.com/gaming/controllers/devices/288 with Arduino using oleg's USB Host Shield 2.0. This host shield works with two version of code library.

1. Legacy Host Library https://github.com/felis/USB_Host_Shield
2. Host Library 2.0 https://github.com/felis/USB_Host_Shield_2.0

Library 2.0 supports USB Hub too. I want to Interface Gampad and other USB device (mostly USB touchscreen monitor) so I need Hub functionality working.

I started reading this http://www.circuitsathome.com/communicating-arduino-with-hid-devices-part-1 article about how to read HID reports from Gamepad with Legacy Host Library .(Article is about USB mouce but Gamepad is almost the same). I test the programs on that article with Gamepad and it worked fine. But now I want to develop same sort of program with USB Hub and Library 2.0. and I have some confusion.

I am trying to write similar function to this one for Gamepad
Code: [Select]

void mouse1_init( void )
byte rcode = 0;  //return code
byte tmpdata;
byte* byte_ptr = &tmpdata;
  ep_record[ 0 ] = *( Usb.getDevTableEntry( 0,0 ));  //copy endpoint 0 parameters
  ep_record[ 1 ].MaxPktSize = EP_MAXPKTSIZE;
  ep_record[ 1 ].sndToggle = bmSNDTOG0;
  ep_record[ 1 ].rcvToggle = bmRCVTOG0;
  Usb.setDevTableEntry( 1, ep_record );              //plug kbd.endpoint parameters to devtable
  /* Configure device */
  rcode = Usb.setConf( DEVADDR, 0, CONFVALUE );
  if( rcode ) {
    Serial.print("Error configuring mouse. Return code : ");
    Serial.println( rcode, HEX );
    while(1);  //stop
  }//if( rcode...
  rcode = Usb.getIdle( DEVADDR, 0, 0, 0, (char *)byte_ptr );
  if( rcode ) {
    Serial.print("Get Idle error. Return code : ");
    Serial.println( rcode, HEX );
    while(1);  //stop
  Serial.print("Idle Rate: ");
  Serial.print(( tmpdata * 4 ), DEC );        //rate is returned in multiples of 4ms
  Serial.println(" ms");
  tmpdata = 0;
  rcode = Usb.setIdle( DEVADDR, 0, 0, 0, tmpdata );
  if( rcode ) {
    Serial.print("Set Idle error. Return code : ");
    Serial.println( rcode, HEX );
    while(1);  //stop
  Usb.setUsbTaskState( USB_STATE_RUNNING );

1. With new Library do I need to initialize the gamepad this way?
2. New library does not have get/setDevTableEntry. Is it same as get/setEpInfoEntry?
3. getIdle/setIdle are not in new Library but that should be ok i think.

So how does the initialization process go for HID devices with new library. I have attached output of Hub test program and HID report descriptor of Gamepad.

I would appreciate your help and many thanks!


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131