Merge remote-tracking branch 'plugin/USB-Quirks/f/monorepo' into f/monorepo

pull/365/head
Gergely Nagy 6 years ago
commit 18f74f0a28
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -0,0 +1,39 @@
# Kaleidoscope-USB-Quirks
USB-Quirks provides a few methods to deal with more obscure parts of the USB spec, such as changing between `Boot` and `Report` protocols. These are in a separate plugin, because these features are not part of the USB spec, and are often workarounds for various issues. See the provided methods for more information about what they're useful for.
## Using the plugin
```c++
#include <Kaleidoscope.h>
#include <Kaleidoscope-Macros.h>
#include <Kaleidoscope-USB-Quirks.h>
KALEIDOSCOPE_INIT_PLUGINS(USBQuirks, Macros);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == 0) {
USBQuirks.toggleKeyboardProtocol();
}
return MACRO_NONE;
}
void setup() {
Kaleidoscope.setup();
}
```
## Plugin methods
The plugin provides one object, `USBQuirks`, which provides the following method:
### `.toggleKeyboardProtocol()`
> Toggle between `Boot` and `Report` protocol by detaching, and then
> re-attaching the USB devices, and setting the `BootKeyboard` protocol
> inbetween.
>
> This is most useful when one needs to have a boot keyboard, when one's in a
> BIOS, boot loader, or early password prompt or the like, and the host does not
> explicitly request the boot protocol for one reason or the other. With this
> toggle, we can switch between the two on-demand.

@ -0,0 +1,21 @@
/* -*- mode: c++ -*-
* Kaleidoscope-USB-Quirks -- USB Quirks for Kaleidoscope
* Copyright (C) 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <kaleidoscope/plugin/USB-Quirks.h>

@ -0,0 +1,41 @@
/* -*- mode: c++ -*-
* Kaleidoscope-USB-Quirks -- USB Quirks for Kaleidoscope
* Copyright (C) 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope-USB-Quirks.h>
namespace kaleidoscope {
namespace plugin {
void USBQuirks::toggleKeyboardProtocol() {
#if KALEIDOSCOPE_HIDADAPTOR_ENABLE_KEYBOARD_BOOT_PROTOCOL
uint8_t new_protocol = !BootKeyboard.getProtocol();
Kaleidoscope.detachFromHost();
BootKeyboard.default_protocol = new_protocol;
BootKeyboard.setProtocol(new_protocol);
delay(1000);
Kaleidoscope.attachToHost();
#endif
}
}
}
kaleidoscope::plugin::USBQuirks USBQuirks;

@ -0,0 +1,34 @@
/* -*- mode: c++ -*-
* Kaleidoscope-USB-Quirks -- USB Quirks for Kaleidoscope
* Copyright (C) 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Kaleidoscope.h>
namespace kaleidoscope {
namespace plugin {
class USBQuirks: public kaleidoscope::Plugin {
public:
USBQuirks() {}
void toggleKeyboardProtocol();
};
}
}
extern kaleidoscope::plugin::USBQuirks USBQuirks;
Loading…
Cancel
Save