From 86b5e9be59713b2be2b3e8696999353998049724 Mon Sep 17 00:00:00 2001 From: Toby Miller Date: Sun, 18 Feb 2018 11:44:25 +0000 Subject: [PATCH 1/3] change windows hex mapping --- src/Kaleidoscope/Unicode.cpp | 58 ++++++++++++++++++++++++++++++------ src/Kaleidoscope/Unicode.h | 1 + 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/Kaleidoscope/Unicode.cpp b/src/Kaleidoscope/Unicode.cpp index d53f90f9..59cf1292 100644 --- a/src/Kaleidoscope/Unicode.cpp +++ b/src/Kaleidoscope/Unicode.cpp @@ -41,13 +41,11 @@ void Unicode::start(void) { hid::sendKeyboardReport(); break; case hostos::WINDOWS: - hid::pressRawKey(Key_RightAlt); + hid::pressRawKey(Key_LeftAlt); hid::sendKeyboardReport(); - hid::releaseRawKey(Key_RightAlt); + hid::pressRawKey(Key_KeypadAdd); hid::sendKeyboardReport(); - hid::pressRawKey(Key_U); - hid::sendKeyboardReport(); - hid::releaseRawKey(Key_U); + hid::releaseRawKey(Key_KeypadAdd); hid::sendKeyboardReport(); break; case hostos::OSX: @@ -63,7 +61,6 @@ void Unicode::input(void) { switch (::HostOS.os()) { case hostos::LINUX: case hostos::WINDOWS: - break; case hostos::OSX: hid::pressRawKey(Key_LeftAlt); break; @@ -82,7 +79,6 @@ void Unicode::end(void) { hid::sendKeyboardReport(); break; case hostos::WINDOWS: - break; case hostos::OSX: hid::releaseRawKey(Key_LeftAlt); hid::sendKeyboardReport(); @@ -102,7 +98,13 @@ void Unicode::typeCode(uint32_t unicode) { uint8_t digit = ((unicode >> (i * 4)) & 0xF); if (digit == 0) { if (on_zero_start == false) { - Key key = hexToKey(digit); + Key key; + if (::HostOS.os() == hostos::WINDOWS) { + key = hexToKeyWindows(digit); + } + else { + key = hexToKey(digit); + } input(); hid::pressRawKey(key); hid::sendKeyboardReport(); @@ -111,7 +113,13 @@ void Unicode::typeCode(uint32_t unicode) { hid::sendKeyboardReport(); } } else { - Key key = hexToKey(digit); + Key key; + if (::HostOS.os() == hostos::WINDOWS) { + key = hexToKeyWindows(digit); + } + else { + key = hexToKey(digit); + } input(); hid::pressRawKey(key); hid::sendKeyboardReport(); @@ -145,6 +153,38 @@ __attribute__((weak)) Key hexToKey(uint8_t hex) { return { m, KEY_FLAGS }; } +__attribute__((weak)) Key hexToKeyWindows(uint8_t hex) { + uint8_t m; + if (hex == 0x0) { + return Key_Keypad0; + } + if (hex < 0xA) { + m = Key_Keypad1.keyCode + (hex - 0x1); + } else { + switch (hex) { + case 0xA: + m = Key_A.keyCode; + break; + case 0xB: + m = Key_B.keyCode; + break; + case 0xC: + m = Key_C.keyCode; + break; + case 0xD: + m = Key_D.keyCode; + break; + case 0xE: + m = Key_E.keyCode; + break; + case 0xF: + m = Key_F.keyCode; + break; + } + } + return { m, KEY_FLAGS }; +} + __attribute__((weak)) void unicodeCustomStart(void) { } diff --git a/src/Kaleidoscope/Unicode.h b/src/Kaleidoscope/Unicode.h index 21487cd6..14fc5086 100644 --- a/src/Kaleidoscope/Unicode.h +++ b/src/Kaleidoscope/Unicode.h @@ -38,6 +38,7 @@ class Unicode : public KaleidoscopePlugin { } Key hexToKey(uint8_t hex); +Key hexToKeyWindows(uint8_t hex); void unicodeCustomStart(void); void unicodeCustomEnd(void); From 890f17974690ca9e631e0497b171a5997810065e Mon Sep 17 00:00:00 2001 From: tobymiller1 Date: Mon, 19 Feb 2018 19:24:28 +0000 Subject: [PATCH 2/3] changes requested --- src/Kaleidoscope/Unicode.cpp | 7 ++++--- src/Kaleidoscope/Unicode.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Kaleidoscope/Unicode.cpp b/src/Kaleidoscope/Unicode.cpp index 59cf1292..17f0100f 100644 --- a/src/Kaleidoscope/Unicode.cpp +++ b/src/Kaleidoscope/Unicode.cpp @@ -60,6 +60,7 @@ void Unicode::start(void) { void Unicode::input(void) { switch (::HostOS.os()) { case hostos::LINUX: + break; case hostos::WINDOWS: case hostos::OSX: hid::pressRawKey(Key_LeftAlt); @@ -100,7 +101,7 @@ void Unicode::typeCode(uint32_t unicode) { if (on_zero_start == false) { Key key; if (::HostOS.os() == hostos::WINDOWS) { - key = hexToKeyWindows(digit); + key = hexToKeysWithNumpad(digit); } else { key = hexToKey(digit); @@ -115,7 +116,7 @@ void Unicode::typeCode(uint32_t unicode) { } else { Key key; if (::HostOS.os() == hostos::WINDOWS) { - key = hexToKeyWindows(digit); + key = hexToKeysWithNumpad(digit); } else { key = hexToKey(digit); @@ -153,7 +154,7 @@ __attribute__((weak)) Key hexToKey(uint8_t hex) { return { m, KEY_FLAGS }; } -__attribute__((weak)) Key hexToKeyWindows(uint8_t hex) { +__attribute__((weak)) Key hexToKeysWithNumpad(uint8_t hex) { uint8_t m; if (hex == 0x0) { return Key_Keypad0; diff --git a/src/Kaleidoscope/Unicode.h b/src/Kaleidoscope/Unicode.h index 14fc5086..293fe7a7 100644 --- a/src/Kaleidoscope/Unicode.h +++ b/src/Kaleidoscope/Unicode.h @@ -38,7 +38,7 @@ class Unicode : public KaleidoscopePlugin { } Key hexToKey(uint8_t hex); -Key hexToKeyWindows(uint8_t hex); +Key hexToKeysWithNumpad(uint8_t hex); void unicodeCustomStart(void); void unicodeCustomEnd(void); From e369aa61e697bfe1184198dfca30c47e4b2f0e75 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 6 Mar 2018 08:56:32 +0100 Subject: [PATCH 3/3] make astyle Signed-off-by: Gergely Nagy --- src/Kaleidoscope/Unicode.cpp | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/Kaleidoscope/Unicode.cpp b/src/Kaleidoscope/Unicode.cpp index 17f0100f..81b723e4 100644 --- a/src/Kaleidoscope/Unicode.cpp +++ b/src/Kaleidoscope/Unicode.cpp @@ -102,8 +102,7 @@ void Unicode::typeCode(uint32_t unicode) { Key key; if (::HostOS.os() == hostos::WINDOWS) { key = hexToKeysWithNumpad(digit); - } - else { + } else { key = hexToKey(digit); } input(); @@ -117,8 +116,7 @@ void Unicode::typeCode(uint32_t unicode) { Key key; if (::HostOS.os() == hostos::WINDOWS) { key = hexToKeysWithNumpad(digit); - } - else { + } else { key = hexToKey(digit); } input(); @@ -163,24 +161,24 @@ __attribute__((weak)) Key hexToKeysWithNumpad(uint8_t hex) { m = Key_Keypad1.keyCode + (hex - 0x1); } else { switch (hex) { - case 0xA: - m = Key_A.keyCode; - break; - case 0xB: - m = Key_B.keyCode; - break; - case 0xC: - m = Key_C.keyCode; - break; - case 0xD: - m = Key_D.keyCode; - break; - case 0xE: - m = Key_E.keyCode; - break; - case 0xF: - m = Key_F.keyCode; - break; + case 0xA: + m = Key_A.keyCode; + break; + case 0xB: + m = Key_B.keyCode; + break; + case 0xC: + m = Key_C.keyCode; + break; + case 0xD: + m = Key_D.keyCode; + break; + case 0xE: + m = Key_E.keyCode; + break; + case 0xF: + m = Key_F.keyCode; + break; } } return { m, KEY_FLAGS };