Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xbox 360 Pass-through Authentication #1138

Merged
merged 32 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a446414
[ImgBot] Optimize images
ImgBotApp Feb 5, 2024
df2e3ec
Merge pull request #8 from arntsonl/imgbot
arntsonl Feb 8, 2024
baa61e6
Merge branch 'OpenStickCommunity:main' into main
arntsonl Feb 8, 2024
9ddf6cd
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Feb 17, 2024
19b367e
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Mar 24, 2024
3687e2f
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Mar 24, 2024
66b2c76
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Mar 31, 2024
176e75e
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Apr 1, 2024
180157b
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Apr 13, 2024
89b3250
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Apr 24, 2024
ccd4d99
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl May 5, 2024
dcdd9eb
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Jun 17, 2024
bc3f8a4
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Jun 25, 2024
2728c72
Merge branch 'main' of https://github.com/arntsonl/GP2040-CE
arntsonl Jun 25, 2024
141bae3
Very WIP xbox 360 auth, don't use this for any reason
arntsonl Sep 2, 2024
ad22c66
Packet size has to be 64
arntsonl Sep 2, 2024
5b004f2
Fixed a bug with descriptor strings that was causing the xbox 360 sec…
arntsonl Sep 5, 2024
cd72c7b
X360 Auth Working! Need to go over a lot of this code because I sync …
arntsonl Sep 14, 2024
7783b77
Re-enabling printf to figure out what is going wrong with release
arntsonl Sep 14, 2024
6b0fb29
Let's revert some core dependence if that's the issue on release
arntsonl Sep 16, 2024
57c4a76
Add sync back in and move add-ons to after driver init
arntsonl Sep 16, 2024
067f556
Removing stdio init seems to fix haute42
arntsonl Sep 16, 2024
e2e8a22
Lots of code cleaning. Core0 will always setup() before Core1() so we…
arntsonl Sep 16, 2024
125a31a
Merge branch '20240704_xbox360_auth' into Pulling-into-x360
arntsonl Sep 16, 2024
295576d
Merge pull request #17 from arntsonl/Pulling-into-x360
arntsonl Sep 16, 2024
64cf57d
Updating TinyUSB to 0.17.0 release from Sept. 2024
arntsonl Sep 17, 2024
fdddfc2
Getting x360 back up to working, fixing some small bugs
arntsonl Sep 23, 2024
d7c71b5
Merge branch '20240704_xbox360_auth' into xb360_mergin
arntsonl Sep 23, 2024
89c5f44
Merge pull request #18 from arntsonl/xb360_mergin
arntsonl Sep 23, 2024
afa7c89
One merge fix for feature data + tud auth data
arntsonl Sep 23, 2024
aed3e47
Formatting, getting ready for merge
arntsonl Sep 24, 2024
a0d9497
Last of the formatting!
arntsonl Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions headers/drivers/shared/driverhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

static uint16_t * getStringDescriptor(const char * value, uint8_t index)
{
static uint16_t descriptorStringBuffer[32]; // Max 64 bytes, 31 unicode characters
static uint16_t descriptorStringBuffer[128]; // Max 256 bytes, 127 unicode characters
size_t charCount;
if ( index == 0 ) // language always has a character count of 1
charCount = 1;
else {
charCount = strlen(value);
if (charCount > 31)
charCount = 31;
if (charCount > 127)
charCount = 127;
}
// Fill descriptionStringBuffer[1] .. [32]
for (uint8_t i = 0; i < charCount; i++)
Expand Down
58 changes: 51 additions & 7 deletions headers/drivers/xinput/XInputAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,68 @@
typedef enum {
auth_idle_state = 0,
send_auth_console_to_dongle = 1,
send_auth_dongle_to_console = 2,
wait_auth_console_to_dongle = 3,
wait_auth_dongle_to_console = 4,
send_auth_dongle_to_console = 2
} XInputAuthState;

typedef struct {
XInputAuthState xboneState;
class XInputAuthBuffer {
public:
XInputAuthBuffer() {
data = nullptr;
length = 0;
}
~XInputAuthBuffer(){
if ( data != nullptr ) {
delete [] data;
}
}

void setBuffer(uint8_t * inData, uint16_t inLen) {
data = new uint8_t[inLen];
length = inLen;
memcpy(data, inData, inLen);
}

void reset() {
if ( data != nullptr ) {
delete [] data;
}
data = nullptr;
length = 0;
}

// Console-to-Host e.g. Xbox 360 to MagicBoots
bool authCompleted;
uint8_t * data;
uint16_t length;
};

#define X360_AUTHLEN_CONSOLE_INIT 34
#define X360_AUTHLEN_DONGLE_SERIAL 29
#define X360_AUTHLEN_DONGLE_INIT 46
#define X360_AUTHLEN_CHALLENGE 22

// We need to keep track of:
// Xbox 360 Console Auth Init 34 bytes
// Dongle Serial 29 bytes
// Console-Dongle Back and Forth 46 bytes & 22 bytes
typedef struct {
XInputAuthState xinputState;
uint8_t consoleInitialAuth[X360_AUTHLEN_CONSOLE_INIT]; // Console Init (Keep when Dongle Reboots)
uint8_t dongleSerial[X360_AUTHLEN_DONGLE_SERIAL]; // Dongle Serial
uint8_t passthruBuffer[X360_AUTHLEN_DONGLE_INIT]; // Back-and-Forth Buffer (46 or 22 bytes)
uint8_t passthruBufferLen; // Length of Passthru (do we need this?)
uint8_t passthruBufferID; // ID of vendor request
bool authCompleted = false;
bool hasInitAuth = false;
bool dongle_ready = false;
} XInputAuthData;

class XInputAuth : public GPAuthDriver {
public:
virtual void initialize();
virtual bool available();
void process();
XInputAuthData * getAuthData() { return &xinputAuthData; }
private:
XInputAuthData xinputAuthData;
};

#endif
32 changes: 29 additions & 3 deletions headers/drivers/xinput/XInputAuthUSBListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,48 @@
#define _XINPUTAUTHUSBLISTENER_H_

#include "usblistener.h"
#include "XInputAuth.h"
#include "usbhostmanager.h"

#include "drivers/shared/xinput_host.h"
#include "drivers/xinput/XInputDescriptors.h"

typedef enum {
DONGLE_AUTH_IDLE = 0,
DONGLE_AUTH_WAIT_STATE
} DONGLE_AUTH_STATE;

class XInputAuthUSBListener : public USBListener {
public:
virtual void setup();
virtual void mount(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len){}
virtual void xmount(uint8_t dev_addr, uint8_t instance, uint8_t controllerType, uint8_t subtype);
virtual void unmount(uint8_t dev_addr);
virtual void report_received(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
virtual void report_sent(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len){}
virtual void report_received(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {}
virtual void report_sent(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {}
virtual void set_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len){}
virtual void get_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len){}
void process();
void setAuthData(XInputAuthData *);
private:
bool xinputh_vendor_report(tusb_dir_t dir, uint8_t request, uint16_t value, uint16_t length, uint8_t * recvBuf, uintptr_t user_data);
// Helper functions for Xbox 360 Authentication
bool auth_dongle_get_serial();
bool auth_dongle_init_challenge();
bool auth_dongle_challenge_verify();
bool auth_dongle_data_reply(uint8_t replyLen);
bool auth_dongle_wait_get_state();
bool auth_dongle_keepalive();
void auth_dongle_wait(uint8_t waitID);
uint8_t xinput_dev_addr;
uint8_t xinput_instance;
bool mounted;
bool sending;
XInputAuthData * xinputAuthData;
uint32_t wait_time;
uint8_t wait_count;
uint8_t waitBuffer[64]; // wait buffer
uint8_t waitBufferID;
DONGLE_AUTH_STATE dongleAuthState;
};

#endif // _XINPUTAUTHUSBLISTENER_H_
Loading