-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'keyboardiohid/master' into f/merge-keyb…
…oardio-hid Merge KeyboardioHID into the Kaleidoscope monorepo as a plugin with full history.
- Loading branch information
Showing
51 changed files
with
4,520 additions
and
0 deletions.
There are no files selected for viewing
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,7 @@ | ||
style=google | ||
unpad-paren | ||
pad-header | ||
pad-oper | ||
indent-classes | ||
indent=spaces=2 | ||
max-continuation-indent=80 |
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,3 @@ | ||
*~ | ||
.#* | ||
.*swp* |
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,18 @@ | ||
language: c | ||
before_install: | ||
- pushd .. | ||
- wget http://downloads.arduino.cc/arduino-1.6.7-linux64.tar.xz | ||
- tar xf arduino-1.6.7-linux64.tar.xz | ||
- popd | ||
script: | ||
- git clone https://github.com/keyboardio/Arduino-HID ../HID | ||
- make smoke ARDUINO_PATH=../arduino-1.6.7 ARDUINO_LOCAL_LIB_PATH=.. | ||
|
||
notifications: | ||
email: | ||
on_success: change | ||
on_failure: change | ||
slack: | ||
secure: geVAHVhYQ5bY7ja5vx1Tgxc5y64WLuXVEWKmw4LqiThFYCjtpdWkHGiZJfhUwkVI11u5w8w1FUmrB7ZP4EUGoXhCK/z1mvVMVJ9+fS+WoaqcTHFJi0hGbvXaFPD7QA+ef7TLrFcU643kf6KHN/P+dVVndLyhctXZqOZHHwXmKZNMt8qM5Gh5h41HOi0YjT9yFafSU0qf5jphF5qvjlxKsVJF+WxtMSU4xMYxzq7rf80bPi2pu4ijgqR5+Haaa71DJ1V2TA4wZ+BFTBo2YUJIGZ8qDlqmb7RdF/u72G/8HbT/Hzj55blrpBXU/BPkokGOPJlIGHPV76ESpJI0ZUILRifmkZY6ylMjl/hutDYPNjhMq8Z/UKSLN6pJQAq0PjqAoHCtPsXTbRMT0lhVt2itkCPwAXVgszTrE6INsNylY/soaDu66Sjmz2zQH8sC6hbL8SrZ0xGs1Q+e3q5WMETPIAS9f4n2YCxkIz4ORoL9IrOXUcebVNriiWKzOBt6bleWPJlGc6yVYkkUhvURH+jEp6v2Y5SqsaJVTD3I5Gq/H/0PJBtPdzu470yQ3/FD4g6M0AmWx8DCuvl1O295QOZbUtujpIowTm7PynFrAgW3ptSidjzWjzZaHc0iQJBiNi86dg3GomoEEOPzx8hnX7fhFgsR+Ixqfzx0srrQYqleQGY= | ||
cache: | ||
ccache: true |
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,50 @@ | ||
# Developer Certificate of Origin | ||
|
||
All contributions must include acceptance of the DCO: | ||
|
||
``` | ||
Developer Certificate of Origin | ||
Version 1.1 | ||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. | ||
1 Letterman Drive | ||
Suite D4700 | ||
San Francisco, CA, 94129 | ||
Everyone is permitted to copy and distribute verbatim copies of this | ||
license document, but changing it is not allowed. | ||
Developer's Certificate of Origin 1.1 | ||
By making a contribution to this project, I certify that: | ||
(a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
(b) The contribution is based upon previous work that, to the best | ||
of my knowledge, is covered under an appropriate open source | ||
license and I have the right under that license to submit that | ||
work with modifications, whether created in whole or in part | ||
by me, under the same open source license (unless I am | ||
permitted to submit under a different license), as indicated | ||
in the file; or | ||
(c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
(d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including all | ||
personal information I submit with it, including my sign-off) is | ||
maintained indefinitely and may be redistributed consistent with | ||
this project or the open source license(s) involved. | ||
``` | ||
|
||
## Sign your work | ||
|
||
To accept the DCO, please add this line to each commit message with your name | ||
and email address (`git commit -s` will do this for you): | ||
|
||
Signed-off-by: Jane Example <[email protected]> |
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,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2015 NicoHood | ||
Copyright (c) 2015-2018 Keyboard.io, Inc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,39 @@ | ||
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile | ||
|
||
#BOARD_TAG = keyboardio | ||
BOARD = model01 | ||
MCU = atmega32u4 | ||
|
||
ARDUINO_LIBS = | ||
|
||
ARDUINO_PATH ?= /Applications/Arduino.app/Contents/Java/ | ||
ARDUINO_TOOLS_PATH=$(ARDUINO_PATH)/hardware/tools | ||
FQBN=arduino:avr:leonardo | ||
BUILD_PATH := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'build') | ||
ARDUINO_LOCAL_LIB_PATH=~/Documents/Arduino/libraries | ||
ARDUINO_IDE_VERSION=100607 | ||
VERBOSE := #-verbose | ||
|
||
EXAMPLES=$(shell find ./examples -type f -name \*.ino ) | ||
EXAMPLES_HEX := $(addsuffix .hex,${EXAMPLES}) | ||
|
||
|
||
astyle: | ||
astyle --project --recursive "src/*.cpp,*.h,*.ino" | ||
|
||
smoke: ${EXAMPLES_HEX} | ||
|
||
${EXAMPLES_HEX}: %.hex: | ||
|
||
$(ARDUINO_PATH)/arduino-builder \ | ||
-hardware $(ARDUINO_PATH)/hardware \ | ||
-tools $(ARDUINO_TOOLS_PATH) \ | ||
-tools $(ARDUINO_PATH)/tools-builder \ | ||
-fqbn $(FQBN) \ | ||
-libraries $(ARDUINO_PATH)/libraries \ | ||
-libraries $(ARDUINO_LOCAL_LIB_PATH) \ | ||
$(VERBOSE) \ | ||
-build-path $(BUILD_PATH) \ | ||
-ide-version $(ARDUINO_IDE_VERSION) \ | ||
$* | ||
$(ARDUINO_TOOLS_PATH)/avr/bin/avr-size -C --mcu=$(MCU) $(BUILD_PATH)/$(shell basename $*).elf |
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,16 @@ | ||
Keyboardio USB HID Driver | ||
========================= | ||
|
||
Based on Nico Hood's HID-Project. Please don't contact Nico with issues in this library. | ||
|
||
|
||
|
||
**Supported HID devices:** | ||
* Boot Keyboard | ||
* NKRO Keyboard (press up to 113 keys at the same time) | ||
* Mouse (5 buttons, move, vertical wheel, horizontal wheel) | ||
* Absolute Mouse | ||
* Consumer/Media Keys (4 keys for music player, web browser and more) | ||
* System Key (for PC standby/shutdown) | ||
* Gamepad (32 buttons, 4 16bit axis, 2 8bit axis, 2 D-Pads) | ||
|
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,3 @@ | ||
To expand the macros in a c++ source file on OSX: | ||
|
||
gcc -D __AVR_ATmega32U4__ -DF_CPU=16000000L -O -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/ -I /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/leonardo -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/HID/ -I. -E $FILE |
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,36 @@ | ||
/* | ||
Copyright (c) 2014-2015 NicoHood | ||
See the readme for credit to other people. | ||
Consumer example | ||
Press a button to play/pause music player | ||
See HID Project documentation for more Consumer keys. | ||
https://github.com/NicoHood/HID/wiki/Consumer-API | ||
*/ | ||
|
||
#include "KeyboardioHID.h" | ||
|
||
const int pinLed = LED_BUILTIN; | ||
const int pinButton = 2; | ||
|
||
void setup() { | ||
pinMode(pinLed, OUTPUT); | ||
pinMode(pinButton, INPUT_PULLUP); | ||
|
||
// Sends a clean report to the host. This is important on any Arduino type. | ||
ConsumerControl.begin(); | ||
} | ||
|
||
void loop() { | ||
if (!digitalRead(pinButton)) { | ||
digitalWrite(pinLed, HIGH); | ||
|
||
// See HID Project documentation for more Consumer keys | ||
ConsumerControl.write(HID_CONSUMER_PLAY_SLASH_PAUSE); | ||
|
||
// Simple debounce | ||
delay(300); | ||
digitalWrite(pinLed, LOW); | ||
} | ||
} |
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,65 @@ | ||
/* | ||
Copyright (c) 2014-2015 NicoHood | ||
See the readme for credit to other people. | ||
Gamepad example | ||
Press a button and demonstrate Gamepad actions | ||
You can also use Gamepad1,2,3 and 4 as single report. | ||
This will use 1 endpoint for each gamepad. | ||
See HID Project documentation for more infos | ||
https://github.com/NicoHood/HID/wiki/Gamepad-API | ||
*/ | ||
|
||
#include "KeyboardioHID.h" | ||
|
||
const int pinLed = LED_BUILTIN; | ||
const int pinButton = 2; | ||
|
||
void setup() { | ||
pinMode(pinLed, OUTPUT); | ||
pinMode(pinButton, INPUT_PULLUP); | ||
|
||
// Sends a clean report to the host. This is important on any Arduino type. | ||
Gamepad.begin(); | ||
} | ||
|
||
void loop() { | ||
if (!digitalRead(pinButton)) { | ||
digitalWrite(pinLed, HIGH); | ||
|
||
// Press button 1-32 | ||
static uint8_t count = 0; | ||
count++; | ||
if (count == 33) { | ||
Gamepad.releaseAll(); | ||
count = 0; | ||
} else | ||
Gamepad.press(count); | ||
|
||
// Move x/y Axis to a new position (16bit) | ||
Gamepad.xAxis(random(0xFFFF)); | ||
Gamepad.yAxis(random(0xFFFF)); | ||
|
||
// Go through all dPad positions | ||
// values: 0-8 (0==centered) | ||
static uint8_t dpad1 = GAMEPAD_DPAD_CENTERED; | ||
Gamepad.dPad1(dpad1++); | ||
if (dpad1 > GAMEPAD_DPAD_UP_LEFT) | ||
dpad1 = GAMEPAD_DPAD_CENTERED; | ||
|
||
static int8_t dpad2 = GAMEPAD_DPAD_CENTERED; | ||
Gamepad.dPad2(dpad2--); | ||
if (dpad2 < GAMEPAD_DPAD_CENTERED) | ||
dpad2 = GAMEPAD_DPAD_UP_LEFT; | ||
|
||
// Functions above only set the values. | ||
// This writes the report to the host. | ||
Gamepad.write(); | ||
|
||
// Simple debounce | ||
delay(300); | ||
digitalWrite(pinLed, LOW); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
plugins/KeyboardioHID/examples/Keyboard/BootKeyboard/BootKeyboard.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,46 @@ | ||
/* | ||
Copyright (c) 2014-2015 NicoHood | ||
See the readme for credit to other people. | ||
BootKeyboard example | ||
Shows that keyboard works even in bios. | ||
Led indicats if we are in bios. | ||
See HID Project documentation for more information. | ||
https://github.com/NicoHood/HID/wiki/Keyboard-API#boot-keyboard | ||
*/ | ||
|
||
#include "KeyboardioHID.h" | ||
|
||
const int pinLed = LED_BUILTIN; | ||
const int pinButton = 2; | ||
|
||
void setup() { | ||
pinMode(pinLed, OUTPUT); | ||
pinMode(pinButton, INPUT_PULLUP); | ||
|
||
// Sends a clean report to the host. This is important on any Arduino type. | ||
BootKeyboard.begin(); | ||
} | ||
|
||
|
||
void loop() { | ||
// Light led if keyboard uses the boot protocol (normally while in bios) | ||
// Keep in mind that on a 16u2 and Arduino Micro HIGH and LOW for TX/RX Leds are inverted. | ||
if (BootKeyboard.getProtocol() == HID_BOOT_PROTOCOL) | ||
digitalWrite(pinLed, HIGH); | ||
else | ||
digitalWrite(pinLed, LOW); | ||
|
||
// Trigger caps lock manually via button | ||
if (!digitalRead(pinButton)) { | ||
BootKeyboard.press(HID_KEYBOARD_ENTER); | ||
BootKeyboard.sendReport(); | ||
BootKeyboard.releaseAll(); | ||
BootKeyboard.sendReport(); | ||
|
||
// Simple debounce | ||
delay(300); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
plugins/KeyboardioHID/examples/Keyboard/KeyboardLed/KeyboardLed.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,47 @@ | ||
/* | ||
Copyright (c) 2014-2015 NicoHood | ||
See the readme for credit to other people. | ||
KeyboardLed example | ||
Press a button to toogle caps lock. | ||
Caps lock state is represented by the onboard led. | ||
Leds are only supported on single report HID devices. | ||
See HID Project documentation for more information. | ||
https://github.com/NicoHood/HID/wiki/Keyboard-API | ||
*/ | ||
|
||
#include "KeyboardioHID.h" | ||
|
||
const int pinLed = LED_BUILTIN; | ||
const int pinButton = 2; | ||
|
||
void setup() { | ||
pinMode(pinLed, OUTPUT); | ||
pinMode(pinButton, INPUT_PULLUP); | ||
|
||
// Sends a clean report to the host. This is important on any Arduino type. | ||
BootKeyboard.begin(); | ||
} | ||
|
||
|
||
void loop() { | ||
// Update Led equal to the caps lock state. | ||
// Keep in mind that on a 16u2 and Arduino Micro HIGH and LOW for TX/RX Leds are inverted. | ||
if (BootKeyboard.getLeds() & LED_CAPS_LOCK) | ||
digitalWrite(pinLed, HIGH); | ||
else | ||
digitalWrite(pinLed, LOW); | ||
|
||
// Trigger caps lock manually via button | ||
if (!digitalRead(pinButton)) { | ||
BootKeyboard.press(HID_KEYBOARD_CAPS_LOCK); | ||
BootKeyboard.sendReport(); | ||
BootKeyboard.releaseAll(); | ||
BootKeyboard.sendReport(); | ||
|
||
// Simple debounce | ||
delay(300); | ||
} | ||
} |
Oops, something went wrong.