KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.38k stars 474 forks source link

[BUG] Lockstatus seems unresponsive #798

Closed SethSenpai closed 1 year ago

SethSenpai commented 1 year ago

Describe the bug Using the code in the documentation I tried to get my keyboard to print some letters to the console when the lock status changes. However nothing seems to happen.

To Reproduce

keyboard = KMKKeyboard()

class LEDLockStatus(LockStatus): def set_lock_leds(self): if self.get_caps_lock(): print("A") else: print("B")

    if self.get_scroll_lock():
        print("C")
    else:
        print("D")

def after_hid_send(self, sandbox):
    super().after_hid_send(sandbox)  # Critically important. Do not forget
    #if self.report_updated:
    self.set_lock_leds()

print("print test") keyboard.extensions.append(LEDLockStatus())


**Expected behavior**
Expecting the serial terminal to print either A or B depending on the capslock status.

**Debug output**
The serial terminal is working as it does print the "print test" text as can be seen below:

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: print test

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.



**Additional context**
With some further testing it seems that the get_caps_lock() function only returns that the caps lock is not on even when it is. The module itself doesn't seem to hook into the HID stack properly?
SethSenpai commented 1 year ago

Nevermind I forgot to actually turn this thing into a keyboard so the code would keep executing. This is why you rubber duck before you make an issue I guess...