From 76ec07abc390a0b1b0fce30b7826914fdee325de Mon Sep 17 00:00:00 2001 From: amogha1234 Date: Thu, 4 Jul 2024 10:39:50 +0530 Subject: [PATCH 1/2] usb/usb-device-keyboard: Add key release. Signed-off-by: amogha1234 --- micropython/usb/usb-device-keyboard/manifest.py | 2 +- .../usb-device-keyboard/usb/device/keyboard.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/micropython/usb/usb-device-keyboard/manifest.py b/micropython/usb/usb-device-keyboard/manifest.py index 923535c4c..5a2ff307d 100644 --- a/micropython/usb/usb-device-keyboard/manifest.py +++ b/micropython/usb/usb-device-keyboard/manifest.py @@ -1,3 +1,3 @@ -metadata(version="0.1.0") +metadata(version="0.1.1") require("usb-device-hid") package("usb") diff --git a/micropython/usb/usb-device-keyboard/usb/device/keyboard.py b/micropython/usb/usb-device-keyboard/usb/device/keyboard.py index c42405fc4..19944ab80 100644 --- a/micropython/usb/usb-device-keyboard/usb/device/keyboard.py +++ b/micropython/usb/usb-device-keyboard/usb/device/keyboard.py @@ -69,6 +69,22 @@ def send_keys(self, down_keys, timeout_ms=100): return True return False + def release_all(self): + for i in range(_KEY_REPORT_LEN): + self._key_reports[0][i] = 0 + if self.send_report(self._key_reports[0], 200): + return True + return False + + '''Example usage + + k = KeyboardInterface() + usb.device.get().init(k, builtin_driver=True) + key = [4] #It clicks letter A (refer KeyCode class) + k.send_keys(key) + k.release_all() + + ''' # HID keyboard report descriptor # From beb2c00ee12bd03de56998e5b1710ffc3ecb6557 Mon Sep 17 00:00:00 2001 From: amogha1234 Date: Thu, 4 Jul 2024 10:44:03 +0530 Subject: [PATCH 2/2] usb/usb-device-keyboard: Add key release. Signed-off-by: amogha1234 --- micropython/usb/usb-device-keyboard/usb/device/keyboard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/usb/usb-device-keyboard/usb/device/keyboard.py b/micropython/usb/usb-device-keyboard/usb/device/keyboard.py index 19944ab80..8947eda23 100644 --- a/micropython/usb/usb-device-keyboard/usb/device/keyboard.py +++ b/micropython/usb/usb-device-keyboard/usb/device/keyboard.py @@ -76,15 +76,15 @@ def release_all(self): return True return False - '''Example usage + """Example usage k = KeyboardInterface() usb.device.get().init(k, builtin_driver=True) key = [4] #It clicks letter A (refer KeyCode class) k.send_keys(key) k.release_all() + """ - ''' # HID keyboard report descriptor #