Skip to content
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

Overhaul USB HID for Leonardo and Micro #1803

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
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.
Jan 8, 2014
f27857d
A comment on an endif pointed to the wrong if
nospam2000 Jan 8, 2014
60e6c34
Use defines to identify the USB HID pages we support, instead of inte…
nospam2000 Jan 8, 2014
4388bed
Add support for the USB HID SystemControl page
nospam2000 Jan 8, 2014
fbcf948
Add support for waking up a host via USB HID.
nospam2000 Jan 8, 2014
1fd6284
Updates to the keyboard usage page for HID to extend the range of
nospam2000 Jan 8, 2014
387d55b
Add an inital pass at complete HID tables for Keyboard, ConsumerContr…
obra Jan 9, 2014
a520873
Addeed Mouse.moveAbs() to USB HID for absolute mouse positioning.
nospam2000 Jan 11, 2014
648d596
A first cut of USB "Consumer Control" support
obra Jan 11, 2014
9a60186
Add USB HID keyboard press and release variants that work with USB HID
Jan 12, 2014
c5efe1e
Switch to less confusingly named HID keyboard character defines.
obra Dec 1, 2014
6fd35f6
Add IDE keyword highlighting for new USB HID APIs
obra Jan 12, 2014
cc0cb95
Demo for the AbsoluteMouse API
obra Jan 12, 2014
05e7173
Demo code for the ConsumerControl and SystemControl APIs
obra Jan 13, 2014
c86e83e
Enable Absolute Mouse support by default
obra Jan 13, 2014
d51ff08
Refactor the new rawKeycode API to be simpler and cleaner; add a
obra Jan 13, 2014
3b535fc
Fixed a missing paren.
obra Jan 13, 2014
282d9c2
Typo fix (and American spelling standardization.)
obra Jan 13, 2014
ed9a3f6
Switch absMouse to a coordinate system with an origin of 0,0 in the u…
obra Jan 19, 2014
018545b
Remove mouse wheel support from moveAbs.
obra Jan 19, 2014
f0b5e7f
Update AbsoluteMouse example to the simplified API
obra Jan 20, 2014
9ba38e7
Fix an off-by-8 error in the HID ConsumerControl driver that broke th…
obra Feb 2, 2014
092dbd7
clean up and reorder the USB HID descriptors. No functional changes
obra Feb 2, 2014
1b0b398
spell out moveAbsolute on the advice of David Mellis
obra Feb 10, 2014
b02e5aa
fix usb mouse report count
obra Feb 28, 2014
9032971
beginnings of support for 5 button mice
obra Feb 28, 2014
ff04c13
extract the various HID report stanzas into preprocessor macros as pr…
obra Mar 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <jesse@keyboard.io>

This sample code is in the public domain.
*/


void setup() {
Keyboard.begin();

Copy link
Contributor

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.

// 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 build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino
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 <jesse@keyboard.io>

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);
}



6 changes: 6 additions & 0 deletions build/shared/lib/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,17 @@ Keyboard KEYWORD3
Mouse KEYWORD3
press KEYWORD2
release KEYWORD2
pressKeycode KEYWORD2
releaseKeycode KEYWORD2
releaseAll KEYWORD2
accept KEYWORD2
click KEYWORD2
move KEYWORD2
moveAbsolute KEYWORD2
write KEYWORD2
isPressed KEYWORD2
systemControl KEYWORD2
consumerControl KEYWORD2

setup KEYWORD3 Setup
loop KEYWORD3 Loop
Loading