Support a simple macro of a sequence of keycodes (basis for SEND_STRING)

This commit is contained in:
Josh Klar
2018-09-30 18:03:43 -07:00
parent 99573de217
commit bdd4f86472
6 changed files with 134 additions and 10 deletions

View File

@@ -73,7 +73,6 @@ class HIDHelper:
# device, or keys will get stuck (mostly when releasing
# media/consumer keys)
self.send()
delay(10)
self.report_device[0] = needed_reporting_device
@@ -99,6 +98,17 @@ class HIDHelper:
self.logger.debug('Sending HID report: {}'.format(self._evt))
self._hid.send(self._evt)
# Without this delay, events get clobbered and you'll likely end up with
# a string like `heloooooooooooooooo` rather than `hello`. This number
# may be able to be shrunken down. It may also make sense to use
# time.sleep_us or time.sleep_ms or time.sleep (platform dependent)
# on non-Pyboards.
#
# It'd be real awesome if pyb.USB_HID.send/recv would support
# uselect.poll or uselect.select to more safely determine when
# it is safe to write to the host again...
delay(10)
return self
def send_string(self, message):
@@ -128,13 +138,6 @@ class HIDHelper:
self.add_key(kc)
self.send()
# Without this delay, events get clobbered and you'll likely end up with
# a string like `heloooooooooooooooo` rather than `hello`. This number
# may be able to be shrunken down. It may also make sense to use
# time.sleep_us or time.sleep_ms or time.sleep (platform dependent)
# on non-Pyboards.
delay(10)
# Release all keys or we'll forever hold whatever the last keyadd was
self.clear_all()
self.send()