2015-08-29 16:12:51 +00:00
|
|
|
/*
|
2015-09-06 17:51:30 +00:00
|
|
|
Copyright (c) 2014-2015 NicoHood
|
|
|
|
|
See the readme for credit to other people.
|
2015-08-29 16:12:51 +00:00
|
|
|
|
2015-09-06 17:51:30 +00:00
|
|
|
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:
|
2015-08-29 16:12:51 +00:00
|
|
|
|
2015-09-06 17:51:30 +00:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
2015-08-29 16:12:51 +00:00
|
|
|
|
2015-09-06 17:51:30 +00:00
|
|
|
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.
|
2015-08-29 16:12:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2015-09-08 15:50:01 +00:00
|
|
|
#pragma once
|
2015-08-29 16:12:51 +00:00
|
|
|
|
|
|
|
|
#include "HID.h"
|
|
|
|
|
|
|
|
|
|
#if !defined(_USING_HID)
|
|
|
|
|
|
|
|
|
|
#warning "Using legacy HID core (non pluggable)"
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
//================================================================================
|
|
|
|
|
//================================================================================
|
|
|
|
|
// Keyboard
|
|
|
|
|
|
2015-09-08 15:31:29 +00:00
|
|
|
#include "HID-Project.h"
|
2015-09-08 15:50:01 +00:00
|
|
|
#include "ImprovedKeylayouts.h"
|
2015-08-29 16:12:51 +00:00
|
|
|
|
|
|
|
|
// Low level key report: up to 6 keys and shift, ctrl etc at once
|
2015-09-08 16:10:32 +00:00
|
|
|
typedef union{
|
|
|
|
|
// Low level key report: up to 6 keys and shift, ctrl etc at once
|
|
|
|
|
uint8_t whole8[];
|
|
|
|
|
uint16_t whole16[];
|
|
|
|
|
uint32_t whole32[];
|
|
|
|
|
struct{
|
|
|
|
|
uint8_t modifiers;
|
|
|
|
|
uint8_t reserved;
|
|
|
|
|
uint8_t keys[6];
|
|
|
|
|
};
|
|
|
|
|
} HID_KeyboardReport_Data_t;
|
2015-08-29 16:12:51 +00:00
|
|
|
|
|
|
|
|
class Keyboard_ : public Print
|
|
|
|
|
{
|
|
|
|
|
private:
|
2015-09-08 16:10:32 +00:00
|
|
|
HID_KeyboardReport_Data_t _keyReport;
|
|
|
|
|
void sendReport(HID_KeyboardReport_Data_t* keys);
|
2015-08-29 16:12:51 +00:00
|
|
|
public:
|
|
|
|
|
Keyboard_(void);
|
|
|
|
|
void begin(void);
|
|
|
|
|
void end(void);
|
|
|
|
|
size_t write(uint8_t k);
|
|
|
|
|
size_t press(uint8_t k);
|
|
|
|
|
size_t release(uint8_t k);
|
|
|
|
|
void releaseAll(void);
|
2015-08-30 17:06:56 +00:00
|
|
|
|
2015-09-08 16:10:32 +00:00
|
|
|
size_t writeKeycode(uint8_t k);
|
|
|
|
|
size_t pressKeycode(uint8_t k);
|
|
|
|
|
size_t releaseKeycode(uint8_t k);
|
|
|
|
|
size_t addKeycodeToReport(uint8_t k);
|
|
|
|
|
size_t removeKeycodeFromReport(uint8_t k);
|
2015-08-29 16:12:51 +00:00
|
|
|
};
|
|
|
|
|
extern Keyboard_ Keyboard;
|
|
|
|
|
|
|
|
|
|
#endif
|