Skip to content

Commit 36f2396

Browse files
committed
1 parent 12cf2bb commit 36f2396

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sentence=Allows an Arduino board with USB capabilities (e.g. Leonardo, Arduino M
66
paragraph=This library is built on the PluggableUSB library. It can be used with or without other HID-based libraries (Mouse, Keyboard, etc.).
77
category=Device Control
88
url=https://github.com/MHeironimus/ArduinoJoystickLibrary
9-
architectures=avr,sam
9+
architectures=avr,sam,samd

src/DynamicHID/DynamicHID.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#ifdef _VARIANT_ARDUINO_DUE_X_
2727
#define USB_SendControl USBD_SendControl
2828
#define USB_Send USBD_Send
29+
#elif defined(ARDUINO_ARCH_SAMD)
30+
#define USB_SendControl(flags, d, len) USBDevice.sendControl(d, len)
31+
#define USB_Send USBDevice.send
32+
#define TRANSFER_RELEASE 0x00
2933
#endif
3034

3135
DynamicHID_& DynamicHID()
@@ -122,7 +126,12 @@ bool DynamicHID_::setup(USBSetup& setup)
122126
return true;
123127
}
124128
if (request == DYNAMIC_HID_GET_IDLE) {
129+
#ifdef ARDUINO_ARCH_SAMD
130+
USBDevice.armSend(0, &idle, 1);
131+
return true;
132+
#else
125133
// TODO: Send8(idle);
134+
#endif
126135
}
127136
}
128137

@@ -157,7 +166,11 @@ DynamicHID_::DynamicHID_(void) : PluggableUSBModule(1, 1, epType),
157166
rootNode(NULL), descriptorSize(0),
158167
protocol(DYNAMIC_HID_REPORT_PROTOCOL), idle(1)
159168
{
160-
epType[0] = EP_TYPE_INTERRUPT_IN;
169+
#ifdef ARDUINO_ARCH_SAMD
170+
epType[0] = USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0);
171+
#else
172+
epType[0] = EP_TYPE_INTERRUPT_IN;
173+
#endif
161174
PluggableUSB().plug(this);
162175
}
163176

src/DynamicHID/DynamicHID.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <stdint.h>
2626
#include <Arduino.h>
2727

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

121121
private:
122-
#ifdef _VARIANT_ARDUINO_DUE_X_
122+
#if defined(_VARIANT_ARDUINO_DUE_X_) || defined(ARDUINO_ARCH_SAMD)
123123
uint32_t epType[1];
124124
#else
125125
uint8_t epType[1];

0 commit comments

Comments
 (0)