Updating instructions for adding keyboard layouts

This commit is contained in:
dbisu
2021-09-11 20:21:55 -05:00
parent fb4189bb20
commit af822e3f01
3 changed files with 45 additions and 7 deletions

View File

@@ -43,6 +43,10 @@ The easiest way to so is by using a jumper wire between those pins as seen bello
![Setup mode with a jumper](images/setup-mode.png)
## Adding non-US keybaords
Instructions for adding non-US keyboards can be found [here](keyboard-layouts.md).
## Useful links and resources
### Docs

View File

@@ -1,8 +1,16 @@
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_win_de_de import KeyboardLayout
from adafruit_hid.keyboard_layout_win_de_de import KeyboardLayoutWinDeDe
from adafruit_hid.keycode import Keycode
kblayout = "DE"
if kblayout == "DE":
from keyboard_layout_win_de import KeyboardLayout
from keycode_win_de import Keycode
elif kblayout == "BR":
from keyboard_layout_win_br import KeyboardLayout
from keycode_win_br import Keycode
else:
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
from adafruit_hid.keycode import Keycode
import time
import digitalio
from board import *
@@ -60,7 +68,7 @@ def parseLine(line):
runScriptLine(newScriptLine)
kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutWinDeDe(kbd)
layout = KeyboardLayout(kbd)
# sleep at the start to allow the device to be recognized by the host computer
time.sleep(.5)

26
keyboard-layouts.md Normal file
View File

@@ -0,0 +1,26 @@
## How to install non-US keyboard layouts
Clone Circuitpython_Keyboard_Layouts
`git clone https://github.com/Neradoc/Circuitpython_Keyboard_Layouts`
`cd Circuitpython_Keyboard_Layouts`
Install dependencies
`pip3 install -r requirements-modules.txt`
Install build dependencies
`pip3 install -r requirements-dev.txt`
Build layouts
`python3 build.py`
Copy libraries to pico
`cp _build/circuitpython-keyboard-layouts-6.x-mpy-<date>/lib/*.mpy /<Pico mount point>/lib`
Update duckyinpython.py
Change
`kblayout="US"`
to
`kblayout="<keyboard layout>"`
Update `if kblayout ==` block to include the new keyboard layout if not already included