chegewara/EspTinyUSB

Change VID/PID from sketch

joelsernamoreno opened this issue · 8 comments

Hello

Is there any way to change the keyboard VID/PID on the air?

I am using this, but with no results:

Keyboard.deviceID(0x05AC, 0x0201);

Thanks

Mm... I'm not referring to the serial class, I'm referring to the HID (keyboard) identification. I'm looking for this to identify as a Mac keyboard

And i am saying it is applicable to any USB class, keyboard too.
Just like you did, only it has to be called before begin()

Keyboard.deviceID(0x05AC, 0x0201);
keyboard.begin()

If I use the keyboard class the keyboard part does not work:

usb 1-2: new full-speed USB device number 84 using xhci_hcd
[12031.764521] usb 1-2: config 1 has an invalid descriptor of length 120, skipping remainder of the config
[12031.765947] usb 1-2: New USB device found, idVendor=dead, idProduct=beef, bcdDevice= 0.64
[12031.765949] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12031.765950] usb 1-2: Product: Joel
[12031.765951] usb 1-2: Manufacturer: Joel
[12031.765952] usb 1-2: SerialNumber: 1234-567890
[12031.767552] usb 1-2: can't set config #1, error -32

This seems to work for me:

USBSerial.manufacturer("Joel");
USBSerial.serial("1234-567890");
USBSerial.product("Joel");
USBSerial.revision(100);
USBSerial.deviceID(0xdead, 0xbeef);
USBSerial.registerDeviceCallbacks(new MyUSBSallnbacks());
dev.setCallbacks(new MyHIDCallbacks());
dev.begin();
USBSerial.begin();

Well, is it possible to stop the USBSerial class, change VID/PID and restart it to continuously change the data?

An example would be the following:

USBSerial.manufacturer("Joel");
USBSerial.product("Joel");
Keyboard.begin();
USBSerial.begin();

USBSerial.stop();
USBSerial.manufacturer("EsptinyUSB");
USBSerial.product("EsptinyUSB");
Keyboard.begin();
USBSerial.begin();

No, its not possible to stop and restart any class.
Without the code its hard to say why you are having this error:

[12031.767552] usb 1-2: can't set config 1, error -32

Hi

A quick question

Some time ago I sent you a PR with multilayout, I have seen that now hidkeylayout.h has changed quite a bit. I have added a keymap here (Spanish layout) below the English layout:

#elif KEY_LAYOUT == ES_LAYOUT
/* ES keyboard (as HID standard) */
#define KEYMAP_SIZE (152)
const KEYMAP keymap[KEYMAP_SIZE] = {


}

I have tried to define the layout with #define KEY_LAYOUT ES_LAYOUT in several places in the library and in my code, but I have not been able to get this to be applied correctly, the library still uses the English layout

Any hint?

I have already fixed the problem

I add this in hidkeylayout.h:

#ifndef US_LAYOUT
#define KEY_LAYOUT US_LAYOUT
#endif
#ifndef ES_LAYOUT
#define KEY_LAYOUT ES_LAYOUT
#endif
#ifndef UK_LAYOUT
#define KEY_LAYOUT UK_LAYOUT
#endif

And in my sketch:

#define ES_LAYOUT

I will send you PR again when I add several layouts

Thanks