Skip to content

Commit c5e4432

Browse files
committed
update the readme with better module and class names
1 parent 32d32fa commit c5e4432

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ circup install keyboard_layout_win_fr
1010

1111
### Layouts
1212

13-
`keyboard_layout_<platform>_<lang>` modules will contain the layout information for use with the `Keyboard` to type text.
13+
For the plaform **platform** (win, mac) and the layout language **lang**.
14+
The module `keyboard_layout_platform_lang` has a class called `KeyboardLayoutPlatformLang` (the CamelCase version of the module's name). It contains the layout information for use with the `Keyboard` to type text.
1415

15-
They require also installing the `keyboard_layout.py` file, containing the base class and methods that are used by the layout. This file should be part of adafruit_hid in the future and will be removed.
16+
They require also installing the `keyboard_layout` module (`keyboard_layout.mpy` in the bundle zip), containing the base class for the layout. This file should be part of adafruit_hid in the future and will then be removed.
1617

1718
```py
1819
import usb_hid
1920
from adafruit_hid.keyboard import Keyboard
20-
from keyboard_layout_win_fr import KeyboardLayoutFR
21+
from keyboard_layout_win_fr import KeyboardLayoutWinFr
2122
keyboard = Keyboard(usb_hid.devices)
22-
keyboard_fr = KeyboardLayoutFR(keyboard)
23-
keyboard_fr.write("Bonjour le monde")
23+
layout = KeyboardLayoutWinFr(keyboard)
24+
layout.write("Bonjour le monde")
2425
```
2526

2627
### Keycodes

libraries/keyboard_layout.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ def _above128char_to_keycode(self, char):
111111
return self.HIGHER_ASCII[ord(char)]
112112

113113
raise ValueError(
114-
"Unsupported non-ASCII character {letter} ({num}/0x{num:02x})."
115-
.format(letter=str(char), num=ord(char))
114+
"Unsupported non-ASCII character {letter} ({num}/0x{num:02x}).".format(
115+
letter=str(char), num=ord(char)
116+
)
116117
)
117118

118119
def _char_to_keycode(self, char):
@@ -127,7 +128,8 @@ def _char_to_keycode(self, char):
127128
keycode = self.ASCII_TO_KEYCODE[char_val]
128129
if keycode == 0:
129130
raise ValueError(
130-
"No keycode available for character {letter} ({num}/0x{num:02x})."
131-
.format(letter=str(char), num=char_val)
131+
"No keycode available for character {letter} ({num}/0x{num:02x}).".format(
132+
letter=str(char), num=char_val
133+
)
132134
)
133135
return keycode

0 commit comments

Comments
 (0)