Open mekaci89 opened 6 years ago
Can you create a pull request with your change? If so I would be happy to integrate it into this repository. This is kind of an old project, and I am sure that the USB 2.0 hosting library has received some updates that this project might not support.
BenBrewerBowman, firstly thank you very much for providing such a library that we can access to joystick values in arduino sketch too.
I am using "USB Host Shield 2.0 Library" and your Arduino_Logitech_3D_Joystick Library to use my "Logitech 3D PRO Extreme" joystick and everything is working nicely. But I was experienced some problem while using nrf24 wireless communication between two arduino devices.
After that, I found a wireless joystick on internet from logitech company and it is similar too "Logitech 3D PRO Extreme Joystick". It's name is "Logitech Cordless Joystick Freedom 2.4".
"Logitech Cordless Joystick Freedom 2.4" is very old joystick and it is the only wireless joystick of its own kind too, I hardly found it on ebay already.
This "Logitech Cordless Joystick Freedom 2.4" is working with "USB Host Shield 2.0 Library"s USBHIDJoystick example sketch; but "Logitech Cordless Joystick Freedom 2.4" is not working with your BenBrewerBowman/Arduino_Logitech_3D_Joystick Library. I don't know why I don't get any reading on serial monitor.
I looked into the USBHIDJoystick example sketch and its cpp, header files and the code written there is more complex than yours; so I failed to modify :(
If it is possible would you make modification on this sketch and its cpp and header files please to access joystick values inside of arduino sketch too ? Then we can use this wireless logitech joystick too.
"USB Host Shield 2.0 Library"s USBHIDJoystick example
USBHIDJoystick example sketch:
`#include
include
include
// Satisfy IDE, which only needs to see the include statment in the ino.
ifdef dobogusinclude
include
endif
include
include "hidjoystickrptparser.h"
USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); JoystickEvents JoyEvents; JoystickReportParser Joy(&JoyEvents);
void setup() { Serial.begin(115200);
if !defined(MIPSEL)
endif
}
void loop() { Usb.Task(); }
USBHIDJoystick example sketch's cpp file:
#include "hidjoystickrptparser.h"JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : joyEvents(evt), oldHat(0xDE), oldButtons(0) { for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = 0xD; }
void JoystickReportParser::Parse(USBHID hid, bool is_rpt_id, uint8_t len, uint8_t buf) { bool match = true;
}
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { Serial.print("X1: "); PrintHex (evt->X, 0x80);
Serial.print("\tY1: ");
PrintHex (evt->Y, 0x80);
Serial.print("\tX2: ");
PrintHex (evt->Z1, 0x80);
Serial.print("\tY2: ");
PrintHex (evt->Z2, 0x80);
Serial.print("\tRz: ");
PrintHex (evt->Rz, 0x80);
Serial.println("");
}
void JoystickEvents::OnHatSwitch(uint8_t hat) { Serial.print("Hat Switch: "); PrintHex (hat, 0x80);
Serial.println("");
}
void JoystickEvents::OnButtonUp(uint8_t but_id) { Serial.print("Up: "); Serial.println(but_id, DEC); }
void JoystickEvents::OnButtonDn(uint8_t but_id) { Serial.print("Dn: "); Serial.println(but_id, DEC); }`
USBHIDJoystick example sketch's header file: `#if !defined(__HIDJOYSTICKRPTPARSER_H__)
define __HIDJOYSTICKRPTPARSER_H__
include
struct GamePadEventData { uint8_t X, Y, Z1, Z2, Rz; };
class JoystickEvents { public: virtual void OnGamePadChanged(const GamePadEventData *evt); virtual void OnHatSwitch(uint8_t hat); virtual void OnButtonUp(uint8_t but_id); virtual void OnButtonDn(uint8_t but_id); };
define RPT_GEMEPAD_LEN 5
class JoystickReportParser : public HIDReportParser { JoystickEvents *joyEvents;
public: JoystickReportParser(JoystickEvents *evt);
};
endif // __HIDJOYSTICKRPTPARSER_H__`
If anyone has deep knowledge about this "how to make that modification, please would you help ? thank you very much.