Skip to content

Commit cee5781

Browse files
BREAKING: USB PID will vary depending on devices (earlephilhower#3091)
The USB PID was already being changed depending on the devices installed in the app. This was needed because Windows has issues with the same VID:PID exporting different HID devices (i.e. it would not recognize changed ones properly). Unfortunately the change was to set a bit to 1 in the PID, but if the bit was already 1 then no change would occur. Now, actually XOR the bitmap of device exports to ensure the VID:PID of a sketch with only Serial will differ from one with Serial and Keyboard, for example.
1 parent fa19d11 commit cee5781

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cores/rp2040/RP2040USB.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ const uint8_t *tud_descriptor_device_cb(void) {
108108
}
109109
// Need a multi-endpoint config which will require changing the PID to help Windows not barf
110110
if (__USBInstallKeyboard) {
111-
usbd_desc_device.idProduct |= 0x8000;
111+
usbd_desc_device.idProduct ^= 0x8000;
112112
}
113113
if (__USBInstallMouse || __USBInstallAbsoluteMouse) {
114-
usbd_desc_device.idProduct |= 0x4000;
114+
usbd_desc_device.idProduct ^= 0x4000;
115115
}
116116
if (__USBInstallJoystick) {
117-
usbd_desc_device.idProduct |= 0x0100;
117+
usbd_desc_device.idProduct ^= 0x0100;
118118
}
119119
if (__USBInstallMassStorage) {
120120
usbd_desc_device.idProduct ^= 0x2000;

0 commit comments

Comments
 (0)