-
Notifications
You must be signed in to change notification settings - Fork 271
/
Copy pathHostKeymap.ino
123 lines (101 loc) · 3.93 KB
/
HostKeymap.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* -*- mode: c++ -*-
* Kaleidoscope-Unicode -- Unicode input helpers
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc
*
* 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, version 3.
*
* 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/>.
*/
// This example demonstrates how different host keymaps can conveniently be used
// in one firmware. The example assumes that the host system supports layout
// switching between US english standard layout and german standard layout.
//
// We define dedicated keymap layers for both host keymaps and define
// a key (defined as llg below) that locks the german keymap layer.
//
// Once the layers are changed on the keyboard, the host keymap must be
// changed as well for the changes to take effect.
#include <Kaleidoscope.h>
#include "kaleidoscope/host_keymap/linux/us/standard/keymap.h"
#include "kaleidoscope/host_keymap/linux/de/standard/keymap.h"
// Define the us standard keymap as default.
//
USE_HOST_KEYMAP(linux, us, standard)
// Note: All unicode character strings like e.g. L"⌫" or L"ß" require to
// be prefixed with an L to make C++ store them as wide characters.
enum Layers {
US,
German
};
// *INDENT-OFF*
constexpr Key llg = LockLayer(German);
START_KEYMAPS
[US] = KEYMAP_STACKED
(
XXX, "1", "2", "3", "4", "5", XXX,
"`", "q", "w", "e", "r", "t", "\t",
L"⇞", "a", "s", "d", "f", "g",
L"⇟", "z", "x", "c", "v", "b", L"⎋",
L"⌃", L"⌫", L"⌘", L"⇧",
XXX,
XXX, "6", "7", "8", "9", "0", XXX,
L"⎆", "y", "u", "i", "o", "p", "=",
"h", "j", "k", "l", ";", "\"",
XXX, "n", "m", ",", ".", "/", "-",
llg, L"r⌥", L"␣", L"r⌃",
XXX
),
// Reset the standard keymap to german
//
#undef CONVERT_TO_KEY
#define CONVERT_TO_KEY(INPUT) MAP_WITH_HOST_KEYMAP(linux, de, standard, INPUT)
[German] = KEYMAP_STACKED
(
XXX, "1", "2", "3", "4", "5", XXX,
XXX, "q", "w", "e", "r", "t", "\t", // The backtick key does not exist on the german keyboard
L"⇞", "a", "s", "d", "f", "g",
L"⇟", "y", "x", "c", "v", "b", L"⎋",
L"⌃", L"⌫", L"⌘", L"⇧",
XXX,
XXX, "6", "7", "8", "9", "0", L"ß",
L"⎆", "z", "u", "i", "o", "p", L"ü",
"h", "j", "k", "l", L"ö", L"ä",
XXX, "n", "m", ",", ".", "-", XXX,
___, L"r⌥", L"␣", L"r⌃",
XXX
)
END_KEYMAPS
// *INDENT-ON*
void setup() {
Kaleidoscope.setup();
}
void loop() {
Kaleidoscope.loop();
}
// The following is just a test (not necessary to define a keymap).
//
// An auxiliary macro D is used to define keys of the german (de)
// keymap.
//
#define D(KEY_STRING) MAP_WITH_HOST_KEYMAP(linux, de, standard, L##KEY_STRING)
// For testing purposes, we define an auxiliary macro for the US keymap as
// well.
//
#define U(KEY_STRING) MAP_WITH_HOST_KEYMAP(linux, us, standard, L##KEY_STRING)
// The y and z keys of the german keymap exchange change positions with
// repect to the US keymap.
//
static_assert(D("y") == U("z"), "The letter y on the german keymap must "
"generate the same Kaleidoscope Key value as the letter z on the US "
"keymap");
static_assert(D("z") == U("y"), "The letter z on the german keymap must "
"generate the same Kaleidoscope Key value as the letter y on the US "
"keymap");