Unicode: Add a way to slow it all down

In certain cases we need to delay the unicode input sequence, otherwise the host
is unable to process the input properly. Introduce the `.input_delay()`
setter/getter for this purpose. We're defaulting to zero (no delay) nevertheless.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/451/head
Gergely Nagy 6 years ago
parent 28a589be03
commit cbbc8418da
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -67,6 +67,14 @@ functionality.
> Finishes the Unicode input method, in an OS-specific way. > Finishes the Unicode input method, in an OS-specific way.
### `.input_delay([delay])`
> Sets or returns (if called without an argument) the number of milliseconds to
> wait between inputting each part of the sequence. In some cases, inputting too
> fast does not give the host enough time to process, and a delay is needed.
>
> Defaults to zero, no delay.
## Overrideable methods ## Overrideable methods
### `hexToKey(hex_digit)` ### `hexToKey(hex_digit)`

@ -21,6 +21,8 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
uint8_t Unicode::input_delay_;
void Unicode::start(void) { void Unicode::start(void) {
switch (::HostOS.os()) { switch (::HostOS.os()) {
case hostos::LINUX: case hostos::LINUX:
@ -62,6 +64,7 @@ void Unicode::input(void) {
unicodeCustomInput(); unicodeCustomInput();
break; break;
} }
delay(input_delay_);
} }
void Unicode::end(void) { void Unicode::end(void) {

@ -32,6 +32,15 @@ class Unicode : public kaleidoscope::Plugin {
static void type(uint32_t unicode); static void type(uint32_t unicode);
static void typeCode(uint32_t unicode); static void typeCode(uint32_t unicode);
static void input_delay(uint8_t delay) {
input_delay_ = delay;
}
static uint8_t input_delay() {
return input_delay_;
}
private:
static uint8_t input_delay_;
}; };
} }
} }

Loading…
Cancel
Save