Skip to content

Commit 38a685a

Browse files
authored
Merge pull request #15 from Neradoc/move-layout-base-to-adafruit
Move layout base to adafruit_hid
2 parents fc4a15f + 7a4f621 commit 38a685a

24 files changed

Lines changed: 38 additions & 30 deletions

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ NOTE: for pico-ducky users, [there's a dedicated guide](PICODUCKY.md).
1313

1414
## Install your language
1515

16-
To install both the layout and keycode files for your language, you need to copy 3 files to your board. Pick the language and platforms that match yours. Use the `.py` version, or the `.mpy` version matching your version of Circuitpython. The mpy files take less space and are better suited for Circuitpython boards with less than 1MB of drive.
16+
To install both the layout and keycode files for your language, you need to copy 2 files to your board. Pick the language and platforms that match yours. Use the `.py` version, or the `.mpy` version matching your version of Circuitpython. The mpy files take less space and are better suited for Circuitpython boards with less than 1MB of drive.
1717

18-
- `keyboard_layout.mpy` (support file)
1918
- `keyboard_layout_win_fr.mpy` (pick your platform/language)
2019
- `keycode_win_fr.mpy` (pick your platform/language)
2120

@@ -29,7 +28,7 @@ Don't forget to also install [the adafruit_hid library](https://github.com/adafr
2928

3029
### Layouts
3130

32-
Layouts require first installing the `keyboard_layout` module (`keyboard_layout.mpy` in the bundle zip), containing the base class for the layouts. This file should be part of adafruit_hid in the future and will then be removed.
31+
Layouts require the **latest** version of the `adafruit_hid` library (at least 5.x.x).
3332

3433
For the plaform **platform** (win, mac) and the layout language **lang**. The module `keyboard_layout_platform_lang` has a class called `KeyboardLayout`. It contains the layout information for use with the `Keyboard` to type text.
3534

docs/drive_generic-nohid.png

1.24 KB
Loading

docs/drive_generic.png

-50 Bytes
Loading

docs/drive_pico_ducky-nohid.png

-24.4 KB
Loading

docs/drive_pico_ducky.png

-7.44 KB
Loading

generator-web/js/drive.png

-20.6 KB
Loading

generator-web/layout_generator.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
<li>Press the "Make Zip Bundle Links" button.</li>
8787
<li>Click the link to download the zip with the modules.</li>
8888
<li>Unzip the zip.</li>
89-
<li>Copy the files to your boards "lib" directory (not the sample code).</li>
90-
<li>Don't forget ton install adafruit_hid too if it's not already there.</li>
89+
<li>Copy the files to your boards "lib" directory (the sample code is not needed).</li>
90+
<li>Don't forget to install adafruit_hid too if it's not already there.</li>
9191
<li>Follow the sample code, included in the zip.</li>
9292
<li>Come bother me <a href="https://adafru.it/discord">on discord</a> if it doesn't work (no private messages).</li>
9393
</ul>

generator-web/make_zip_bundle.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
ob_start();
77
$ERRORS = [];
8+
$LAYOUT_BASE = false;
89

910
$source_url = "";
1011
$platform = "win";
@@ -90,13 +91,15 @@
9091

9192
$keycodes = preg_replace("/".preg_quote($VERSION0)."/", $VERSION, $keycodes);
9293

93-
if( !file_exists("src/keyboard_layout6.mpy") ) {
94-
exec("mpy-cross/mpy-cross.static-amd64-linux-6 src/keyboard_layout.py");
95-
rename("src/keyboard_layout.mpy", "src/keyboard_layout6.mpy");
96-
}
97-
if( !file_exists("src/keyboard_layout7.mpy") ) {
98-
exec("mpy-cross/mpy-cross.static-amd64-linux-7 src/keyboard_layout.py");
99-
rename("src/keyboard_layout.mpy", "src/keyboard_layout7.mpy");
94+
if($LAYOUT_BASE) {
95+
if( !file_exists("src/keyboard_layout6.mpy") ) {
96+
exec("mpy-cross/mpy-cross.static-amd64-linux-6 src/keyboard_layout.py");
97+
rename("src/keyboard_layout.mpy", "src/keyboard_layout6.mpy");
98+
}
99+
if( !file_exists("src/keyboard_layout7.mpy") ) {
100+
exec("mpy-cross/mpy-cross.static-amd64-linux-7 src/keyboard_layout.py");
101+
rename("src/keyboard_layout.mpy", "src/keyboard_layout7.mpy");
102+
}
100103
}
101104

102105
function make_zip($layout, $keycodes, $cpversion, $platform, $lang) {
@@ -142,11 +145,15 @@ function make_zip($layout, $keycodes, $cpversion, $platform, $lang) {
142145
$deletes[] = $tempfile;
143146
$deletes[] = $mpyfile;
144147
# layout base
145-
$zip->addFile("src/keyboard_layout".$cpversion.".mpy", "keyboard_layout.mpy");
148+
if($LAYOUT_BASE) {
149+
$zip->addFile("src/keyboard_layout".$cpversion.".mpy", "keyboard_layout.mpy");
150+
}
146151
} else {
147152
$zip->addFromString($layout_file, $layout);
148153
$zip->addFromString($keycodes_file, $keycodes);
149-
$zip->addFile("src/keyboard_layout.py", "keyboard_layout.py");
154+
if($LAYOUT_BASE) {
155+
$zip->addFile("src/keyboard_layout.py", "keyboard_layout.py");
156+
}
150157
}
151158

152159
$data = file_get_contents("src/sample_code_template.py");

generator-web/src/keyboard_layout.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

libraries/layouts/keyboard_layout_mac_fr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Author(s): Dan Halbert, Neradoc
2626
"""
2727

28-
from keyboard_layout import KeyboardLayoutBase
28+
from adafruit_hid.keyboard_layout_base import KeyboardLayoutBase
2929

3030

3131
__version__ = "1.0.0-auto.0"

0 commit comments

Comments
 (0)