Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tagantroy committed Oct 19, 2022
1 parent 12cf2bb commit 36f2396
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sentence=Allows an Arduino board with USB capabilities (e.g. Leonardo, Arduino M
paragraph=This library is built on the PluggableUSB library. It can be used with or without other HID-based libraries (Mouse, Keyboard, etc.).
category=Device Control
url=https://github.com/MHeironimus/ArduinoJoystickLibrary
architectures=avr,sam
architectures=avr,sam,samd
15 changes: 14 additions & 1 deletion src/DynamicHID/DynamicHID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#ifdef _VARIANT_ARDUINO_DUE_X_
#define USB_SendControl USBD_SendControl
#define USB_Send USBD_Send
#elif defined(ARDUINO_ARCH_SAMD)
#define USB_SendControl(flags, d, len) USBDevice.sendControl(d, len)
#define USB_Send USBDevice.send
#define TRANSFER_RELEASE 0x00
#endif

DynamicHID_& DynamicHID()
Expand Down Expand Up @@ -122,7 +126,12 @@ bool DynamicHID_::setup(USBSetup& setup)
return true;
}
if (request == DYNAMIC_HID_GET_IDLE) {
#ifdef ARDUINO_ARCH_SAMD
USBDevice.armSend(0, &idle, 1);
return true;
#else
// TODO: Send8(idle);
#endif
}
}

Expand Down Expand Up @@ -157,7 +166,11 @@ DynamicHID_::DynamicHID_(void) : PluggableUSBModule(1, 1, epType),
rootNode(NULL), descriptorSize(0),
protocol(DYNAMIC_HID_REPORT_PROTOCOL), idle(1)
{
epType[0] = EP_TYPE_INTERRUPT_IN;
#ifdef ARDUINO_ARCH_SAMD
epType[0] = USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0);
#else
epType[0] = EP_TYPE_INTERRUPT_IN;
#endif
PluggableUSB().plug(this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/DynamicHID/DynamicHID.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdint.h>
#include <Arduino.h>

#ifdef _VARIANT_ARDUINO_DUE_X_
#if defined(_VARIANT_ARDUINO_DUE_X_) || defined(ARDUINO_ARCH_SAMD)
// The following values are the same as AVR's USBAPI.h
// Reproduced here because SAM doesn't have these in
// its own USBAPI.H
Expand Down Expand Up @@ -119,7 +119,7 @@ class DynamicHID_ : public PluggableUSBModule
uint8_t getShortName(char* name);

private:
#ifdef _VARIANT_ARDUINO_DUE_X_
#if defined(_VARIANT_ARDUINO_DUE_X_) || defined(ARDUINO_ARCH_SAMD)
uint32_t epType[1];
#else
uint8_t epType[1];
Expand Down

0 comments on commit 36f2396

Please sign in to comment.