Skip to content

Commit df615dd

Browse files
authored
Keyboard layouts (#30)
* Make switching keyboard layouts easier * Fix broken image link * fix typos
1 parent 003cede commit df615dd

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,61 @@ The default mode is USB mass storage enabled.
5757

5858
![USB enable/disable mode](images/usb-boot-mode.png)
5959

60+
### Changing Keyboard Layouts
61+
62+
Copied from [Neradoc/Circuitpython_Keyboard_Layouts](https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/blob/main/PICODUCKY.md)
63+
64+
#### How to use one of these layouts with the pico-ducky repository.
65+
66+
**Go to the [latest release page](https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/releases/latest), look if your language is in the list.**
67+
68+
#### If your language/layout is in the bundle
69+
70+
Download the `py` zip, named `circuitpython-keyboard-layouts-py-XXXXXXXX.zip`
71+
72+
**NOTE: You can use the mpy version targetting the version of Circuitpython that is on the device, but on Raspberry Pi Pico you don't need it - they only reduce file size and memory use on load, which the pico has plenty of.**
73+
74+
#### If your language/layout is not in the bundle
75+
76+
Try the online generator, it should get you a zip file with the bundles for yout language
77+
78+
https://www.neradoc.me/layouts/
79+
80+
#### Now you have a zip file
81+
82+
#### Find your language/layout in the lib directory
83+
84+
For a language `LANG`, copy the following files from the zip's `lib` folder to the `lib` directory of the board.
85+
**DO NOT** modify the adafruit_hid directory. Your files go directly in `lib`.
86+
**DO NOT** change the names or extensions of the files. Just pick the right ones.
87+
Replace `LANG` with the letters for your language of choice.
88+
89+
- `keyboard_layout.py`
90+
- `keyboard_layout_win_LANG.py`
91+
- `keycode_win_LANG.py`
92+
93+
Don't forget to get [the adafruit_hid library](https://github.com/adafruit/Adafruit_CircuitPython_HID/releases/latest).
94+
95+
This is what it should look like **if your language is French for example**.
96+
97+
![CIRCUITPY drive screenshot](https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/raw/main/docs/drive_pico_ducky.png)
98+
99+
#### Modify the pico-ducky code to use your language file:
100+
101+
At the start of the file comment out these lines:
102+
103+
```py
104+
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
105+
from adafruit_hid.keycode import Keycode
106+
```
107+
108+
Uncomment these lines:
109+
*Replace `LANG` with the letters for your language of choice. The name must match the file (without the py or mpy extension).*
110+
```py
111+
from keyboard_layout_win_LANG import KeyboardLayout
112+
from keycode_win_LANG import Keycode
113+
```
114+
60115
## Useful links and resources
61116

62117
### Docs

duckyinpython.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import usb_hid
22
from adafruit_hid.keyboard import Keyboard
3-
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
3+
4+
# comment out these lines for non_US keyboards
5+
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
46
from adafruit_hid.keycode import Keycode
7+
8+
# uncomment these lines for non_US keyboards
9+
# replace LANG with appropriate language
10+
#from keyboard_layout_win_LANG import KeyboardLayout
11+
#from keycode_win_LANG import Keycode
12+
513
import time
614
import digitalio
715
from board import *
@@ -74,7 +82,7 @@ def parseLine(line):
7482
runScriptLine(newScriptLine)
7583

7684
kbd = Keyboard(usb_hid.devices)
77-
layout = KeyboardLayoutUS(kbd)
85+
layout = KeyboardLayout(kbd)
7886

7987
# sleep at the start to allow the device to be recognized by the host computer
8088
time.sleep(.5)

0 commit comments

Comments
 (0)