MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.1k stars 409 forks source link

Arduino Zero compatiblity ? #51

Open Synless opened 7 years ago

Synless commented 7 years ago

Is it possible to port it so that is can also be compatible with the SAMD21 based board ? I tried a bit myself but I'm not good enough to do it. Upon compilation I get "Joystick.h is missing", and when I try to place the .h and .cpp next to the .ino my the Arduino IDE found invalid lib and my board goes berzerk. So I guess that this part of the HID isn't yet written for the Arduino Zero, or that it does not support this part of the HID ?

MHeironimus commented 7 years ago

I have not worked with the Arduino Zero board or any other SAMD21 based boards, so I do not know.

mieperDE commented 6 years ago

I tried. But I get this error:

Compiling 'joystickmax' for 'Arduino/Genuino Zero (Programming Port)'

Joystick.h:24: In file included from joystickmax.ino:7: from

DynamicHID.h: 37:28: fatal error: PluggableUSB.h: No such file or directory

include "PluggableUSB.h"

compilation terminated

An error was encountered during the 'Deep Search' library discovery process. Build failed for project 'joystickmax'

Changed something for a test.

\Arduino\libraries\Joystick\src\DynamicHID\DynamicHID.h

#ifdef _VARIANT_ARDUINO_DUE_X_
  // The following values are the same as AVR's USBAPI.h
  // Reproduced here because SAM doesn't have these in
  // its own USBAPI.H
  #define USB_EP_SIZE 64
  #define TRANSFER_PGM 0x80

  #include "USB/PluggableUSB.h"
#else
  #include "USB/PluggableUSB.h"             //<----- EDIT
#endif

Hmm..

Compiling 'joystickmax' for 'Arduino/Genuino Zero (Programming Port)'

Arduino.h:129: In file included from DynamicHID.h:26: from DynamicHID.cpp:22: from Error compiling libraries DynamicHID.cpp: In member function virtual int DynamicHID_::getInterface(uint8_t*)

Build failed for project 'joystickmax' DynamicHID.cpp: 43:77: error: 'USB_EP_SIZE' was not declared in this scope D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) USBCore.h:276: note in definition of macro D_ENDPOINT { 7, 5, _addr,_attr,_packetSize, _interval }

DynamicHID.cpp: 45:63: error: 'USB_SendControl' was not declared in this scope return USBSendControl(0, &hidInterface, sizeof(hidInterface)) DynamicHID.cpp: In member function virtual int DynamicHID::getDescriptor(USBSetup&)

DynamicHID.cpp: 60:48: error: 'TRANSFER_PGM' was not declared in this scope 0), node->data, node->length)

DynamicHID.cpp: 60:91: error: 'USBSendControl' was not declared in this scope 0), node->data, node->length) DynamicHID.cpp: In member function int DynamicHID::SendReport(uint8_t, const void*, int)

DynamicHID.cpp: 102:36: error: 'TRANSFER_RELEASE' was not declared in this scope return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, p, len + 1)

DynamicHID.cpp: 102:64: error: 'USB_Send' was not declared in this scope return USB_Send(pluggedEndpoint | TRANSFERRELEASE, p, len + 1) DynamicHID.cpp: In constructor DynamicHID::DynamicHID_()

DynamicHID.cpp: 158:65: error: no matching function for call to 'PluggableUSBModule::PluggableUSBModule(int, int, uint8_t [1]) protocol(DYNAMIC_HID_REPORT_PROTOCOL), idle(1) DynamicHID.cpp:158: note candidates are

DynamicHID.h:37: In file included from DynamicHID.cpp:22: from PluggableUSB.h:30: note PluggableUSBModule PluggableUSBModule(uint8_t, uint8_t, uint32_t) PluggableUSBModule(uint8_t numEps, uint8_t numIfs, uint32_t epType) PluggableUSB.h:30: note no known conversion for argument 3 from uint8_t [1] {aka unsigned char [1]} to uint32_t {aka long unsigned int} PluggableUSB.h:28: note constexpr PluggableUSBModule PluggableUSBModule(const PluggableUSBModule&) class PluggableUSBModule { PluggableUSB.h:28: note candidate expects 1 argument, 3 provided PluggableUSB.h:28: note constexpr PluggableUSBModule PluggableUSBModule(PluggableUSBModule&&) PluggableUSB.h:28: note candidate expects 1 argument, 3 provided

DynamicHID.cpp: 160:14: error: 'EP_TYPE_INTERRUPT_IN' was not declared in this scope epType[0] = EP_TYPE_INTERRUPT_IN