Add stock-USB native Joy-Con R/L hub bridge
This commit is contained in:
parent
9f6dddb790
commit
1748910316
41 changed files with 7101 additions and 909 deletions
|
|
@ -2,21 +2,23 @@
|
|||
#include "probe_memory_data.h"
|
||||
#include <string.h>
|
||||
|
||||
_Static_assert(sizeof(probe_factory_memory) == 8192, "factory capture size");
|
||||
_Static_assert(sizeof(probe_user_calibration) == 4096, "user calibration capture size");
|
||||
_Static_assert(sizeof(probe_factory_memories) == PROBE_CONTROLLER_COUNT * 8192u,
|
||||
"factory capture sizes");
|
||||
_Static_assert(sizeof(probe_user_calibrations) == PROBE_CONTROLLER_COUNT * 4096u,
|
||||
"user calibration capture sizes");
|
||||
|
||||
bool probe_memory_read(uint32_t address, uint8_t* output, size_t length) {
|
||||
if (!output) return false;
|
||||
bool probe_memory_read(uint8_t instance, uint32_t address, uint8_t* output, size_t length) {
|
||||
if (instance >= PROBE_CONTROLLER_COUNT || !output) return false;
|
||||
const uint8_t* source;
|
||||
size_t offset, available;
|
||||
if (address >= 0x13000 && address < 0x15000) {
|
||||
offset = address - 0x13000;
|
||||
source = probe_factory_memory;
|
||||
available = sizeof(probe_factory_memory) - offset;
|
||||
source = probe_factory_memories[instance];
|
||||
available = sizeof(probe_factory_memories[instance]) - offset;
|
||||
} else if (address >= 0x1fc000 && address < 0x1fd000) {
|
||||
offset = address - 0x1fc000;
|
||||
source = probe_user_calibration;
|
||||
available = sizeof(probe_user_calibration) - offset;
|
||||
source = probe_user_calibrations[instance];
|
||||
available = sizeof(probe_user_calibrations[instance]) - offset;
|
||||
} else {
|
||||
return false; // No fabricated erased bytes, pairing keys, or firmware reads.
|
||||
}
|
||||
|
|
@ -43,12 +45,12 @@ static bool valid_calibration(const uint8_t* data) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool probe_memory_right_stick_calibration(uint8_t output[9]) {
|
||||
if (!output) return false;
|
||||
// A solo Joy-Con uses the primary calibration record, even for the right
|
||||
// controller. User magic precedes its 9-byte record; factory has no magic.
|
||||
const uint8_t* selected = probe_factory_memory + 0xa8;
|
||||
const uint8_t* user = probe_user_calibration + 0x40;
|
||||
bool probe_memory_stick_calibration(uint8_t instance, uint8_t output[9]) {
|
||||
if (instance >= PROBE_CONTROLLER_COUNT || !output) return false;
|
||||
// Each Joy-Con's own capture uses the primary calibration record.
|
||||
// User magic precedes its 9-byte record; factory has no magic.
|
||||
const uint8_t* selected = probe_factory_memories[instance] + 0xa8;
|
||||
const uint8_t* user = probe_user_calibrations[instance] + 0x40;
|
||||
if (user[0] == 0xb2 && user[1] == 0xa1 && valid_calibration(user + 2))
|
||||
selected = user + 2;
|
||||
if (!valid_calibration(selected)) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue