Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions adafruit_hid/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
class Keyboard:
"""Send HID keyboard reports."""

LED_NUM_LOCK = 0x01
LED_CAPS_LOCK = 0x02
LED_SCROLL_LOCK = 0x04
LED_COMPOSE = 0x08

# No more than _MAX_KEYPRESSES regular keys may be pressed at once.

def __init__(self, devices):
Expand Down Expand Up @@ -143,3 +148,12 @@ def _remove_keycode_from_report(self, keycode):
for i in range(_MAX_KEYPRESSES):
if self.report_keys[i] == keycode:
self.report_keys[i] = 0

@property
def led_status(self):
"""Returns the last received report"""
return self._keyboard_device.last_received_report

def led_on(self, led_code):
"""Returns whether an LED is on based on the led code"""
return bool(self.led_status[0] & led_code)