Skip to content

Commit

Permalink
X-Input Serial ID (Pico ID Based) (#1235)
Browse files Browse the repository at this point in the history
* [ImgBot] Optimize images

*Total -- 6,536.44kb -> 6,081.92kb (6.95%)

/configs/OpenCore0/assets/Open_Core0_LED_order.png -- 81.87kb -> 34.77kb (57.53%)
/configs/OpenCore0/assets/Open_Core0_pin_mapping.png -- 79.46kb -> 34.15kb (57.02%)
/configs/OpenCore0/assets/Open_Core0_layout.png -- 80.33kb -> 34.76kb (56.73%)
/configs/OpenCore0/assets/Open_Core0_2.jpg -- 3,134.92kb -> 2,976.17kb (5.06%)
/configs/OpenCore0/assets/Open_Core0.jpg -- 3,159.87kb -> 3,002.07kb (4.99%)

Signed-off-by: ImgBotApp <[email protected]>

* Updated X-Input serial index 3 to use Pico ID instead of static value (converted to bytes)

* Let's try the tail end of the pico ID

* Lots of tabs in this driver, moved over to spaces

* Also convert these indents to spaces

---------

Signed-off-by: ImgBotApp <[email protected]>
Co-authored-by: ImgBotApp <[email protected]>
  • Loading branch information
arntsonl and ImgBotApp authored Dec 23, 2024
1 parent 3f37d77 commit e2d765a
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 181 deletions.
16 changes: 15 additions & 1 deletion headers/drivers/xinput/XInputDescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <stdint.h>
#include <pico/unique_id.h>

#define XINPUT_ENDPOINT_SIZE 20

Expand Down Expand Up @@ -50,7 +51,7 @@ static const uint8_t xinput_string_language[] = { 0x09, 0x04 };
static const uint8_t xinput_string_serial[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uint8_t xinput_string_manfacturer[] = "\xa9Microsoft Corporation";
static const uint8_t xinput_string_product[] = "Controller";
static const uint8_t xinput_string_version[] = "08FEC93"; // Fake a random serial, doesn't matter
static uint8_t xinput_string_version[] = "08FEC93"; // Serial that is overridden by Pico ID
static const uint8_t xinput_string_xsm3[] = "Xbox Security Method 3, Version 1.00, \xa9 2005 Microsoft Corporation. All rights reserved.";

static const uint8_t *xinput_string_descriptors[] __attribute__((unused)) =
Expand All @@ -62,6 +63,19 @@ static const uint8_t *xinput_string_descriptors[] __attribute__((unused)) =
xinput_string_xsm3
};

static const uint8_t * xinput_get_string_descriptor(int index) {
if ( index == 3 ) {
// Generate a serial number of hex bytes from the pico's unique ID
pico_unique_board_id_t unique_id;
pico_get_unique_board_id(&unique_id);
for(int i = 0; i < 3; i++) {
sprintf((char*)(&xinput_string_version[i*2+1]), "%02X", (uint8_t)unique_id.id[i+5]);
}
}

return xinput_string_descriptors[index];
}

static const uint8_t xinput_device_descriptor[] =
{
0x12, // bLength
Expand Down
Loading

0 comments on commit e2d765a

Please sign in to comment.