Added boot protocol for mouse
This commit is contained in:
parent
f357dfc6c3
commit
a683e6eab1
3 changed files with 26 additions and 1 deletions
|
|
@ -33,8 +33,13 @@ THE SOFTWARE.
|
|||
#error "This is not an USB AVR or you use an old version of the IDE."
|
||||
#endif
|
||||
|
||||
//================================================================================
|
||||
// Settings
|
||||
//================================================================================
|
||||
|
||||
#define HID_KEYBOARD_LEDS_ENABLED
|
||||
#define USE_BOOT_KEYBOARD_PROTOCOL
|
||||
//#define USE_BOOT_MOUSE_PROTOCOL
|
||||
|
||||
//#define LAYOUT_US_ENGLISH
|
||||
//#define LAYOUT_CANADIAN_FRENCH
|
||||
|
|
@ -60,6 +65,10 @@ THE SOFTWARE.
|
|||
//#define LAYOUT_UNITED_KINGDOM
|
||||
//#define LAYOUT_US_INTERNATIONAL
|
||||
|
||||
//================================================================================
|
||||
// Definitions and Helpers
|
||||
//================================================================================
|
||||
|
||||
// Default US keyboard layout
|
||||
#if !defined(LAYOUT_CANADIAN_FRENCH) && !defined(LAYOUT_CANADIAN_MULTILINGUAL) \
|
||||
&& !defined(LAYOUT_DANISH) && !defined(LAYOUT_FINNISH) && !defined(LAYOUT_FRENCH) \
|
||||
|
|
@ -107,6 +116,11 @@ THE SOFTWARE.
|
|||
#define HID_REPORTID_TEENSY_KEYBOARD 9
|
||||
#endif
|
||||
|
||||
#if defined(USE_BOOT_KEYBOARD_PROTOCOL) && defined(USE_BOOT_MOUSE_PROTOCOL)
|
||||
// Technically it is possible but not within this (simpler) API.
|
||||
#error "You cannot use a boot compatible keyboard and mouse at the same time."
|
||||
#endif
|
||||
|
||||
#include "HID.h"
|
||||
|
||||
#include "HID-Tables.h"
|
||||
|
|
|
|||
|
|
@ -91,6 +91,15 @@ void Mouse_::move(signed char x, signed char y, signed char wheel)
|
|||
report.xAxis = x;
|
||||
report.yAxis = y;
|
||||
report.wheel = wheel;
|
||||
#if defined(USE_BOOT_MOUSE_PROTOCOL)
|
||||
if(getProtocol() != 1){
|
||||
// Do not send the wheel information.
|
||||
// It should be discarded by the host,
|
||||
// but to be sure we better leave it out.
|
||||
SendRawReport(&report, sizeof(report)-1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
SendReport(&report, sizeof(report));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ int HID_::HID_GetInterface(u8* interfaceNum)
|
|||
{
|
||||
#if defined(USE_BOOT_KEYBOARD_PROTOCOL)
|
||||
D_INTERFACE(HID_INTERFACE,1,3,1,1),
|
||||
#elif defined(USE_BOOT_MOUSE_PROTOCOL)
|
||||
D_INTERFACE(HID_INTERFACE,1,3,1,2),
|
||||
#else
|
||||
D_INTERFACE(HID_INTERFACE,1,3,0,0),
|
||||
#endif
|
||||
|
|
@ -102,7 +104,7 @@ void HID_::SendReport(u8 id, const void* data, int len)
|
|||
{
|
||||
// Only send report ID if it exists
|
||||
if(id){
|
||||
#if defined(USE_BOOT_KEYBOARD_PROTOCOL)
|
||||
#if defined(USE_BOOT_KEYBOARD_PROTOCOL) || defined(USE_BOOT_MOUSE_PROTOCOL)
|
||||
// Do not send a normal report while in Bootloader mode.
|
||||
if(_hid_protocol != 1){
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue