Pages: [1]   Go Down
Author Topic: Interfacing Logitech Gamepad with Arduino using USB Host Shield  (Read 1369 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi to all Arduino developers!

I am trying to interface Logitech Dual Action Gamepad with Arduino using oleg's USB Host Shield 2.0. This host shield works with two version of code library.

1. Legacy Host Library
2. Host Library 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 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
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!


* HID report descriptor.doc (28.5 KB - downloaded 55 times.)
* HUB+GAMEPAD OUTPUT.txt (1.6 KB - downloaded 18 times.)

Pages: [1]   Go Up
Jump to: