1
1
//! German keyboard support
2
2
3
- use crate :: { DecodedKey , HandleControl , KeyCode , KeyboardLayout , Modifiers , PhysicalKeyboard , QUO } ;
3
+ use crate :: {
4
+ DecodedKey , HandleControl , KeyCode , KeyboardLayout , Modifiers , PhysicalKeyboard , QUO , SLS ,
5
+ } ;
4
6
5
7
/// A standard German 102-key (or 105-key including Windows keys) keyboard.
6
8
///
@@ -10,247 +12,47 @@ use crate::{DecodedKey, HandleControl, KeyCode, KeyboardLayout, Modifiers, Physi
10
12
pub struct De105Key ;
11
13
12
14
impl KeyboardLayout for De105Key {
15
+ #[ rustfmt:: skip]
13
16
fn map_keycode (
14
17
& self ,
15
18
keycode : KeyCode ,
16
19
modifiers : & Modifiers ,
17
20
handle_ctrl : HandleControl ,
18
21
) -> DecodedKey {
19
- let map_to_unicode = handle_ctrl == HandleControl :: MapLettersToUnicode ;
20
22
match keycode {
21
- KeyCode :: Escape => DecodedKey :: Unicode ( '\u{001B}' ) ,
22
- KeyCode :: Oem8 => {
23
- if modifiers. is_shifted ( ) {
24
- DecodedKey :: Unicode ( '°' )
25
- } else {
26
- DecodedKey :: Unicode ( '^' )
27
- }
28
- }
29
- KeyCode :: Key1 => {
30
- if modifiers. is_shifted ( ) {
31
- DecodedKey :: Unicode ( '!' )
32
- } else {
33
- DecodedKey :: Unicode ( '1' )
34
- }
35
- }
36
- KeyCode :: Key2 => {
37
- if modifiers. is_altgr ( ) {
38
- DecodedKey :: Unicode ( '²' )
39
- } else if modifiers. is_shifted ( ) {
40
- DecodedKey :: Unicode ( '"' )
41
- } else {
42
- DecodedKey :: Unicode ( '2' )
43
- }
44
- }
45
- KeyCode :: Key3 => {
46
- if modifiers. is_altgr ( ) {
47
- DecodedKey :: Unicode ( '³' )
48
- } else if modifiers. is_shifted ( ) {
49
- DecodedKey :: Unicode ( '§' )
50
- } else {
51
- DecodedKey :: Unicode ( '3' )
52
- }
53
- }
54
- KeyCode :: Key4 => {
55
- if modifiers. is_shifted ( ) {
56
- DecodedKey :: Unicode ( '$' )
57
- } else {
58
- DecodedKey :: Unicode ( '4' )
59
- }
60
- }
61
- KeyCode :: Key5 => {
62
- if modifiers. is_shifted ( ) {
63
- DecodedKey :: Unicode ( '%' )
64
- } else {
65
- DecodedKey :: Unicode ( '5' )
66
- }
67
- }
68
- KeyCode :: Key6 => {
69
- if modifiers. is_shifted ( ) {
70
- DecodedKey :: Unicode ( '&' )
71
- } else {
72
- DecodedKey :: Unicode ( '6' )
73
- }
74
- }
75
- KeyCode :: Key7 => {
76
- if modifiers. is_altgr ( ) {
77
- DecodedKey :: Unicode ( '{' )
78
- } else if modifiers. is_shifted ( ) {
79
- DecodedKey :: Unicode ( '/' )
80
- } else {
81
- DecodedKey :: Unicode ( '7' )
82
- }
83
- }
84
- KeyCode :: Key8 => {
85
- if modifiers. is_altgr ( ) {
86
- DecodedKey :: Unicode ( '[' )
87
- } else if modifiers. is_shifted ( ) {
88
- DecodedKey :: Unicode ( '(' )
89
- } else {
90
- DecodedKey :: Unicode ( '8' )
91
- }
92
- }
93
- KeyCode :: Key9 => {
94
- if modifiers. is_altgr ( ) {
95
- DecodedKey :: Unicode ( ']' )
96
- } else if modifiers. is_shifted ( ) {
97
- DecodedKey :: Unicode ( ')' )
98
- } else {
99
- DecodedKey :: Unicode ( '9' )
100
- }
101
- }
102
- KeyCode :: Key0 => {
103
- if modifiers. is_altgr ( ) {
104
- DecodedKey :: Unicode ( '}' )
105
- } else if modifiers. is_shifted ( ) {
106
- DecodedKey :: Unicode ( '=' )
107
- } else {
108
- DecodedKey :: Unicode ( '0' )
109
- }
110
- }
111
- KeyCode :: OemMinus => {
112
- if modifiers. is_altgr ( ) {
113
- DecodedKey :: Unicode ( '\\' )
114
- } else if modifiers. is_shifted ( ) {
115
- DecodedKey :: Unicode ( '?' )
116
- } else {
117
- DecodedKey :: Unicode ( 'ß' )
118
- }
119
- }
120
- KeyCode :: OemPlus => {
121
- if modifiers. is_shifted ( ) {
122
- DecodedKey :: Unicode ( '`' )
123
- } else {
124
- DecodedKey :: Unicode ( '´' )
125
- }
126
- }
127
- KeyCode :: Backspace => DecodedKey :: Unicode ( '\u{0008}' ) ,
128
- KeyCode :: Tab => DecodedKey :: Unicode ( '\u{0009}' ) ,
129
- KeyCode :: Q => {
130
- if map_to_unicode && modifiers. is_ctrl ( ) {
131
- DecodedKey :: Unicode ( '\u{0011}' )
132
- } else if modifiers. is_altgr ( ) {
133
- DecodedKey :: Unicode ( '@' )
134
- } else if modifiers. is_caps ( ) {
135
- DecodedKey :: Unicode ( 'Q' )
136
- } else {
137
- DecodedKey :: Unicode ( 'q' )
138
- }
139
- }
140
- KeyCode :: E => {
141
- if map_to_unicode && modifiers. is_ctrl ( ) {
142
- DecodedKey :: Unicode ( '\u{0005}' )
143
- } else if modifiers. is_altgr ( ) {
144
- DecodedKey :: Unicode ( '€' )
145
- } else if modifiers. is_caps ( ) {
146
- DecodedKey :: Unicode ( 'E' )
147
- } else {
148
- DecodedKey :: Unicode ( 'e' )
149
- }
150
- }
151
- KeyCode :: Y => {
152
- if map_to_unicode && modifiers. is_ctrl ( ) {
153
- DecodedKey :: Unicode ( '\u{0014}' )
154
- } else if modifiers. is_caps ( ) {
155
- DecodedKey :: Unicode ( 'Z' )
156
- } else {
157
- DecodedKey :: Unicode ( 'z' )
158
- }
159
- }
160
- KeyCode :: Oem4 => {
161
- if modifiers. is_caps ( ) {
162
- DecodedKey :: Unicode ( 'Ü' )
163
- } else {
164
- DecodedKey :: Unicode ( 'ü' )
165
- }
166
- }
167
- KeyCode :: Oem6 => {
168
- if modifiers. is_altgr ( ) {
169
- DecodedKey :: Unicode ( '~' )
170
- } else if modifiers. is_caps ( ) {
171
- DecodedKey :: Unicode ( '*' )
172
- } else {
173
- DecodedKey :: Unicode ( '+' )
174
- }
175
- }
176
- KeyCode :: Return => DecodedKey :: Unicode ( '\u{000A}' ) ,
177
- KeyCode :: Oem7 => {
178
- if modifiers. is_shifted ( ) {
179
- DecodedKey :: Unicode ( '\'' )
180
- } else {
181
- DecodedKey :: Unicode ( '#' )
182
- }
183
- }
184
- KeyCode :: Oem1 => {
185
- if modifiers. is_shifted ( ) {
186
- DecodedKey :: Unicode ( 'Ö' )
187
- } else {
188
- DecodedKey :: Unicode ( 'ö' )
189
- }
190
- }
191
- KeyCode :: Oem3 => {
192
- if modifiers. is_shifted ( ) {
193
- DecodedKey :: Unicode ( 'Ä' )
194
- } else {
195
- DecodedKey :: Unicode ( 'ä' )
196
- }
197
- }
198
- KeyCode :: Z => {
199
- if map_to_unicode && modifiers. is_ctrl ( ) {
200
- DecodedKey :: Unicode ( '\u{001A}' )
201
- } else if modifiers. is_caps ( ) {
202
- DecodedKey :: Unicode ( 'Y' )
203
- } else {
204
- DecodedKey :: Unicode ( 'y' )
205
- }
206
- }
207
- KeyCode :: M => {
208
- if map_to_unicode && modifiers. is_ctrl ( ) {
209
- DecodedKey :: Unicode ( '\u{001A}' )
210
- } else if modifiers. is_altgr ( ) {
211
- DecodedKey :: Unicode ( 'µ' )
212
- } else if modifiers. is_caps ( ) {
213
- DecodedKey :: Unicode ( 'M' )
214
- } else {
215
- DecodedKey :: Unicode ( 'm' )
216
- }
217
- }
218
- KeyCode :: OemComma => {
219
- if modifiers. is_shifted ( ) {
220
- DecodedKey :: Unicode ( ';' )
221
- } else {
222
- DecodedKey :: Unicode ( ',' )
223
- }
224
- }
225
- KeyCode :: OemPeriod => {
226
- if modifiers. is_shifted ( ) {
227
- DecodedKey :: Unicode ( ':' )
228
- } else {
229
- DecodedKey :: Unicode ( '.' )
230
- }
231
- }
232
- KeyCode :: Oem2 => {
233
- if modifiers. is_shifted ( ) {
234
- DecodedKey :: Unicode ( '_' )
235
- } else {
236
- DecodedKey :: Unicode ( '-' )
237
- }
238
- }
239
- KeyCode :: Oem5 => {
240
- if modifiers. is_shifted ( ) {
241
- DecodedKey :: Unicode ( '>' )
242
- } else if modifiers. is_altgr ( ) {
243
- DecodedKey :: Unicode ( '|' )
244
- } else {
245
- DecodedKey :: Unicode ( '<' )
246
- }
247
- }
248
- e => {
249
- let us = super :: Us104Key ;
250
- us. map_keycode ( e, modifiers, handle_ctrl)
251
- }
23
+ // ========= Row 2 (the numbers) =========
24
+ KeyCode :: Oem8 => modifiers. handle_shift ( '^' , '°' ) ,
25
+ KeyCode :: Key2 => modifiers. handle_altsh ( '2' , '"' , '²' ) ,
26
+ KeyCode :: Key3 => modifiers. handle_altsh ( '3' , '§' , '³' ) ,
27
+ KeyCode :: Key6 => modifiers. handle_shift ( '6' , '&' ) ,
28
+ KeyCode :: Key7 => modifiers. handle_altsh ( '7' , '/' , '{' ) ,
29
+ KeyCode :: Key8 => modifiers. handle_altsh ( '8' , '(' , '[' ) ,
30
+ KeyCode :: Key9 => modifiers. handle_altsh ( '9' , ')' , ']' ) ,
31
+ KeyCode :: Key0 => modifiers. handle_altsh ( '0' , '=' , '}' ) ,
32
+ KeyCode :: OemMinus => modifiers. handle_altsh ( 'ß' , '?' , SLS ) ,
33
+ KeyCode :: OemPlus => modifiers. handle_shift ( '´' , '`' ) ,
34
+ // ========= Row 3 (QWERTY) =========
35
+ KeyCode :: Q => modifiers. handle_alalt ( 'Q' , '@' , '@' , handle_ctrl) ,
36
+ KeyCode :: E => modifiers. handle_alalt ( 'E' , '€' , '€' , handle_ctrl) ,
37
+ KeyCode :: Y => modifiers. handle_alpha ( 'Z' , handle_ctrl) ,
38
+ KeyCode :: Oem4 => modifiers. handle_accen ( 'ü' , 'Ü' ) ,
39
+ KeyCode :: Oem6 => modifiers. handle_altsh ( '+' , '*' , '~' ) ,
40
+ // ========= Row 4 (ASDFG) =========
41
+ KeyCode :: Oem1 => modifiers. handle_accen ( 'ö' , 'Ö' ) ,
42
+ KeyCode :: Oem3 => modifiers. handle_accen ( 'ä' , 'Ä' ) ,
43
+ KeyCode :: Oem7 => modifiers. handle_shift ( '#' , QUO ) ,
44
+ // ========= Row 5 (ZXCVB) =========
45
+ KeyCode :: Oem5 => modifiers. handle_altsh ( '<' , '>' , '|' ) ,
46
+ KeyCode :: Z => modifiers. handle_alpha ( 'Y' , handle_ctrl) ,
47
+ KeyCode :: M => modifiers. handle_alalt ( 'M' , 'µ' , 'µ' , handle_ctrl) ,
48
+ KeyCode :: OemComma => modifiers. handle_shift ( ',' , ';' ) ,
49
+ KeyCode :: OemPeriod => modifiers. handle_shift ( '.' , ':' ) ,
50
+ KeyCode :: Oem2 => modifiers. handle_shift ( '-' , '_' ) ,
51
+ // ========= Fallback =========
52
+ e => super :: Us104Key . map_keycode ( e, modifiers, handle_ctrl) ,
252
53
}
253
54
}
55
+
254
56
fn get_physical ( & self ) -> PhysicalKeyboard {
255
57
PhysicalKeyboard :: Iso
256
58
}
0 commit comments