-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Overhaul USB HID for Leonardo and Micro #1803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d7b654b
Break out the size of a USB keyboard HID packet into a macro.
f27857d
A comment on an endif pointed to the wrong if
nospam2000 60e6c34
Use defines to identify the USB HID pages we support, instead of inte…
nospam2000 4388bed
Add support for the USB HID SystemControl page
nospam2000 fbcf948
Add support for waking up a host via USB HID.
nospam2000 1fd6284
Updates to the keyboard usage page for HID to extend the range of
nospam2000 387d55b
Add an inital pass at complete HID tables for Keyboard, ConsumerContr…
obra a520873
Addeed Mouse.moveAbs() to USB HID for absolute mouse positioning.
nospam2000 648d596
A first cut of USB "Consumer Control" support
obra 9a60186
Add USB HID keyboard press and release variants that work with USB HID
c5efe1e
Switch to less confusingly named HID keyboard character defines.
obra 6fd35f6
Add IDE keyword highlighting for new USB HID APIs
obra cc0cb95
Demo for the AbsoluteMouse API
obra 05e7173
Demo code for the ConsumerControl and SystemControl APIs
obra c86e83e
Enable Absolute Mouse support by default
obra d51ff08
Refactor the new rawKeycode API to be simpler and cleaner; add a
obra 3b535fc
Fixed a missing paren.
obra 282d9c2
Typo fix (and American spelling standardization.)
obra ed9a3f6
Switch absMouse to a coordinate system with an origin of 0,0 in the u…
obra 018545b
Remove mouse wheel support from moveAbs.
obra f0b5e7f
Update AbsoluteMouse example to the simplified API
obra 9ba38e7
Fix an off-by-8 error in the HID ConsumerControl driver that broke th…
obra 092dbd7
clean up and reorder the USB HID descriptors. No functional changes
obra 1b0b398
spell out moveAbsolute on the advice of David Mellis
obra b02e5aa
fix usb mouse report count
obra 9032971
beginnings of support for 5 button mice
obra ff04c13
extract the various HID report stanzas into preprocessor macros as pr…
obra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
build/shared/examples/09.USB/Keyboard/ConsumerAndSystemControl/ConsumerAndSystemControl.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* ConsumerAndSystemControl.ino | ||
|
||
Turns the computer's volume up, then turns it down. | ||
|
||
For ATmega32U4 based boards (like the Leonardo and Micro) | ||
|
||
* This code is an API demo for the USB HID ConsumerControl and | ||
SystemControl APIS. | ||
It does not require any circut external to your Arduino | ||
|
||
Created 12 Jan 2014 | ||
by Jesse Vincent <[email protected]> | ||
|
||
This sample code is in the public domain. | ||
*/ | ||
|
||
|
||
void setup() { | ||
Keyboard.begin(); | ||
|
||
// It can take a moment for the USB interface to be ready | ||
// after setup. Delay for a second so we don't lose the first | ||
// keypress. | ||
delay(1000); | ||
} | ||
|
||
void loop() { | ||
|
||
Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_UP); | ||
delay(1000); | ||
Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_DOWN); | ||
delay(1000); | ||
|
||
|
||
// Some other things the consumer control API can do: | ||
|
||
// Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_MUTE); | ||
// Keyboard.consumerControl(CONSUMER_CONTROL_PLAY_PAUSE); | ||
// Keyboard.consumerControl(CONSUMER_CONTROL_STOP); | ||
// Keyboard.consumerControl(CONSUMER_CONTROL_PREV_TRACK); | ||
// Keyboard.consumerControl(CONSUMER_CONTROL_NEXT_TRACK); | ||
|
||
|
||
// If you uncomment this code, the Arduino will try to put your | ||
// computer to sleep after waiting for 30 seconds. | ||
// delay(30000); Keyboard.systemControl(SYSTEM_CONTROL_SLEEP); | ||
|
||
// For a complete list, of the currently supported ConsumerControl | ||
// and SystemControl usages, look in cores/arduino/USBAPI.h | ||
|
||
} | ||
|
||
|
||
|
34 changes: 34 additions & 0 deletions
34
build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* AbsoluteMouse.ino | ||
|
||
For ATmega32U4 based boards (like the Leonardo and Micro) | ||
|
||
* This code is an API demo for the USB HID Absolute Mouse positioning API. | ||
It does not require any circut external to your Arduino | ||
|
||
Created 12 Jan 2014 | ||
by Jesse Vincent <[email protected]> | ||
|
||
This sample code is in the public domain. | ||
*/ | ||
|
||
|
||
void setup() { | ||
Mouse.begin(); | ||
} | ||
|
||
void loop() { | ||
|
||
Mouse.moveAbsolute(16384,16384); // Jump to the center of the screen | ||
delay(2500); | ||
Mouse.moveAbsolute(0, 0); // X position, Y position | ||
delay(2500); | ||
Mouse.moveAbsolute(0, 32767); | ||
delay(2500); | ||
Mouse.moveAbsolute(32767, 32767); | ||
delay(2500); | ||
Mouse.moveAbsolute(32767,0); | ||
delay(2500); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things i want to mention here:
I would not integrate the consumer into the Keyboard API since it uses different APIs.
And another fix i suggest is to clear the reports on a begin() and end(). This conflicts with integrating all together in Keyboard.
A System Wakeup example would be nice to simply test the wakeup. I'd use the USBDevice.wakeupHost(); and maybe integrate it in the system control as well. I will work on that myself and show you later.