Skip to content

Keyboard CapLock simple program #326

Closed Answered by WormPatch
WormPatch asked this question in Q&A
Discussion options

You must be logged in to vote

ok i realized there is no such keyboard HID that sets leds from byte, but you can read

#include "Adafruit_TinyUSB.h"

uint8_t leds = 0;
uint8_t const desc_hid_report[] = { TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(RID_KEYBOARD)) };
Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), 2, false);

void setup() {
  usb_hid.setReportCallback(NULL, hid_report_callback);
  usb_hid.begin();
  while (!USBDevice.mounted()) delay(1);
  do delay(50); while (!usb_hid.ready());
}

void loop() {}

void hid_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {
  if (report_type == HID_REPORT_TYPE_OUTPUT) leds = buffer[0];
}

a way to …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@WormPatch
Comment options

Answer selected by WormPatch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant