Skip to content

Commit af290fc

Browse files
facchinmcmaglie
authored andcommitted
rework HID-based libraries and add Due fallback
1 parent 9981435 commit af290fc

File tree

15 files changed

+162
-17
lines changed

15 files changed

+162
-17
lines changed

Diff for: hardware/arduino/avr/libraries/HID/HID.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#if defined(USBCON)
2323

24-
//#define RAWHID_ENABLED
25-
2624
HID_ HID;
2725

2826
static u8 HID_ENDPOINT_INT;

Diff for: hardware/arduino/avr/libraries/HID/HID.h

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#if defined(USBCON)
2929

30+
#define _USING_HID
31+
3032
//================================================================================
3133
//================================================================================
3234
// HID 'Driver'

Diff for: hardware/arduino/avr/libraries/HID/keywords.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#######################################
2+
# Syntax Coloring Map HID
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
HID KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
begin KEYWORD2
15+
SendReport KEYWORD2
16+
AppendDescriptor KEYWORD2
17+
18+
#######################################
19+
# Constants (LITERAL1)
20+
#######################################
21+
HID_TX LITERAL1
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name=HID
2+
version=1.0
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=Module for PluggableUSB infrastructure. Exposes an API for devices like Keyboards, Mice and Gamepads
6+
paragraph=
7+
url=http://www.arduino.cc/en/Reference/HID
8+
architectures=avr

Diff for: hardware/arduino/sam/libraries/HID/HID.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// HID.h
2+
3+
// placeholder waiting for HID library to be DUE compatible

Diff for: libraries/Keyboard/README.adoc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Keyboard Library for Arduino =
2+
3+
This library allows an Arduino board with USB capabilites to act as a Keyboard.
4+
Being based on HID library you need to include "HID.h" in your sketch.
5+
6+
For more information about this library please visit us at
7+
http://www.arduino.cc/en/Reference/Keyboard
8+
9+
== License ==
10+
11+
Copyright (c) Arduino LLC. All right reserved.
12+
13+
This library is free software; you can redistribute it and/or
14+
modify it under the terms of the GNU Lesser General Public
15+
License as published by the Free Software Foundation; either
16+
version 2.1 of the License, or (at your option) any later version.
17+
18+
This library is distributed in the hope that it will be useful,
19+
but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21+
Lesser General Public License for more details.
22+
23+
You should have received a copy of the GNU Lesser General Public
24+
License along with this library; if not, write to the Free Software
25+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Diff for: libraries/Keyboard/keywords.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#######################################
2+
# Syntax Coloring Map For Keyboard
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
Keyboard KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
begin KEYWORD2
16+
write KEYWORD2
17+
press KEYWORD2
18+
release KEYWORD2
19+
releaseAll KEYWORD2
20+
21+
#######################################
22+
# Constants (LITERAL1)
23+
#######################################
24+

Diff for: libraries/Keyboard/library.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Keyboard
2+
version=1.0.0
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=Allows an Arduino board with USB capabilites to act as a Keyboard. For Leonardo/Micro only
6+
paragraph=This library plugs on the HID library. It can be used with or without other HID-based libraries (Mouse, Gamepad etc)
7+
category=USB
8+
url=http://www.arduino.cc/en/Reference/Keyboard
9+
architectures=*

Diff for: libraries/Keyboard/Keyboard.cpp renamed to libraries/Keyboard/src/Keyboard.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2020
*/
2121

22-
#if 1
23-
2422
#include "Keyboard.h"
2523

24+
#if defined(_USING_HID)
25+
2626
//================================================================================
2727
//================================================================================
2828
// Keyboard

Diff for: libraries/Keyboard/Keyboard.h renamed to libraries/Keyboard/src/Keyboard.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
#ifndef KEYBOARD_h
2323
#define KEYBOARD_h
2424

25-
#if 0 //defined(_USING_HID)
26-
27-
#error "Can only attach one submodule to HID module"
25+
#include "HID.h"
2826

29-
#else
27+
#if !defined(_USING_HID)
3028

31-
#define _USING_HID
29+
#warning "Using legacy HID core (non pluggable)"
3230

33-
#include "HID.h"
31+
#else
3432

3533
//================================================================================
3634
//================================================================================

Diff for: libraries/Mouse/README.adoc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Mouse Library for Arduino =
2+
3+
This library allows an Arduino board with USB capabilites to act as a Mouse.
4+
Being based on HID library you need to include "HID.h" in your sketch
5+
6+
For more information about this library please visit us at
7+
http://www.arduino.cc/en/Reference/Mouse
8+
9+
== License ==
10+
11+
Copyright (c) Arduino LLC. All right reserved.
12+
13+
This library is free software; you can redistribute it and/or
14+
modify it under the terms of the GNU Lesser General Public
15+
License as published by the Free Software Foundation; either
16+
version 2.1 of the License, or (at your option) any later version.
17+
18+
This library is distributed in the hope that it will be useful,
19+
but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21+
Lesser General Public License for more details.
22+
23+
You should have received a copy of the GNU Lesser General Public
24+
License along with this library; if not, write to the Free Software
25+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Diff for: libraries/Mouse/keywords.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#######################################
2+
# Syntax Coloring Map For Keyboard
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
Mouse KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
begin KEYWORD2
16+
click KEYWORD2
17+
move KEYWORD2
18+
press KEYWORD2
19+
release KEYWORD2
20+
isPressed KEYWORD2
21+
22+
#######################################
23+
# Constants (LITERAL1)
24+
#######################################

Diff for: libraries/Mouse/library.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Mouse
2+
version=1.0.0
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=Allows an Arduino board with USB capabilites to act as a Mouse. For Leonardo/Micro only
6+
paragraph=This library plugs on the HID library. Can be used with or without other HID-based libraries (Keyboard, Gamepad etc)
7+
category=USB
8+
url=http://www.arduino.cc/en/Reference/Mouse
9+
architectures=*

Diff for: libraries/Mouse/Mouse.cpp renamed to libraries/Mouse/src/Mouse.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2020
*/
2121

22-
#if 1 //defined(USBCON)
23-
2422
#include "Mouse.h"
2523

24+
#if defined(_USING_HID)
25+
2626
static const u8 _hidReportDescriptor[] PROGMEM = {
2727

2828
// Mouse

Diff for: libraries/Mouse/Mouse.h renamed to libraries/Mouse/src/Mouse.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
#ifndef MOUSE_h
2323
#define MOUSE_h
2424

25-
#if 0 //defined(_USING_HID)
25+
#include "HID.h"
2626

27-
#error "Can only attach one submodule to HID module"
27+
#if !defined(_USING_HID)
2828

29-
#else
29+
#warning "Using legacy HID core (non pluggable)"
3030

31-
#define _USING_HID
31+
#else
3232

33-
#include "HID.h"
3433
//================================================================================
3534
//================================================================================
3635
// Mouse

0 commit comments

Comments
 (0)