Page 1 of 1

esp32S2 HID keyboard

Posted: Wed Dec 30, 2020 11:09 pm
by chegewara
Very simple example of USB HID keyboard with saola board and m5stack cardKB. Code will be available on arduino and is very simple and easy to use:

Code: Select all

#include "hidkeyboard.h"
#include "Wire.h"

#define KEYBOARD_I2C_ADDR     0X5f

HIDkeyboard dev;

void setup()
{
    Serial.begin(115200);
    Wire.begin(7,8);
    dev.begin();
}

void loop()
{
    delay(10);
    Wire.requestFrom(KEYBOARD_I2C_ADDR, 1);  // request 1 byte from keyboard
    while (Wire.available()) { 
      uint8_t key_val = Wire.read();                  // receive a byte as character
      if(key_val != 0) {
        dev.sendChar(key_val); // send ASCII char
      }
    }
}
20201230_235928.jpg
20201230_235928.jpg (4.4 MiB) Viewed 8475 times

Re: esp32S2 HID devices

Posted: Thu Dec 31, 2020 10:28 pm
by chegewara
Library is updated with mouse and gamepad, so now its possible to build hid devices:
- keyboard,
- mouse with 2 scroll wheels and 3(5) buttons,
- gamepad with 16 buttons and 2 analog joysticks,
- some generic IN/OUT hid device.

Unfortunately only hid 1 device can be implemented at the same time, because arduino tinyusb library is build with such settings.


Happy new year with esp32 and wish you all many great projects and new esp32 chip versions in 2021.

Re: esp32S2 HID keyboard

Posted: Mon Jan 11, 2021 12:57 pm
by ehagerty
@chegewara is this in github somewhere? Thanks so much!

Re: esp32S2 HID keyboard

Posted: Mon Jan 11, 2021 1:51 pm
by chegewara