Skip to content

Commit 8e3b5b4

Browse files
authored
Merge pull request MHeironimus#80 from MHeironimus/master
Update version-2.0 branch with latest changes from master
2 parents 533f534 + 3d626fb commit 8e3b5b4

File tree

5 files changed

+59
-53
lines changed

5 files changed

+59
-53
lines changed

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## How to contribute to the Arduino Joystick Library
2+
3+
### Report a bug
4+
5+
* **Check to see if the bug has already reported** by searching on GitHub under [Issues](https://github.com/MHeironimus/ArduinoJoystickLibrary/issues).
6+
7+
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/MHeironimus/ArduinoJoystickLibrary/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible (e.g. host OS, Arduino IDE version, etc.), any important hardware information (e.g. name of Arduino board being used, specific pin wirings if they are relavant, etc.), and a **sample sketch** file demonstrating the issue.
8+
9+
### Fix a bug
10+
11+
* Open a new GitHub pull request with the fix.
12+
13+
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
14+
15+
### Whitespace, format code, or cosmetic updates
16+
17+
* Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability will generally not be accepted.
18+
19+
### Adding a new feature
20+
21+
* Feel free to [create a new issue](https://github.com/MHeironimus/ArduinoJoystickLibrary/issues/new) to document the feature you are planning to add. This will allow others to see and comment on what you would plan to add to the library.
22+
23+
### Questions about the library
24+
25+
* Be sure to check the [FAQ](https://github.com/MHeironimus/ArduinoJoystickLibrary/wiki/FAQ) in the [Wiki](https://github.com/MHeironimus/ArduinoJoystickLibrary/wiki) to see if your question has already been answered.
26+
* Another good place to look for general Arduino questions is the [Arduino]() website.
27+
28+
The Arduino Joystick Library is a volunteer effort done in volunteer's spare time. Please be patient as it may take some time for bugs to be fixed, features to be added, and questions to be answered.

Joystick/library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Joystick
2-
version=2.0.4
2+
version=2.0.5
33
author=Matthew Heironimus
44
maintainer=Matthew Heironimus <[email protected]>
5-
sentence=Arduino library that allows an Arduino Leonardo or Arduino Micro to appear as a Joystick or Gamepad.
5+
sentence=Arduino library that allows an Arduino Leonardo, Arduino Micro, or Arudino Due to appear as a Joystick or Gamepad.
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
9+
architectures=avr,sam

Joystick/src/DynamicHID/DynamicHID.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
#if defined(USBCON)
2525

26+
#ifdef _VARIANT_ARDUINO_DUE_X_
27+
#define USB_SendControl USBD_SendControl
28+
#define USB_Send USBD_Send
29+
#endif
30+
2631
DynamicHID_& DynamicHID()
2732
{
2833
static DynamicHID_ obj;
@@ -91,11 +96,10 @@ void DynamicHID_::AppendDescriptor(DynamicHIDSubDescriptor *node)
9196

9297
int DynamicHID_::SendReport(uint8_t id, const void* data, int len)
9398
{
94-
auto ret = USB_Send(pluggedEndpoint, &id, 1);
95-
if (ret < 0) return ret;
96-
auto ret2 = USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
97-
if (ret2 < 0) return ret2;
98-
return ret + ret2;
99+
uint8_t p[len + 1];
100+
p[0] = id;
101+
memcpy(&p[1], data, len);
102+
return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, p, len + 1);
99103
}
100104

101105
bool DynamicHID_::setup(USBSetup& setup)

Joystick/src/DynamicHID/DynamicHID.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@
2424

2525
#include <stdint.h>
2626
#include <Arduino.h>
27-
#include "PluggableUSB.h"
27+
28+
#ifdef _VARIANT_ARDUINO_DUE_X_
29+
// The following values are the same as AVR's USBAPI.h
30+
// Reproduced here because SAM doesn't have these in
31+
// its own USBAPI.H
32+
#define USB_EP_SIZE 64
33+
#define TRANSFER_PGM 0x80
34+
35+
#include "USB/PluggableUSB.h"
36+
#else
37+
#include "PluggableUSB.h"
38+
#endif
2839

2940
#if defined(USBCON)
3041

@@ -108,7 +119,11 @@ class DynamicHID_ : public PluggableUSBModule
108119
uint8_t getShortName(char* name);
109120

110121
private:
122+
#ifdef _VARIANT_ARDUINO_DUE_X_
123+
uint32_t epType[1];
124+
#else
111125
uint8_t epType[1];
126+
#endif
112127

113128
DynamicHIDSubDescriptor* rootNode;
114129
uint16_t descriptorSize;

README.md

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Arduino Joystick Library
2-
#### Version 2.0.4
3-
This library can be used with Arduino IDE 1.6.6 (or above) to add one or more joysticks (or gamepads) to the list of HID devices an [Arduino Leonardo](https://www.arduino.cc/en/Main/ArduinoBoardLeonardo) or [Arduino Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro) (or any Arduino clone that is based on the ATmega32u4) can support. This will not work with Arduino IDE 1.6.5 (or below) or with non-32u4 based Arduino devices (e.g. Arduino UNO, Arduino MEGA, etc.).
2+
#### Version 2.0.5
3+
This library can be used with Arduino IDE 1.6.6 (or above) to add one or more joysticks (or gamepads) to the list of HID devices an [Arduino Leonardo](https://www.arduino.cc/en/Main/ArduinoBoardLeonardo) or [Arduino Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro) (or any Arduino clone that is based on the ATmega32u4) can support. This library will also work with the [Arduino Due](https://www.arduino.cc/en/Main/ArduinoBoardDue), thanks to [@Palakis](https://github.com/Palakis). A complete list of supported boards can be found in the [Wiki](https://github.com/MHeironimus/ArduinoJoystickLibrary/wiki/Supported-Boards). This will not work with Arduino IDE 1.6.5 (or below) or with non-32u4 based Arduino devices (e.g. Arduino UNO, Arduino MEGA, etc.).
44

55
## Features
66
The joystick or gamepad can have the following features:
@@ -185,45 +185,4 @@ Sets the value of the specified hat switch. The hatSwitch is 0-based (i.e. hat s
185185
### Joystick.sendState()
186186
Sends the updated joystick state to the host computer. Only needs to be called if `AutoSendState` is `false` (see `Joystick.begin` for more details).
187187

188-
## Testing Details
189-
I have used this library to make an Arduino appear as the following:
190-
191-
- 1 joystick / gamepad
192-
- 2 joysticks / gamepads
193-
- 3 joysticks / gamepads
194-
- 4 joysticks / gamepads
195-
196-
I have tested with 1 - 32 buttons using the standard Microsoft Windows Game Controller Test dialog.
197-
I have also tested this with 1 - 64 buttons.
198-
To test a joystick with over 32 buttons, a third-party testing tool will need to be used (e.g. http://www.planetpointy.co.uk/joystick-test-application/).
199-
200-
I have tested with 0, 1, and 2 hat switches.
201-
202-
I have tested this library using the following Arduino IDE Versions:
203-
204-
- 1.6.6 through 1.6.13
205-
- 1.8.0 through 1.8.4
206-
207-
I have tested this library with the following boards:
208-
209-
- [Arduino Leonardo](https://www.arduino.cc/en/Main/ArduinoBoardLeonardo)
210-
- [Arduino Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro)
211-
212-
Others have tested this library with the following boards:
213-
214-
- [SparkFun Pro Micro](https://www.sparkfun.com/products/12640)
215-
- [RobotDyn Micro ATmega32U4-MU](http://robotdyn.com/catalog/boards/micro_atmega32u4_mu/) by [@Sylverzerom](https://github.com/Sylverzerom)
216-
217-
Boards that should work, but I have not personally tested:
218-
219-
- [Arduino Leonardo ETH](https://store.arduino.cc/usa/arduino-leonardo-eth)
220-
- [Arduino Industrial 101](https://store.arduino.cc/usa/arduino-industrial-101)
221-
- [Arduino Yún](https://store.arduino.cc/usa/arduino-yun)
222-
223-
Other board notes:
224-
- [Arduino Due](https://www.arduino.cc/en/Main/ArduinoBoardDue) - NOT Supported - I have been told that the old Arduino IDE 1.6.5 (and below) version of this library (see [Add USB Game Controller to Arduino Leonardo or Micro](http://mheironimus.blogspot.com/2015/03/add-usb-game-controller-to-arduino.html))
225-
works with the Arduino Due. I have also been told Version 1.x of the the Arduino Joystick Library will work with the Arduino Duo. However, Version 2.x of the Arduino Joystick Library does not work with Arduino Due at this time.
226-
- [Arduino UNO](https://www.arduino.cc/en/Main/ArduinoBoardUno) - NOT Supported - However, it might work with the [NicoHood/HoodLoader2](https://github.com/NicoHood/HoodLoader2) library, but I have not had a chance to try this out yet.
227-
- [Arduino MEGA](https://www.arduino.cc/en/Main/ArduinoBoardMega2560) - NOT Supported - However, it might work with the [NicoHood/HoodLoader2](https://github.com/NicoHood/HoodLoader2) library, but I have not had a chance to try this out yet.
228-
229-
(as of 2017-09-02)
188+
See the [Wiki](https://github.com/MHeironimus/ArduinoJoystickLibrary/wiki) for more details on things like FAQ, supported boards, testing, etc.

0 commit comments

Comments
 (0)