Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run():
dev = kbDevices[0]
# KbQueueTest
ptb.WaitSecs('YieldSecs', 1)
keyboard = hid.Keyboard(dev['index'])
# keyboard.queue_create(num_slots=10000) # done implicitly but can redo
# keyboard.start_trapping() # stops keys going to stdout but sketchy!
keyboard.queue_start()
t0 = ptb.GetSecs()
while ptb.GetSecs() < t0+5:
ptb.WaitSecs('YieldSecs', 0.00001)
if keyboard.flush():
evt = keyboard.queue_get_event()
print(evt)
keyboard.queue_stop()
def run():
dev = kbDevices[0]
# KbQueueTest
ptb.WaitSecs('YieldSecs', 1)
keyboard = hid.Keyboard(dev['index'])
# keyboard.queue_create(num_slots=10000) # done implicitly but can redo
# keyboard.start_trapping() # stops keys going to stdout but sketchy!
keyboard.queue_start()
t0 = ptb.GetSecs()
while ptb.GetSecs() < t0+5:
ptb.WaitSecs('YieldSecs', 0.00001)
if keyboard.flush():
evt = keyboard.queue_get_event()
print(evt)
keyboard.queue_stop()
def _flushEvts(self):
ptb.WaitSecs('YieldSecs', 0.00001)
while self.dev.flush():
evt, remaining = self.dev.queue_get_event()
key = {}
key['keycode'] = int(evt['Keycode'])
key['down'] = bool(evt['Pressed'])
key['time'] = evt['Time']
self._evts.append(key)