pc_keyboard/layouts/
dvorak104.rs1use crate::{DecodedKey, HandleControl, KeyCode, KeyboardLayout, Modifiers};
4
5pub struct Dvorak104Key;
9
10impl KeyboardLayout for Dvorak104Key {
11 fn map_keycode(
12 &self,
13 keycode: KeyCode,
14 modifiers: &Modifiers,
15 handle_ctrl: HandleControl,
16 ) -> DecodedKey {
17 let map_to_unicode = handle_ctrl == HandleControl::MapLettersToUnicode;
18 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 }
302 }
303 }
304}