Skip to content

Commit b0b6b19

Browse files
committed
Update Dvorak and Programmer's Dvorak
1 parent add8580 commit b0b6b19

File tree

2 files changed

+98
-751
lines changed

2 files changed

+98
-751
lines changed

src/layouts/dvorak104.rs

Lines changed: 41 additions & 285 deletions
Original file line numberDiff line numberDiff line change
@@ -1,304 +1,60 @@
11
//! Dvorak keyboard support
22
3-
use crate::{DecodedKey, HandleControl, KeyCode, KeyboardLayout, Modifiers, PhysicalKeyboard};
3+
use crate::{DecodedKey, HandleControl, KeyCode, KeyboardLayout, Modifiers, PhysicalKeyboard, QUO};
44

55
/// A Dvorak 101-key (or 104-key including Windows keys) keyboard.
66
///
77
/// Has a 1-row high Enter key, with Oem5 above (ANSI layout).
88
pub struct Dvorak104Key;
99

1010
impl KeyboardLayout for Dvorak104Key {
11+
#[rustfmt::skip]
1112
fn map_keycode(
1213
&self,
1314
keycode: KeyCode,
1415
modifiers: &Modifiers,
1516
handle_ctrl: HandleControl,
1617
) -> DecodedKey {
17-
let map_to_unicode = handle_ctrl == HandleControl::MapLettersToUnicode;
1818
match keycode {
19-
KeyCode::OemMinus => {
20-
if modifiers.is_shifted() {
21-
DecodedKey::Unicode('{')
22-
} else {
23-
DecodedKey::Unicode('[')
24-
}
25-
}
26-
KeyCode::OemPlus => {
27-
if modifiers.is_shifted() {
28-
DecodedKey::Unicode('}')
29-
} else {
30-
DecodedKey::Unicode(']')
31-
}
32-
}
33-
KeyCode::Q => {
34-
if modifiers.is_shifted() {
35-
DecodedKey::Unicode('"')
36-
} else {
37-
DecodedKey::Unicode('\'')
38-
}
39-
}
40-
KeyCode::W => {
41-
if modifiers.is_shifted() {
42-
DecodedKey::Unicode('<')
43-
} else {
44-
DecodedKey::Unicode(',')
45-
}
46-
}
47-
KeyCode::E => {
48-
if modifiers.is_shifted() {
49-
DecodedKey::Unicode('>')
50-
} else {
51-
DecodedKey::Unicode('.')
52-
}
53-
}
54-
KeyCode::R => {
55-
if map_to_unicode && modifiers.is_ctrl() {
56-
DecodedKey::Unicode('\u{0010}')
57-
} else if modifiers.is_caps() {
58-
DecodedKey::Unicode('P')
59-
} else {
60-
DecodedKey::Unicode('p')
61-
}
62-
}
63-
KeyCode::T => {
64-
if map_to_unicode && modifiers.is_ctrl() {
65-
DecodedKey::Unicode('\u{0019}')
66-
} else if modifiers.is_caps() {
67-
DecodedKey::Unicode('Y')
68-
} else {
69-
DecodedKey::Unicode('y')
70-
}
71-
}
72-
KeyCode::Y => {
73-
if map_to_unicode && modifiers.is_ctrl() {
74-
DecodedKey::Unicode('\u{0006}')
75-
} else if modifiers.is_caps() {
76-
DecodedKey::Unicode('F')
77-
} else {
78-
DecodedKey::Unicode('f')
79-
}
80-
}
81-
KeyCode::U => {
82-
if map_to_unicode && modifiers.is_ctrl() {
83-
DecodedKey::Unicode('\u{0007}')
84-
} else if modifiers.is_caps() {
85-
DecodedKey::Unicode('G')
86-
} else {
87-
DecodedKey::Unicode('g')
88-
}
89-
}
90-
KeyCode::I => {
91-
if map_to_unicode && modifiers.is_ctrl() {
92-
DecodedKey::Unicode('\u{0003}')
93-
} else if modifiers.is_caps() {
94-
DecodedKey::Unicode('C')
95-
} else {
96-
DecodedKey::Unicode('c')
97-
}
98-
}
99-
KeyCode::O => {
100-
if map_to_unicode && modifiers.is_ctrl() {
101-
DecodedKey::Unicode('\u{0012}')
102-
} else if modifiers.is_caps() {
103-
DecodedKey::Unicode('R')
104-
} else {
105-
DecodedKey::Unicode('r')
106-
}
107-
}
108-
KeyCode::P => {
109-
if map_to_unicode && modifiers.is_ctrl() {
110-
DecodedKey::Unicode('\u{000C}')
111-
} else if modifiers.is_caps() {
112-
DecodedKey::Unicode('L')
113-
} else {
114-
DecodedKey::Unicode('l')
115-
}
116-
}
117-
KeyCode::Oem4 => {
118-
if modifiers.is_shifted() {
119-
DecodedKey::Unicode('?')
120-
} else {
121-
DecodedKey::Unicode('/')
122-
}
123-
}
124-
KeyCode::Oem6 => {
125-
if modifiers.is_shifted() {
126-
DecodedKey::Unicode('+')
127-
} else {
128-
DecodedKey::Unicode('=')
129-
}
130-
}
131-
KeyCode::S => {
132-
if map_to_unicode && modifiers.is_ctrl() {
133-
DecodedKey::Unicode('\u{000F}')
134-
} else if modifiers.is_caps() {
135-
DecodedKey::Unicode('O')
136-
} else {
137-
DecodedKey::Unicode('o')
138-
}
139-
}
140-
KeyCode::D => {
141-
if map_to_unicode && modifiers.is_ctrl() {
142-
DecodedKey::Unicode('\u{0005}')
143-
} else if modifiers.is_caps() {
144-
DecodedKey::Unicode('E')
145-
} else {
146-
DecodedKey::Unicode('e')
147-
}
148-
}
149-
KeyCode::F => {
150-
if map_to_unicode && modifiers.is_ctrl() {
151-
DecodedKey::Unicode('\u{0015}')
152-
} else if modifiers.is_caps() {
153-
DecodedKey::Unicode('U')
154-
} else {
155-
DecodedKey::Unicode('u')
156-
}
157-
}
158-
KeyCode::G => {
159-
if map_to_unicode && modifiers.is_ctrl() {
160-
DecodedKey::Unicode('\u{0009}')
161-
} else if modifiers.is_caps() {
162-
DecodedKey::Unicode('I')
163-
} else {
164-
DecodedKey::Unicode('i')
165-
}
166-
}
167-
KeyCode::H => {
168-
if map_to_unicode && modifiers.is_ctrl() {
169-
DecodedKey::Unicode('\u{0004}')
170-
} else if modifiers.is_caps() {
171-
DecodedKey::Unicode('D')
172-
} else {
173-
DecodedKey::Unicode('d')
174-
}
175-
}
176-
KeyCode::J => {
177-
if map_to_unicode && modifiers.is_ctrl() {
178-
DecodedKey::Unicode('\u{0008}')
179-
} else if modifiers.is_caps() {
180-
DecodedKey::Unicode('H')
181-
} else {
182-
DecodedKey::Unicode('h')
183-
}
184-
}
185-
KeyCode::K => {
186-
if map_to_unicode && modifiers.is_ctrl() {
187-
DecodedKey::Unicode('\u{0014}')
188-
} else if modifiers.is_caps() {
189-
DecodedKey::Unicode('T')
190-
} else {
191-
DecodedKey::Unicode('t')
192-
}
193-
}
194-
KeyCode::L => {
195-
if map_to_unicode && modifiers.is_ctrl() {
196-
DecodedKey::Unicode('\u{000E}')
197-
} else if modifiers.is_caps() {
198-
DecodedKey::Unicode('N')
199-
} else {
200-
DecodedKey::Unicode('n')
201-
}
202-
}
203-
KeyCode::Oem1 => {
204-
if map_to_unicode && modifiers.is_ctrl() {
205-
DecodedKey::Unicode('\u{0013}')
206-
} else if modifiers.is_caps() {
207-
DecodedKey::Unicode('S')
208-
} else {
209-
DecodedKey::Unicode('s')
210-
}
211-
}
212-
KeyCode::Oem3 => {
213-
if modifiers.is_shifted() {
214-
DecodedKey::Unicode('_')
215-
} else {
216-
DecodedKey::Unicode('-')
217-
}
218-
}
219-
KeyCode::Z => {
220-
if modifiers.is_shifted() {
221-
DecodedKey::Unicode(':')
222-
} else {
223-
DecodedKey::Unicode(';')
224-
}
225-
}
226-
KeyCode::X => {
227-
if map_to_unicode && modifiers.is_ctrl() {
228-
DecodedKey::Unicode('\u{0011}')
229-
} else if modifiers.is_caps() {
230-
DecodedKey::Unicode('Q')
231-
} else {
232-
DecodedKey::Unicode('q')
233-
}
234-
}
235-
KeyCode::C => {
236-
if map_to_unicode && modifiers.is_ctrl() {
237-
DecodedKey::Unicode('\u{000A}')
238-
} else if modifiers.is_caps() {
239-
DecodedKey::Unicode('J')
240-
} else {
241-
DecodedKey::Unicode('j')
242-
}
243-
}
244-
KeyCode::V => {
245-
if map_to_unicode && modifiers.is_ctrl() {
246-
DecodedKey::Unicode('\u{000B}')
247-
} else if modifiers.is_caps() {
248-
DecodedKey::Unicode('K')
249-
} else {
250-
DecodedKey::Unicode('k')
251-
}
252-
}
253-
KeyCode::B => {
254-
if map_to_unicode && modifiers.is_ctrl() {
255-
DecodedKey::Unicode('\u{0018}')
256-
} else if modifiers.is_caps() {
257-
DecodedKey::Unicode('X')
258-
} else {
259-
DecodedKey::Unicode('x')
260-
}
261-
}
262-
KeyCode::N => {
263-
if map_to_unicode && modifiers.is_ctrl() {
264-
DecodedKey::Unicode('\u{0002}')
265-
} else if modifiers.is_caps() {
266-
DecodedKey::Unicode('B')
267-
} else {
268-
DecodedKey::Unicode('b')
269-
}
270-
}
271-
KeyCode::OemComma => {
272-
if map_to_unicode && modifiers.is_ctrl() {
273-
DecodedKey::Unicode('\u{0017}')
274-
} else if modifiers.is_caps() {
275-
DecodedKey::Unicode('W')
276-
} else {
277-
DecodedKey::Unicode('w')
278-
}
279-
}
280-
KeyCode::OemPeriod => {
281-
if map_to_unicode && modifiers.is_ctrl() {
282-
DecodedKey::Unicode('\u{0016}')
283-
} else if modifiers.is_caps() {
284-
DecodedKey::Unicode('V')
285-
} else {
286-
DecodedKey::Unicode('v')
287-
}
288-
}
289-
KeyCode::Oem2 => {
290-
if map_to_unicode && modifiers.is_ctrl() {
291-
DecodedKey::Unicode('\u{001A}')
292-
} else if modifiers.is_caps() {
293-
DecodedKey::Unicode('Z')
294-
} else {
295-
DecodedKey::Unicode('z')
296-
}
297-
}
298-
e => {
299-
let us = super::Us104Key;
300-
us.map_keycode(e, modifiers, handle_ctrl)
301-
}
19+
// ========= Row 2 (the numbers) =========
20+
KeyCode::OemMinus => modifiers.handle_shift('[', '{'),
21+
KeyCode::OemPlus => modifiers.handle_shift(']', '}'),
22+
// ========= Row 3 (QWERTY) =========
23+
KeyCode::Q => modifiers.handle_shift(QUO, '"'),
24+
KeyCode::W => modifiers.handle_shift(',', '<'),
25+
KeyCode::E => modifiers.handle_shift('.', '>'),
26+
KeyCode::R => modifiers.handle_alpha('P', handle_ctrl),
27+
KeyCode::T => modifiers.handle_alpha('Y', handle_ctrl),
28+
KeyCode::Y => modifiers.handle_alpha('F', handle_ctrl),
29+
KeyCode::U => modifiers.handle_alpha('G', handle_ctrl),
30+
KeyCode::I => modifiers.handle_alpha('C', handle_ctrl),
31+
KeyCode::O => modifiers.handle_alpha('R', handle_ctrl),
32+
KeyCode::P => modifiers.handle_alpha('L', handle_ctrl),
33+
KeyCode::Oem4 => modifiers.handle_shift('/', '?'),
34+
KeyCode::Oem6 => modifiers.handle_shift('=', '+'),
35+
// ========= Row 4 (ASDFG) =========
36+
KeyCode::S => modifiers.handle_alpha('O', handle_ctrl),
37+
KeyCode::D => modifiers.handle_alpha('E', handle_ctrl),
38+
KeyCode::F => modifiers.handle_alpha('U', handle_ctrl),
39+
KeyCode::G => modifiers.handle_alpha('I', handle_ctrl),
40+
KeyCode::H => modifiers.handle_alpha('D', handle_ctrl),
41+
KeyCode::J => modifiers.handle_alpha('H', handle_ctrl),
42+
KeyCode::K => modifiers.handle_alpha('T', handle_ctrl),
43+
KeyCode::L => modifiers.handle_alpha('N', handle_ctrl),
44+
KeyCode::Oem1 => modifiers.handle_alpha('S', handle_ctrl),
45+
KeyCode::Oem3 => modifiers.handle_shift('-', '_'),
46+
// ========= Row 5 (ZXCVB) =========
47+
KeyCode::Z => modifiers.handle_shift(';', ':'),
48+
KeyCode::X => modifiers.handle_alpha('Q', handle_ctrl),
49+
KeyCode::C => modifiers.handle_alpha('J', handle_ctrl),
50+
KeyCode::V => modifiers.handle_alpha('K', handle_ctrl),
51+
KeyCode::B => modifiers.handle_alpha('X', handle_ctrl),
52+
KeyCode::N => modifiers.handle_alpha('B', handle_ctrl),
53+
KeyCode::OemComma => modifiers.handle_alpha('W', handle_ctrl),
54+
KeyCode::OemPeriod => modifiers.handle_alpha('V', handle_ctrl),
55+
KeyCode::Oem2 => modifiers.handle_alpha('Z', handle_ctrl),
56+
// ========= Fallback =========
57+
e => super::Us104Key.map_keycode(e, modifiers, handle_ctrl),
30258
}
30359
}
30460

0 commit comments

Comments
 (0)