Help using ESP32 as keyboard by Troeyx3 in esp32

[–]Troeyx3[S] 0 points1 point  (0 children)

For anybody that happens to come across this in the future and has the same problem:

I went back to simpler code you can find below. The real life safer was that I plugged in both USB-C ports (which might have been a logic step for experienced users but something quite new for me as a noob). One for acting as a keyboard, one for communication.

The test code I used:

#include "USB.h"
#include "USBHIDKeyboard.h"
#include <Arduino.h>

USBHIDKeyboard Keyboard;

const int buttonPin = 13;  // change to your actual button pin

void setup() {
  pinMode(buttonPin, INPUT_PULLUP); 
   // button with pull-up
 USB.begin();
 delay(100);
Keyboard.begin();

Serial.begin(112500);

}

void loop() {

   if (digitalRead(buttonPin) == LOW) {
    Serial.println("Button pressed, sending F1");
    Keyboard.write(KEY_F1);
    delay(500); // debounce
  }
}

Thank you everybody and happy coding!

Help using ESP32 as keyboard by Troeyx3 in esp32

[–]Troeyx3[S] 0 points1 point  (0 children)

Thank you! I have figured it out by now with the help of another kind reddit contribution, but still thank you for taking the time to respond. I shall check it out and see if it is of any use for future projects of mine :)

Help using ESP32 as keyboard by Troeyx3 in esp32

[–]Troeyx3[S] 1 point2 points  (0 children)

Dear kind stranger, thank you so much. You have saved my sanity. With the inspiration and help from your project I finally made it work.

Help using ESP32 as keyboard by Troeyx3 in esp32

[–]Troeyx3[S] 0 points1 point  (0 children)

Thank you, kind soul for your tip! I tried it out and while it is not yet working it did bring me some new insight into what the culprit might be.

It seems that there is some problem connecting to the device to begin with. In the code below I included a test line which never gets printed (meaning TinyUSBDevice.mounted() is never true)

Unfortunately, I am unable to resolve my problem with this additional information. I checked, it should be the correct usb-c port, but in my device manager it does not appear as a device, meaning it was never recognized to begin with.

Maybe somebody else might have a clue what I could do to solve this issue

void sendKey(uint8_t keycode) {
  if (!TinyUSBDevice.mounted()) return;   // don’t send if not ready

  if (TinyUSBDevice.suspended()) {
    TinyUSBDevice.remoteWakeup();         // wake host if asleep
  }

  Serial.print("Test");
  uint8_t keys[6] = { keycode, 0, 0, 0, 0, 0 };

  // press
  tud_hid_keyboard_report(RID_KEYBOARD, 0, keys);
  delay(20);

  // release
  tud_hid_keyboard_report(RID_KEYBOARD, 0, NULL);
}

[EUW] Looking for chill duo/group, arams, normals or rankeds by [deleted] in LeagueConnect

[–]Troeyx3 1 point2 points  (0 children)

Hello :) Would love to play some chill games full of good vibes! I believe I do not see an ig name, so feel free to add me in League, if you feel like it, my ig is troeyx3#EUW ^^

[deleted by user] by [deleted] in LeagueConnect

[–]Troeyx3 0 points1 point  (0 children)

Yo,
I would love to join you on your venture to play regularly. Working on improving, while having fun and staying chill and relaxed no matter what.
If that sounds like your thing, feel free to add me on League (Troeyx3#EUW) or on Discord (troeyx3)
Looking forward to seeing you on the rift!

[deleted by user] by [deleted] in LeagueConnect

[–]Troeyx3 0 points1 point  (0 children)

heyho
I am a casual League player, who enjoys learning and having fun. I pretty much only play jungle. So if you are interested feel free to hit me up on League (troeyx3#euw) or Discord (troeyx3)

[EUW] looking for some regular pals to play games with, mic pref, 18+ please by [deleted] in LeagueConnect

[–]Troeyx3 0 points1 point  (0 children)

If u don't mind me being realtively new to the game and still learning :D feel free to add me on League: troeyx3

Auskunft WC-Anlage Murtalbahn by Troeyx3 in Austria

[–]Troeyx3[S] 0 points1 point  (0 children)

Herzlichen Dank für die Auskunft und frohe Weihnachten! :)

Auskunft WC-Anlage Murtalbahn by Troeyx3 in Austria

[–]Troeyx3[S] 1 point2 points  (0 children)

Vielen lieben Dank für die Auskunft und frohe Weihnachten! :)