Skip to content

Commit 5b0009c

Browse files
authored
Merge pull request adafruit#5151 from dhalbert/usb_hid-changes
Support multiple reports per device in usb_hid
2 parents 2d8346d + 1bcf66f commit 5b0009c

File tree

11 files changed

+332
-200
lines changed

11 files changed

+332
-200
lines changed

locale/circuitpython.pot

+14-13
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ msgstr ""
9191
msgid "%q length must be %q"
9292
msgstr ""
9393

94+
#: shared-bindings/usb_hid/Device.c
95+
msgid "%q length must be >= 1"
96+
msgstr ""
97+
9498
#: shared-bindings/vectorio/Polygon.c
9599
msgid "%q list must be a list"
96100
msgstr ""
@@ -103,14 +107,6 @@ msgstr ""
103107
msgid "%q must be %d-%d"
104108
msgstr ""
105109

106-
#: shared-bindings/usb_hid/Device.c
107-
msgid "%q must be 0-255"
108-
msgstr ""
109-
110-
#: shared-bindings/usb_hid/Device.c
111-
msgid "%q must be 1-255"
112-
msgstr ""
113-
114110
#: py/argcheck.c
115111
msgid "%q must be >= %d"
116112
msgstr ""
@@ -127,10 +123,6 @@ msgstr ""
127123
msgid "%q must be >= 1"
128124
msgstr ""
129125

130-
#: shared-bindings/usb_hid/Device.c
131-
msgid "%q must be None or between 1 and len(report_descriptor)-1"
132-
msgstr ""
133-
134126
#: py/argcheck.c
135127
msgid "%q must be a string"
136128
msgstr ""
@@ -168,6 +160,10 @@ msgstr ""
168160
msgid "%q() takes %d positional arguments but %d were given"
169161
msgstr ""
170162

163+
#: shared-bindings/usb_hid/Device.c
164+
msgid "%q, %q, and %q must all be the same length"
165+
msgstr ""
166+
171167
#: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c
172168
#, c-format
173169
msgid "%s error 0x%x"
@@ -1234,7 +1230,7 @@ msgstr ""
12341230
msgid "Internal error #%d"
12351231
msgstr ""
12361232

1237-
#: shared-bindings/sdioio/SDCard.c
1233+
#: shared-bindings/sdioio/SDCard.c shared-module/usb_hid/Device.c
12381234
msgid "Invalid %q"
12391235
msgstr ""
12401236

@@ -1518,6 +1514,11 @@ msgstr ""
15181514
msgid "Missing jmp_pin. Instruction %d jumps on pin"
15191515
msgstr ""
15201516

1517+
#: shared-module/usb_hid/Device.c
1518+
#, c-format
1519+
msgid "More than %d report ids not supported"
1520+
msgstr ""
1521+
15211522
#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
15221523
msgid "Must be a %q subclass."
15231524
msgstr ""

ports/atmel-samd/boards/blm_badge/mpconfigboard.mk

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CIRCUITPY_AUDIOIO = 1
1414
CIRCUITPY_AUDIOBUSIO = 1
1515
# Pins for I2SOut are not available.
1616
CIRCUITPY_AUDIOBUSIO_I2SOUT = 0
17+
CIRCUITPY_BUSIO_SPI = 0
1718
CIRCUITPY_PWMIO = 0
1819
CIRCUITPY_ROTARYIO = 0
1920
CIRCUITPY_RTC = 0

ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ INTERNAL_FLASH_FILESYSTEM = 1
1010
LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

13-
CIRCUITPY_GETPASS = 0
13+
# There are many pin definitions on this board; it doesn't quite fit on very large translations.
14+
# So remove what might be least likely module to be used.
15+
CIRCUITPY_RAINBOWIO = 0

py/argcheck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t
197197

198198
size_t mp_arg_validate_length_with_name(mp_int_t i, size_t length, qstr arg_name, qstr length_name) {
199199
if (i != (mp_int_t)length) {
200-
mp_raise_ValueError_varg(translate("%q length must be %q"), MP_QSTR_pressed, MP_QSTR_num_keys);
200+
mp_raise_ValueError_varg(translate("%q length must be %q"), arg_name, length_name);
201201
}
202202
return (size_t)i;
203203
}

shared-bindings/usb_hid/Device.c

+136-64
Large diffs are not rendered by default.

shared-bindings/usb_hid/Device.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333

3434
extern const mp_obj_type_t usb_hid_device_type;
3535

36-
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t descriptor, uint8_t usage_page, uint8_t usage, uint8_t in_report_length, uint8_t out_report_length, uint8_t report_id_index);
37-
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len);
36+
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint8_t usage_page, uint8_t usage, size_t report_ids_count,uint8_t *report_ids, uint8_t *in_report_lengths, uint8_t *out_report_lengths);
37+
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len, uint8_t report_id);
38+
mp_obj_t common_hal_usb_hid_device_get_last_received_report(usb_hid_device_obj_t *self, uint8_t report_id);
3839
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self);
3940
uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self);
41+
uint8_t common_hal_usb_hid_device_validate_report_id(usb_hid_device_obj_t *self, mp_int_t report_id);
4042

4143
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_HID_DEVICE_H

shared-bindings/usb_hid/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable);
7171
//|
7272
//| If you enable too many devices at once, you will run out of USB endpoints.
7373
//| The number of available endpoints varies by microcontroller.
74-
//| CircuitPython will go into safe mode after running boot.py to inform you if
74+
//| CircuitPython will go into safe mode after running ``boot.py`` to inform you if
7575
//| not enough endpoints are available.
7676
//| """
7777
//| ...

0 commit comments

Comments
 (0)