mirror of
https://github.com/dbisu/pico-ducky.git
synced 2025-12-06 02:41:45 +00:00
Keyboard layouts (#30)
* Make switching keyboard layouts easier * Fix broken image link * fix typos
This commit is contained in:
55
README.md
55
README.md
@@ -57,6 +57,61 @@ The default mode is USB mass storage enabled.
|
||||
|
||||

|
||||
|
||||
### Changing Keyboard Layouts
|
||||
|
||||
Copied from [Neradoc/Circuitpython_Keyboard_Layouts](https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/blob/main/PICODUCKY.md)
|
||||
|
||||
#### How to use one of these layouts with the pico-ducky repository.
|
||||
|
||||
**Go to the [latest release page](https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/releases/latest), look if your language is in the list.**
|
||||
|
||||
#### If your language/layout is in the bundle
|
||||
|
||||
Download the `py` zip, named `circuitpython-keyboard-layouts-py-XXXXXXXX.zip`
|
||||
|
||||
**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.**
|
||||
|
||||
#### If your language/layout is not in the bundle
|
||||
|
||||
Try the online generator, it should get you a zip file with the bundles for yout language
|
||||
|
||||
https://www.neradoc.me/layouts/
|
||||
|
||||
#### Now you have a zip file
|
||||
|
||||
#### Find your language/layout in the lib directory
|
||||
|
||||
For a language `LANG`, copy the following files from the zip's `lib` folder to the `lib` directory of the board.
|
||||
**DO NOT** modify the adafruit_hid directory. Your files go directly in `lib`.
|
||||
**DO NOT** change the names or extensions of the files. Just pick the right ones.
|
||||
Replace `LANG` with the letters for your language of choice.
|
||||
|
||||
- `keyboard_layout.py`
|
||||
- `keyboard_layout_win_LANG.py`
|
||||
- `keycode_win_LANG.py`
|
||||
|
||||
Don't forget to get [the adafruit_hid library](https://github.com/adafruit/Adafruit_CircuitPython_HID/releases/latest).
|
||||
|
||||
This is what it should look like **if your language is French for example**.
|
||||
|
||||

|
||||
|
||||
#### Modify the pico-ducky code to use your language file:
|
||||
|
||||
At the start of the file comment out these lines:
|
||||
|
||||
```py
|
||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
|
||||
from adafruit_hid.keycode import Keycode
|
||||
```
|
||||
|
||||
Uncomment these lines:
|
||||
*Replace `LANG` with the letters for your language of choice. The name must match the file (without the py or mpy extension).*
|
||||
```py
|
||||
from keyboard_layout_win_LANG import KeyboardLayout
|
||||
from keycode_win_LANG import Keycode
|
||||
```
|
||||
|
||||
## Useful links and resources
|
||||
|
||||
### Docs
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import usb_hid
|
||||
from adafruit_hid.keyboard import Keyboard
|
||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
||||
|
||||
# comment out these lines for non_US keyboards
|
||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
|
||||
from adafruit_hid.keycode import Keycode
|
||||
|
||||
# uncomment these lines for non_US keyboards
|
||||
# replace LANG with appropriate language
|
||||
#from keyboard_layout_win_LANG import KeyboardLayout
|
||||
#from keycode_win_LANG import Keycode
|
||||
|
||||
import time
|
||||
import digitalio
|
||||
from board import *
|
||||
@@ -74,7 +82,7 @@ def parseLine(line):
|
||||
runScriptLine(newScriptLine)
|
||||
|
||||
kbd = Keyboard(usb_hid.devices)
|
||||
layout = KeyboardLayoutUS(kbd)
|
||||
layout = KeyboardLayout(kbd)
|
||||
|
||||
# sleep at the start to allow the device to be recognized by the host computer
|
||||
time.sleep(.5)
|
||||
|
||||
Reference in New Issue
Block a user