Skip to content

Commit eb41fbc

Browse files
author
Spacehuhn
committed
Fixed RU layout
1 parent ce13637 commit eb41fbc

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ To write text, use the STRING function.
315315
| `DELAY` | `DELAY 1000` | Delay in ms |
316316
| `STRING` | `STRING Hello World!` | Types the following string |
317317
| `REPEAT` or `REPLAY` | `REPEAT 3` | Repeats the last command n times |
318-
| `LOCALE` | `LOCALE DE` | Sets the keyboard layout. Currently supported: `DE`, `ES`, `GB`, `US` |
318+
| `LOCALE` | `LOCALE DE` | Sets the keyboard layout. Available: `DE`, `ES`, `GB`, `US`, `DK`, `RU`, `FR` |
319319
| `KEYCODE` | `KEYCODE 0x02 0x04` | Types a specific key code (modifier, key1[, ..., key6]) in decimal or hexadecimal |
320320
| `LED` | `LED 40 20 10` |Changes the color of the LED in decimal RGB values (0-255) |
321321

@@ -457,6 +457,7 @@ Currently the supported keyboard layouts are:
457457
- [US](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/locale_us.h)
458458
- [ES](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/locale_es.h)
459459
- [DK](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/locale_dk.h)
460+
- [RU](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/locale_ru.h)
460461
- [FR (ASCII only)](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/locale_fr.h)
461462

462463
All standard keys are defined in [usb_hid_keys.h](https://github.com/spacehuhn/WiFiDuck/blob/master/atmega_duck/usb_hid_keys.h).

atmega_duck/keyboard.cpp

+21-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "keyboard.h"
7+
#include "debug.h"
78

89
namespace keyboard {
910
// ====== PRIVATE ====== //
@@ -101,7 +102,7 @@ namespace keyboard {
101102
uint8_t press(const char* strPtr) {
102103
// Convert string pointer into a byte pointer
103104
uint8_t* b = (uint8_t*)strPtr;
104-
105+
105106
// ASCII
106107
if (b[0] < locale->ascii_len) {
107108
uint8_t modifiers = pgm_read_byte(locale->ascii + (b[0] * 2) + 0);
@@ -111,21 +112,7 @@ namespace keyboard {
111112

112113
return 0;
113114
}
114-
115-
// Extended ASCII
116-
for (uint8_t i = 0; i<locale->extended_ascii_len; ++i) {
117-
uint8_t key_code = pgm_read_byte(locale->extended_ascii + (i * 3));
118-
119-
if (b[0] == key_code) {
120-
uint8_t modifiers = pgm_read_byte(locale->extended_ascii + (i * 3) + 1);
121-
uint8_t key = pgm_read_byte(locale->extended_ascii + (i * 3) + 2);
122-
123-
pressKey(key, modifiers);
124-
125-
return 0;
126-
}
127-
}
128-
115+
129116
// UTF8
130117
for (size_t i = 0; i<locale->utf8_len; ++i) {
131118
uint8_t res = 0;
@@ -134,7 +121,9 @@ namespace keyboard {
134121
for (uint8_t j = 0; j<4; ++j) {
135122
uint8_t key_code = pgm_read_byte(locale->utf8 + (i * 6) + j);
136123

137-
if (key_code == 0) break;
124+
if (key_code == 0) {
125+
break;
126+
}
138127

139128
if (key_code == b[j]) {
140129
++res;
@@ -144,7 +133,7 @@ namespace keyboard {
144133
}
145134
}
146135

147-
// Found a match was found, read out the data and type it
136+
// If a match was found, read out the data and type it
148137
if (res > 0) {
149138
uint8_t modifiers = pgm_read_byte(locale->utf8 + (i * 6) + 4);
150139
uint8_t key = pgm_read_byte(locale->utf8 + (i * 6) + 5);
@@ -156,6 +145,20 @@ namespace keyboard {
156145
}
157146
}
158147

148+
// Extended ASCII
149+
for (uint8_t i = 0; i<locale->extended_ascii_len; ++i) {
150+
uint8_t key_code = pgm_read_byte(locale->extended_ascii + (i * 3));
151+
152+
if (b[0] == key_code) {
153+
uint8_t modifiers = pgm_read_byte(locale->extended_ascii + (i * 3) + 1);
154+
uint8_t key = pgm_read_byte(locale->extended_ascii + (i * 3) + 2);
155+
156+
pressKey(key, modifiers);
157+
158+
return 0;
159+
}
160+
}
161+
159162
return 0;
160163
}
161164

atmega_duck/locale_ru.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ const uint8_t ascii_ru[] PROGMEM = {
191191
};
192192

193193
const uint8_t extended_ascii_ru[] PROGMEM = {
194-
0xF1, KEY_NONE, KEY_HASHTILDE, // ё
195-
0xA1, KEY_MOD_LSHIFT, KEY_HASHTILDE, // Ё
194+
0xF1, KEY_NONE, KEY_GRAVE, // ё
195+
0xA1, KEY_MOD_LSHIFT, KEY_GRAVE, // Ё
196196

197197
0xD9, KEY_NONE, KEY_Q, // й
198198
0xB9, KEY_MOD_LSHIFT, KEY_Q, // Й
@@ -263,8 +263,8 @@ const uint8_t extended_ascii_ru[] PROGMEM = {
263263
};
264264

265265
const uint8_t utf8_ru[] PROGMEM = {
266-
0xd1, 0x91, 0x00, 0x00, KEY_NONE, KEY_HASHTILDE, // ё
267-
0xd0, 0x01, 0x00, 0x00, KEY_MOD_LSHIFT, KEY_HASHTILDE, // Ё
266+
0xd1, 0x91, 0x00, 0x00, KEY_NONE, KEY_GRAVE, // ё
267+
0xd0, 0x81, 0x00, 0x00, KEY_MOD_LSHIFT, KEY_GRAVE, // Ё
268268

269269
0xd0, 0xb9, 0x00, 0x00, KEY_NONE, KEY_Q, // й
270270
0xd0, 0x99, 0x00, 0x00, KEY_MOD_LSHIFT, KEY_Q, // Й

test.script

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ LOCALE DK
5757
STRING !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}£¤§ÅÆØåæø
5858
ENTER
5959

60+
REM ru char test
61+
LOCALE RU
62+
STRING ёЁйЙцЦуУкКеЕнНгГшШщЩзЗхХъЪФФыЫвВаАпПрРоОлЛдДжЖэЭяЯчЧсСмМиИтТьЬбБюЮ
63+
ENTER
64+
6065
REM overflow test
6166
STRING 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890 01234567890
6267
ENTER

web/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h3>Functions</h3>
139139
<tr>
140140
<td><code>LOCALE</code></td>
141141
<td><code>LOCALE DE</code></td>
142-
<td>Sets the keyboard layout. Currently supported: <code>DE</code>, <code>GB</code>, <code>US</code>, <code>ES</code>, <code>FR</code>, <code>DK</code>
142+
<td>Sets the keyboard layout. Available: <code>DE</code>, <code>GB</code>, <code>US</code>, <code>ES</code>, <code>FR</code>, <code>DK</code>, <code>RU</code>
143143
</td>
144144
</tr>
145145
<tr>

0 commit comments

Comments
 (0)