summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorYihui Xiong <yihui.xiong@hotmail.com>2020-08-19 20:18:17 +0800
committerYihui Xiong <yihui.xiong@hotmail.com>2020-08-19 20:18:17 +0800
commit8bab7b664c9627dfbaa32b3bf64893d7487f1cd0 (patch)
tree6425d12ad4535553f51f04a2a38841fd4a511fd8 /shared-bindings
parent8e77981ad580505f9ca918a489660db56d3776b2 (diff)
support to get HID OUT report
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/usb_hid/Device.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c
index 83c0df4ae..2fbc5fe51 100644
--- a/shared-bindings/usb_hid/Device.c
+++ b/shared-bindings/usb_hid/Device.c
@@ -58,6 +58,25 @@ STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(usb_hid_device_send_report_obj, usb_hid_device_send_report);
+//|report: bytes
+//| """The HID OUT report as a `bytes`. (read-only)"""
+//|
+STATIC mp_obj_t usb_hid_device_obj_get_report(mp_obj_t self_in) {
+ usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ if (self->out_report_buffer == 0) {
+ return mp_const_none;
+ }
+ return mp_obj_new_bytes(self->out_report_buffer, self->out_report_length);
+}
+MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_device_get_report_obj, usb_hid_device_obj_get_report);
+
+const mp_obj_property_t usb_hid_device_report_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&usb_hid_device_get_report_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
//| usage_page: int
//| """The usage page of the device as an `int`. Can be thought of a category. (read-only)"""
//|
@@ -96,6 +115,7 @@ const mp_obj_property_t usb_hid_device_usage_obj = {
STATIC const mp_rom_map_elem_t usb_hid_device_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_send_report), MP_ROM_PTR(&usb_hid_device_send_report_obj) },
+ { MP_ROM_QSTR(MP_QSTR_report), MP_ROM_PTR(&usb_hid_device_report_obj) },
{ MP_ROM_QSTR(MP_QSTR_usage_page), MP_ROM_PTR(&usb_hid_device_usage_page_obj)},
{ MP_ROM_QSTR(MP_QSTR_usage), MP_ROM_PTR(&usb_hid_device_usage_obj)},
};