Skip to content

Commit e4f0b86

Browse files
CHiPs44thejpster
authored andcommitted
Bug for Oem5 giving *µ instead of <>, amelioration for ² giving ¹³, comments about others with AltGr (+Shift)
1 parent 4aa5ef6 commit e4f0b86

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

src/layouts/azerty.rs

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,30 @@ impl KeyboardLayout for Azerty {
1919
let map_to_unicode = handle_ctrl == HandleControl::MapLettersToUnicode;
2020
match keycode {
2121
KeyCode::Escape => DecodedKey::Unicode(0x1B.into()),
22-
KeyCode::Oem8 => DecodedKey::Unicode('²'),
22+
// Works with Unicode & 850 code page, not 437
23+
KeyCode::Oem8 => {
24+
if modifiers.is_shifted() {
25+
DecodedKey::Unicode('³') // Not in 437 code page
26+
} else if modifiers.is_altgr() {
27+
DecodedKey::Unicode('¹') // Not in 437 code page
28+
} else {
29+
DecodedKey::Unicode('²')
30+
}
31+
}
32+
// Works with Unicode, 437 & 850 code pages
2333
KeyCode::Oem5 => {
2434
if modifiers.is_shifted() {
25-
DecodedKey::Unicode('*')
35+
if modifiers.is_altgr() {
36+
DecodedKey::Unicode('≥')
37+
} else {
38+
DecodedKey::Unicode('>')
39+
}
2640
} else {
27-
DecodedKey::Unicode('µ')
41+
if modifiers.is_altgr() {
42+
DecodedKey::Unicode('≤')
43+
} else {
44+
DecodedKey::Unicode('<')
45+
}
2846
}
2947
}
3048
KeyCode::Key1 => {
@@ -35,6 +53,7 @@ impl KeyboardLayout for Azerty {
3553
}
3654
}
3755
KeyCode::Key2 => {
56+
// NB: É can be done with AltGr + Shift
3857
if modifiers.is_shifted() {
3958
DecodedKey::Unicode('2')
4059
} else if modifiers.is_altgr() {
@@ -53,6 +72,7 @@ impl KeyboardLayout for Azerty {
5372
}
5473
}
5574
KeyCode::Key4 => {
75+
// NB: — (not -) can be done with AltGr + Shift, but is Unicode only
5676
if modifiers.is_shifted() {
5777
DecodedKey::Unicode('4')
5878
} else if modifiers.is_altgr() {
@@ -62,6 +82,7 @@ impl KeyboardLayout for Azerty {
6282
}
6383
}
6484
KeyCode::Key5 => {
85+
// NB: – (not -) can be done with AltGr + Shift, but is Unicode only
6586
if modifiers.is_shifted() {
6687
DecodedKey::Unicode('5')
6788
} else if modifiers.is_altgr() {
@@ -71,6 +92,7 @@ impl KeyboardLayout for Azerty {
7192
}
7293
}
7394
KeyCode::Key6 => {
95+
// NB: ‑ (not -) can be done with AltGr + Shift, but is Unicode only
7496
if modifiers.is_shifted() {
7597
DecodedKey::Unicode('6')
7698
} else if modifiers.is_altgr() {
@@ -80,6 +102,7 @@ impl KeyboardLayout for Azerty {
80102
}
81103
}
82104
KeyCode::Key7 => {
105+
// NB: È can be done with AltGr + Shift
83106
if modifiers.is_shifted() {
84107
DecodedKey::Unicode('7')
85108
} else if modifiers.is_altgr() {
@@ -89,6 +112,7 @@ impl KeyboardLayout for Azerty {
89112
}
90113
}
91114
KeyCode::Key8 => {
115+
// NB: ™ can be done with AltGr + Shift
92116
if modifiers.is_shifted() {
93117
DecodedKey::Unicode('8')
94118
} else if modifiers.is_altgr() {
@@ -98,6 +122,7 @@ impl KeyboardLayout for Azerty {
98122
}
99123
}
100124
KeyCode::Key9 => {
125+
// NB: Ç can be done with AltGr + Shift
101126
if modifiers.is_shifted() {
102127
DecodedKey::Unicode('9')
103128
} else if modifiers.is_altgr() {
@@ -107,6 +132,7 @@ impl KeyboardLayout for Azerty {
107132
}
108133
}
109134
KeyCode::Key0 => {
135+
// NB: À can be done with AltGr + Shift
110136
if modifiers.is_shifted() {
111137
DecodedKey::Unicode('0')
112138
} else if modifiers.is_altgr() {
@@ -116,6 +142,7 @@ impl KeyboardLayout for Azerty {
116142
}
117143
}
118144
KeyCode::OemMinus => {
145+
// NB: ≠ can be done with AltGr + Shift, but is Unicode only
119146
if modifiers.is_shifted() {
120147
DecodedKey::Unicode('°')
121148
} else if modifiers.is_altgr() {
@@ -125,6 +152,7 @@ impl KeyboardLayout for Azerty {
125152
}
126153
}
127154
KeyCode::OemPlus => {
155+
// NB: ± can be done with AltGr + Shift
128156
if modifiers.is_shifted() {
129157
DecodedKey::Unicode('+')
130158
} else if modifiers.is_altgr() {
@@ -136,6 +164,7 @@ impl KeyboardLayout for Azerty {
136164
KeyCode::Backspace => DecodedKey::Unicode(0x08.into()),
137165
KeyCode::Tab => DecodedKey::Unicode(0x09.into()),
138166
KeyCode::Q => {
167+
// NB: æ & Æ can be done with AltGr (+ Shift)
139168
if map_to_unicode && modifiers.is_ctrl() {
140169
DecodedKey::Unicode('\u{0001}')
141170
} else if modifiers.is_caps() {
@@ -145,6 +174,7 @@ impl KeyboardLayout for Azerty {
145174
}
146175
}
147176
KeyCode::W => {
177+
// NB: â &  can be done with AltGr (+ Shift), but no  in code page 437
148178
if map_to_unicode && modifiers.is_ctrl() {
149179
DecodedKey::Unicode('\u{001A}')
150180
} else if modifiers.is_caps() {
@@ -154,6 +184,7 @@ impl KeyboardLayout for Azerty {
154184
}
155185
}
156186
KeyCode::E => {
187+
// NB: € & ¢ can be done with AltGr (+ Shift), but not with code page 437
157188
if map_to_unicode && modifiers.is_ctrl() {
158189
DecodedKey::Unicode('\u{0005}')
159190
} else if modifiers.is_caps() {
@@ -163,6 +194,7 @@ impl KeyboardLayout for Azerty {
163194
}
164195
}
165196
KeyCode::R => {
197+
// NB: ê & Ê can be done with AltGr (+ Shift), but no Ê in code page 437
166198
if map_to_unicode && modifiers.is_ctrl() {
167199
DecodedKey::Unicode('\u{0012}')
168200
} else if modifiers.is_caps() {
@@ -172,6 +204,7 @@ impl KeyboardLayout for Azerty {
172204
}
173205
}
174206
KeyCode::T => {
207+
// NB: þ & Þ can be done with AltGr (+ Shift), but not with code page 437
175208
if map_to_unicode && modifiers.is_ctrl() {
176209
DecodedKey::Unicode('\u{0014}')
177210
} else if modifiers.is_caps() {
@@ -181,6 +214,7 @@ impl KeyboardLayout for Azerty {
181214
}
182215
}
183216
KeyCode::Y => {
217+
// NB: ÿ & Ÿ can be done with AltGr (+ Shift), but no Ÿ in code page 437
184218
if map_to_unicode && modifiers.is_ctrl() {
185219
DecodedKey::Unicode('\u{0019}')
186220
} else if modifiers.is_caps() {
@@ -190,6 +224,7 @@ impl KeyboardLayout for Azerty {
190224
}
191225
}
192226
KeyCode::U => {
227+
// NB: û & Û can be done with AltGr (+ Shift), but no Û in code page 437
193228
if map_to_unicode && modifiers.is_ctrl() {
194229
DecodedKey::Unicode('\u{0015}')
195230
} else if modifiers.is_caps() {
@@ -199,6 +234,7 @@ impl KeyboardLayout for Azerty {
199234
}
200235
}
201236
KeyCode::I => {
237+
// NB: î & Î can be done with AltGr (+ Shift), but no Î in code page 437
202238
if map_to_unicode && modifiers.is_ctrl() {
203239
DecodedKey::Unicode('\u{0009}')
204240
} else if modifiers.is_caps() {
@@ -208,6 +244,7 @@ impl KeyboardLayout for Azerty {
208244
}
209245
}
210246
KeyCode::O => {
247+
// NB: œ & Œ can be done with AltGr (+ Shift), but not with code page 437
211248
if map_to_unicode && modifiers.is_ctrl() {
212249
DecodedKey::Unicode('\u{000F}')
213250
} else if modifiers.is_caps() {
@@ -217,6 +254,7 @@ impl KeyboardLayout for Azerty {
217254
}
218255
}
219256
KeyCode::P => {
257+
// NB: ô & Ô can be done with AltGr (+ Shift), but no Ô in code page 437
220258
if map_to_unicode && modifiers.is_ctrl() {
221259
DecodedKey::Unicode('\u{0010}')
222260
} else if modifiers.is_caps() {
@@ -235,6 +273,7 @@ impl KeyboardLayout for Azerty {
235273
}
236274
}
237275
KeyCode::Oem6 => {
276+
// NB: ø & Ø can be done with AltGr (+ Shift), but not with code page 437
238277
if modifiers.is_shifted() {
239278
DecodedKey::Unicode('£')
240279
} else if modifiers.is_altgr() {
@@ -251,6 +290,7 @@ impl KeyboardLayout for Azerty {
251290
}
252291
}
253292
KeyCode::A => {
293+
// NB: ä & Ä can be done with AltGr (+ Shift)
254294
if map_to_unicode && modifiers.is_ctrl() {
255295
DecodedKey::Unicode('\u{0011}')
256296
} else if modifiers.is_caps() {
@@ -260,6 +300,7 @@ impl KeyboardLayout for Azerty {
260300
}
261301
}
262302
KeyCode::S => {
303+
// NB: ß & „ can be done with AltGr (+ Shift), but „ is Unicode only
263304
if map_to_unicode && modifiers.is_ctrl() {
264305
DecodedKey::Unicode('\u{0013}')
265306
} else if modifiers.is_caps() {
@@ -269,6 +310,7 @@ impl KeyboardLayout for Azerty {
269310
}
270311
}
271312
KeyCode::D => {
313+
// NB: ë & Ë can be done with AltGr (+ Shift), but no Ë in code page 437
272314
if map_to_unicode && modifiers.is_ctrl() {
273315
DecodedKey::Unicode('\u{0004}')
274316
} else if modifiers.is_caps() {
@@ -278,6 +320,7 @@ impl KeyboardLayout for Azerty {
278320
}
279321
}
280322
KeyCode::F => {
323+
// NB: ‘ & ‚ can be done with AltGr (+ Shift), but are Unicode only
281324
if map_to_unicode && modifiers.is_ctrl() {
282325
DecodedKey::Unicode('\u{0006}')
283326
} else if modifiers.is_caps() {
@@ -287,6 +330,7 @@ impl KeyboardLayout for Azerty {
287330
}
288331
}
289332
KeyCode::G => {
333+
// NB: ’ & ¥ can be done with AltGr (+ Shift), but no ’ in code page 437
290334
if map_to_unicode && modifiers.is_ctrl() {
291335
DecodedKey::Unicode('\u{0007}')
292336
} else if modifiers.is_caps() {
@@ -296,6 +340,7 @@ impl KeyboardLayout for Azerty {
296340
}
297341
}
298342
KeyCode::H => {
343+
// NB: ð & Ð can be done with AltGr (+ Shift), but not with code page 437
299344
if map_to_unicode && modifiers.is_ctrl() {
300345
DecodedKey::Unicode('\u{0008}')
301346
} else if modifiers.is_caps() {
@@ -305,6 +350,7 @@ impl KeyboardLayout for Azerty {
305350
}
306351
}
307352
KeyCode::J => {
353+
// NB: ü & Ü can be done with AltGr (+ Shift)
308354
if map_to_unicode && modifiers.is_ctrl() {
309355
DecodedKey::Unicode('\u{000A}')
310356
} else if modifiers.is_caps() {
@@ -314,6 +360,7 @@ impl KeyboardLayout for Azerty {
314360
}
315361
}
316362
KeyCode::K => {
363+
// NB: ï & Ï can be done with AltGr (+ Shift), but no Ï in code page 437
317364
if map_to_unicode && modifiers.is_ctrl() {
318365
DecodedKey::Unicode('\u{000B}')
319366
} else if modifiers.is_caps() {
@@ -323,6 +370,7 @@ impl KeyboardLayout for Azerty {
323370
}
324371
}
325372
KeyCode::L => {
373+
// NB: ŀ & Ŀ can be done with AltGr (+ Shift), but are Unicode only
326374
if map_to_unicode && modifiers.is_ctrl() {
327375
DecodedKey::Unicode('\u{000C}')
328376
} else if modifiers.is_caps() {
@@ -332,6 +380,7 @@ impl KeyboardLayout for Azerty {
332380
}
333381
}
334382
KeyCode::Oem1 => {
383+
// NB: ö & Ö can be done with AltGr (+ Shift)
335384
if map_to_unicode && modifiers.is_ctrl() {
336385
DecodedKey::Unicode('\u{000D}')
337386
} else if modifiers.is_caps() {
@@ -350,6 +399,7 @@ impl KeyboardLayout for Azerty {
350399
// Enter gives LF, not CRLF or CR
351400
KeyCode::Return => DecodedKey::Unicode(10.into()),
352401
KeyCode::Z => {
402+
// NB: « & “ can be done with AltGr (+ Shift), but no “ in code page 437
353403
if map_to_unicode && modifiers.is_ctrl() {
354404
DecodedKey::Unicode('\u{0017}')
355405
} else if modifiers.is_caps() {
@@ -359,6 +409,7 @@ impl KeyboardLayout for Azerty {
359409
}
360410
}
361411
KeyCode::X => {
412+
// NB: » & ” can be done with AltGr (+ Shift), but no ” in code page 437
362413
if map_to_unicode && modifiers.is_ctrl() {
363414
DecodedKey::Unicode('\u{0018}')
364415
} else if modifiers.is_caps() {
@@ -368,6 +419,7 @@ impl KeyboardLayout for Azerty {
368419
}
369420
}
370421
KeyCode::C => {
422+
// NB: © & ® can be done with AltGr (+ Shift), but not with code page 437
371423
if map_to_unicode && modifiers.is_ctrl() {
372424
DecodedKey::Unicode('\u{0003}')
373425
} else if modifiers.is_caps() {
@@ -377,6 +429,8 @@ impl KeyboardLayout for Azerty {
377429
}
378430
}
379431
KeyCode::V => {
432+
// NB: ' ' & ← can be done with AltGr (+ Shift), but '' is Unicode NARROW UNBREAKABLE SPACE
433+
// and ← is 0x1B with 437 and 850 code pages
380434
if map_to_unicode && modifiers.is_ctrl() {
381435
DecodedKey::Unicode('\u{0016}')
382436
} else if modifiers.is_caps() {
@@ -386,6 +440,7 @@ impl KeyboardLayout for Azerty {
386440
}
387441
}
388442
KeyCode::B => {
443+
// NB: ↓ & ↑ can be done with AltGr (+ Shift), but are 0x19 & 0x18 with 437 and 850 code pages
389444
if map_to_unicode && modifiers.is_ctrl() {
390445
DecodedKey::Unicode('\u{0002}')
391446
} else if modifiers.is_caps() {
@@ -395,6 +450,7 @@ impl KeyboardLayout for Azerty {
395450
}
396451
}
397452
KeyCode::N => {
453+
// NB: ¬ & → can be done with AltGr (+ Shift), but → is 0x1A with 437 and 850 code pages
398454
if map_to_unicode && modifiers.is_ctrl() {
399455
DecodedKey::Unicode('\u{000E}')
400456
} else if modifiers.is_caps() {
@@ -404,27 +460,31 @@ impl KeyboardLayout for Azerty {
404460
}
405461
}
406462
KeyCode::M => {
463+
// NB: ¿ & … can be done with AltGr (+ Shift), but no … in code page 437
407464
if modifiers.is_caps() {
408465
DecodedKey::Unicode('?')
409466
} else {
410467
DecodedKey::Unicode(',')
411468
}
412469
}
413470
KeyCode::OemComma => {
471+
// NB: × & ⋅ can be done with AltGr (+ Shift), but not with code page 437
414472
if modifiers.is_shifted() {
415473
DecodedKey::Unicode('.')
416474
} else {
417475
DecodedKey::Unicode(';')
418476
}
419477
}
420478
KeyCode::OemPeriod => {
479+
// NB: ÷ & ∕ can be done with AltGr (+ Shift), but ∕ is Unicode only
421480
if modifiers.is_shifted() {
422481
DecodedKey::Unicode('/')
423482
} else {
424483
DecodedKey::Unicode(':')
425484
}
426485
}
427486
KeyCode::Oem2 => {
487+
// NB: ¡ & − (not -) can be done with AltGr (+ Shift), but no − in code page 437
428488
if modifiers.is_shifted() {
429489
DecodedKey::Unicode('§')
430490
} else {
@@ -509,7 +569,6 @@ impl KeyboardLayout for Azerty {
509569
}
510570
}
511571
KeyCode::NumpadEnter => DecodedKey::Unicode(10.into()),
512-
KeyCode::LShift => DecodedKey::Unicode('<'),
513572
k => DecodedKey::RawKey(k),
514573
}
515574
}

0 commit comments

Comments
 (0)