esp32S2 HID keyboard

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

esp32S2 HID keyboard

Postby chegewara » Wed Dec 30, 2020 11:09 pm

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 9496 times

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32S2 HID devices

Postby chegewara » Thu Dec 31, 2020 10:28 pm

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.

ehagerty
Posts: 5
Joined: Mon Jan 11, 2021 12:54 pm

Re: esp32S2 HID keyboard

Postby ehagerty » Mon Jan 11, 2021 12:57 pm

@chegewara is this in github somewhere? Thanks so much!

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32S2 HID keyboard

Postby chegewara » Mon Jan 11, 2021 1:51 pm


Who is online

Users browsing this forum: No registered users and 8 guests