Skip to content

Commit c609d4a

Browse files
committed
Initialize the layout to en_US in the constructor
This obviates the need to test in press() whether it has been initialized, saving a few cycles and a few bytes of flash.
1 parent ac0291b commit c609d4a

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/Keyboard.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Keyboard_::Keyboard_(void)
6565
{
6666
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
6767
HID().AppendDescriptor(&node);
68-
_asciimap = 0;
68+
_asciimap = KeyboardLayout_en_US;
6969
}
7070

7171
void Keyboard_::begin(const uint8_t *layout)
@@ -90,10 +90,6 @@ uint8_t USBPutChar(uint8_t c);
9090
// call release(), releaseAll(), or otherwise clear the report and resend.
9191
size_t Keyboard_::press(uint8_t k)
9292
{
93-
// Do not be too harsh on users who forget to begin().
94-
if (!_asciimap) {
95-
begin();
96-
}
9793
uint8_t i;
9894
if (k >= 136) { // it's a non-printing key (not a modifier)
9995
k = k - 136;

0 commit comments

Comments
 (0)