Skip to content

Commit 28ea21b

Browse files
author
Florian Fleissner
committed
Implemented host_keymaps
host_keymaps enable defining keymaps in a natural fashion. Instead of using Key constants like Key_A or LSHIFT(Key_A) it allows to conveniently write "a" or "A". The mappings between ascii and unicode characters to USB-HID keys works by reverse engineering the host keymaps of a linux system. The information of the provided keymap files allows for precisely figuring out the Kaleidoscope-Key that is needed to generate a specific utf8 character in a given keymap. For non-unicode keycodes, the linux XKB-keysym name is mapped to a Kaleidoscope-Key. The newly introduced host_keymap system is easily extensible and allows users to define their own non-english keymaps, if necessary by extending an existing keymap. Signed-off-by: Florian Fleissner <[email protected]>
1 parent ca8be53 commit 28ea21b

File tree

643 files changed

+313556
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

643 files changed

+313556
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* -*- mode: c++ -*-
2+
* Kaleidoscope-Unicode -- Unicode input helpers
3+
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc
4+
*
5+
* This program is free software: you can redistribute it and/or modify it under
6+
* the terms of the GNU General Public License as published by the Free Software
7+
* Foundation, version 3.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12+
* details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with
15+
* this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include <Kaleidoscope.h>
19+
20+
#include "kaleidoscope/host_keymap/ascii/us_en.h"
21+
#include "kaleidoscope/host_keymap/unicode/us_en.h"
22+
23+
USE_HOST_KEYMAP(ascii, us_en)
24+
USE_HOST_KEYMAP(unicode, us_en)
25+
26+
// *INDENT-OFF*
27+
28+
KEYMAPS(
29+
[0] = KEYMAP_STACKED
30+
(
31+
XXX, "1", "2", "3", "4", "5", XXX,
32+
"`", "q", "w", "e", "r", "t", "\t",
33+
L"", "a", "s", "d", "f", "g",
34+
L"", "z", "x", "c", "v", "b", L"",
35+
36+
L"", L"", L"", L"",
37+
XXX,
38+
39+
XXX, "6", "7", "8", "9", "0", XXX,
40+
L"", "y", "u", "i", "o", "p", "=",
41+
"h", "j", "k", "l", ";", "\"",
42+
XXX, "n", "m", ",", ".", "/", "-",
43+
44+
L"r⇧", L"r⌥", L"", L"r⌃",
45+
XXX
46+
)
47+
)
48+
// *INDENT-ON*
49+
50+
//KALEIDOSCOPE_INIT_PLUGINS();
51+
52+
void setup() {
53+
Kaleidoscope.setup();
54+
}
55+
56+
void loop() {
57+
Kaleidoscope.loop();
58+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The linux keymaps were generated on an Ubuntu 19.04 system based on XKeyboardConfig 2.23.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* Kaleidoscope - Firmware for computer input devices
2+
* Copyright (C) 2013-2018 Keyboard.io, Inc.
3+
*
4+
* This program is free software: you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation, version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11+
* details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#pragma once
18+
19+
#include "kaleidoscope/host_keymap/host_keymap.h"
20+
21+
namespace kaleidoscope {
22+
namespace host_keymap {
23+
namespace ascii {
24+
25+
struct CharProcessor {
26+
static constexpr bool isEscapeChar(char c) {
27+
return c == '#';
28+
}
29+
30+
static constexpr bool isSeparator(char c) {
31+
return (c == ' ')
32+
|| (c == '\t')
33+
|| (c == '+');
34+
}
35+
36+
static constexpr bool isMirrorChar(char c) {
37+
return c == 'r';
38+
}
39+
};
40+
41+
#define _HOST_KEYMAP_CAST_ON_MODIFIERS_ASCII(OP) \
42+
OP('s', LSHIFT(k)) \
43+
OP('S', LSHIFT(k)) \
44+
OP('c', LCTRL(k)) \
45+
OP('C', LCTRL(k)) \
46+
OP('a', LALT(k)) \
47+
OP('A', RALT(k)) \
48+
OP('m', LGUI(k)) \
49+
OP('M', LGUI(k)) \
50+
OP('g', LGUI(k)) \
51+
OP('G', LGUI(k))
52+
53+
// Define a AsciiConverterBase template base class that any ascii keymap converters
54+
// are derived from by means of invoking the HOST_KEYMAP_ASCII_LANGUAGE_CONVERTER
55+
// function macro.
56+
//
57+
_HOST_KEYMAP_DEFINE_CHAR_CONVERTER(
58+
ConverterBase, char, _HOST_KEYMAP_CAST_ON_MODIFIERS_ASCII)
59+
60+
#undef _HOST_KEYMAP_CAST_ON_MODIFIERS_ASCII
61+
62+
typedef _CharParsingStandardFallback<char> CharParsingStandardFallback;
63+
64+
} // namespace ascii
65+
} // namespace host_keymap
66+
} // namespace kaleidoscope
67+
68+
#define HOST_KEYMAP_ASCII_CONVERTER(LANGUAGE_KEYMAP, CHAR_PARSING_FALLBACK) \
69+
struct AsciiConverter \
70+
: public ascii::ConverterBase<AsciiConverter, ascii::CharProcessor> \
71+
{ \
72+
typedef ascii::ConverterBase<AsciiConverter, ascii::CharProcessor> Parent; \
73+
\
74+
using typename Parent::StringMemberType; \
75+
using typename Parent::CharType; \
76+
\
77+
static constexpr bool isKeyChar(char c) { \
78+
return LANGUAGE_KEYMAP(_HOST_KEYMAP_IS_KEY_CHAR) \
79+
CHAR_PARSING_FALLBACK::isKeyChar(c); \
80+
} \
81+
\
82+
static constexpr Key charToKey(char c) { \
83+
return LANGUAGE_KEYMAP( \
84+
_HOST_KEYMAP_MAP_KEY_CHAR_TO_KALEIDOSCOPE_KEY \
85+
) \
86+
CHAR_PARSING_FALLBACK::charToKey(c); \
87+
} \
88+
}; \
89+
\
90+
constexpr Key convertToKey(char c) { \
91+
return AsciiConverter::convertToKey(c); \
92+
} \
93+
template<int _Size> \
94+
constexpr Key convertToKey(char const(&string) [_Size]) { \
95+
return AsciiConverter::convertToKey(string); \
96+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Kaleidoscope - Firmware for computer input devices
2+
* Copyright (C) 2013-2018 Keyboard.io, Inc.
3+
*
4+
* This program is free software: you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation, version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11+
* details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#pragma once
18+
19+
#include "kaleidoscope/host_keymap/ascii.h"
20+
#include "kaleidoscope/host_keymap/unicode.h"
21+
#include "kaleidoscope/host_keymap/non_printable.h"

0 commit comments

Comments
 (0)