Send Caps Lock command to Espruino USB HID

Posted on
  • Hello again everyone!
    I've been doing a bit of reading and I've tried a couple of things but can't seem to get properly started.

    My end goal is to be able to press capslock (or emulate a capslock press) on the host device and have that sent directly to the Espruino Pico which I've got in USB HID mode. I'd like for the Espruino to then be able to be recognise that command and then I'd activate a function to turn on one of its LEDs. Then behave as one would expect and adjust all characters sent to the host as if the Caps Lock were pressed on an actual keyboard.

    My understanding is that commands like setleds can be used to manipulate the LEDs on Keyboards and I this would be a cool way to do it but I'm unsure how to get the Espruino to receive/understand this.

    I'm very keen to avoid writing a script that would simply sends one of the echo commands to the espruino upon a capslock press. Though I would not mind writing a script that realises a caps Lock has been pressed and sends a setleds command.

    TLDR: How do I get the Espruino Pico to understand a setleds/Caps Lock command from the host as if it were a real Keyboard?

  • I'm afraid there's no way to do that at the moment. Espruino's USB HID uses only one USB endpoint (running from the Espruino to the PC), so there's only ever one-directional data transfer.

    Having said that, you may not need it depending on what you're planning. As far as I know, keyboards send the key that's pressed - but for instance that would just be the 'A' key - there's no understanding of what is upper and lower case. That is handled by the PC.

    If you press 'shift-A' it sends 'A' but with a 'shift' modifier. Caps lock doesn't have any effect on what is sent back.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Send Caps Lock command to Espruino USB HID

Posted by Avatar for user79809 @user79809

Actions