MotionPlus code clean up and small code improvements.
Removing and adding some elements, making it more readable for others. Off-Topic: Have fun at the Grandprix! May the best win:P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5536 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
659d5705c9
commit
bdeefd361a
|
@ -48,7 +48,6 @@ u8 g_MotionPlus[MAX_WIIMOTES];
|
|||
u8 g_SpeakerMute[MAX_WIIMOTES];
|
||||
|
||||
u8 g_MotionPlusLastWriteReg[MAX_WIIMOTES];
|
||||
int g_MotionPlusReadError[MAX_WIIMOTES];
|
||||
u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
|
||||
|
||||
int g_ID; // Current refreshing Wiimote
|
||||
|
|
|
@ -90,8 +90,6 @@ extern u8 g_MotionPlus[MAX_WIIMOTES];
|
|||
extern u8 g_MotionPlusLastWriteReg[MAX_WIIMOTES];
|
||||
extern u8 g_SpeakerMute[MAX_WIIMOTES];
|
||||
|
||||
|
||||
extern int g_MotionPlusReadError[MAX_WIIMOTES];
|
||||
extern u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
|
||||
|
||||
extern int g_ID;
|
||||
|
@ -118,25 +116,6 @@ static const u8 EepromData_16D0[] = {
|
|||
0x33, 0xCC, 0x44, 0xBB, 0x00, 0x00, 0x66, 0x99,
|
||||
0x77, 0x88, 0x00, 0x00, 0x2B, 0x01, 0xE8, 0x13
|
||||
};
|
||||
//I'll clean this up, we don't need the whole register
|
||||
static const u8 motionplus_register[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x79, 0x83, 0x73, 0x54, 0x72, 0xE8, 0x30, 0xC3, 0xCC, 0x4A, 0x34, 0xFC, 0xC8, 0x4F, 0xCC, 0x5B, //MP calibration data
|
||||
0x77, 0x49, 0x75, 0xA4, 0x73, 0x9A, 0x35, 0x52, 0xCA, 0x22, 0x37, 0x26, 0x2D, 0xE5, 0xB5, 0xA2, //MP calibration data
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //Extensions(NC) calibration data
|
||||
0x1e, 0x54, 0x74, 0xa2, 0x96, 0xec, 0x2b, 0xd6, 0xe1, 0xef, 0xc3, 0xf7, 0x84, 0x9e, 0x06, 0xbb,
|
||||
0x39, 0x33, 0x3d, 0x20, 0x97, 0xed, 0x75, 0x52, 0xfd, 0x98, 0xaf, 0xd8, 0xc9, 0x5a, 0x17, 0x23,
|
||||
0x74, 0x3a, 0x49, 0xd3, 0xb9, 0xf6, 0xff, 0x4f, 0x34, 0xa8, 0x6d, 0xc4, 0x96, 0x5c, 0xcd, 0xb2,
|
||||
0x33, 0x78, 0x98, 0xe9, 0xa9, 0x7f, 0xf7, 0x5e, 0x07, 0x87, 0xbb, 0x29, 0x01, 0x2b, 0x70, 0x3f,
|
||||
0xC1, 0x6D, 0x84, 0x2A, 0xD8, 0x6F, 0x8A, 0xE5, 0x2D, 0x3B, 0x7B, 0xCC, 0xD2, 0x59, 0xD5, 0xD1,
|
||||
0x9F, 0x5B, 0x6F, 0xAE, 0x82, 0xDE, 0xEA, 0xC3, 0x73, 0x42, 0x06, 0xA9, 0x77, 0xFF, 0x61, 0xA8,
|
||||
0x1A, 0x70, 0xE4, 0x16, 0x90, 0x7A, 0x80, 0xF7, 0x79, 0x4B, 0x41, 0x18, 0x82, 0x6C, 0x62, 0x1A,
|
||||
0x3B, 0xBF, 0xFC, 0xFF, 0x2C, 0xF2, 0x32, 0x97, 0xB8, 0x2F, 0x17, 0xE7, 0xBD, 0x35, 0x1D, 0x0A,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x55, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0x00, 0x00, 0xa6, 0x20, 0x00, 0x05
|
||||
};
|
||||
|
||||
/* Default calibration for the nunchuck. It should be written to 0x20 - 0x3f of the
|
||||
extension register. 0x80 is the neutral x and y accelerators and 0xb3 is the
|
||||
|
@ -158,12 +137,6 @@ static const u8 wireless_nunchuck_calibration[] =
|
|||
255, 0, 125, 255,
|
||||
0, 126, 0xed, 0x43
|
||||
};
|
||||
/* Default calibration for the motion plus*/
|
||||
static const u8 motion_plus_calibration[] =
|
||||
{
|
||||
0x79, 0xbe, 0x77, 0x5a, 0x77, 0x38, 0x2f, 0x90, 0xcd, 0x3b, 0x2f, 0xfd, 0xc8, 0x29, 0x9c, 0x75,
|
||||
0x7d, 0xd4, 0x78, 0xef, 0x78, 0x8a, 0x35, 0xa6, 0xc9, 0x9b, 0x33, 0x50, 0x2d, 0x00, 0xbd, 0x23
|
||||
};
|
||||
|
||||
/* Classic Controller calibration */
|
||||
static const u8 classic_calibration[] =
|
||||
|
@ -172,6 +145,33 @@ static const u8 classic_calibration[] =
|
|||
0x00,0x00, 0x51,0xa6
|
||||
};
|
||||
|
||||
|
||||
/* Default calibration for the motion plus, 0xA60020 */
|
||||
static const u8 motion_plus_calibration[] =
|
||||
{
|
||||
0x79, 0xbe, 0x77, 0x5a, 0x77, 0x38, // gyroscope neutral values (each 14 bit, last 2bits unknown) fast motion
|
||||
0x2f, 0x90, 0xcd, 0x3b, // "" min/max
|
||||
0x2f, 0xfd, 0xc8, 0x29, // "" min/max
|
||||
0x9c, 0x75,
|
||||
|
||||
0x7d, 0xd4, 0x78, 0xef, 0x78, 0x8a, // gyroscope neutral values (each 14 bit, last 2bits unknown) slow motion
|
||||
0x35, 0xa6, 0xc9, 0x9b, // "" min/max
|
||||
0x33, 0x50, // "" min
|
||||
0x2d, 0x00, 0xbd, 0x23
|
||||
}; // TODO: figure out remaining parts;
|
||||
|
||||
static const u8 motionplus_accel_gyro_syncing[] = { //resulting calibration data at 0xA60050 by syncing accels and gyros
|
||||
0x1e, 0x54, 0x74, 0xa2, 0x96, 0xec, 0x2b, 0xd6, 0xe1, 0xef, 0xc3, 0xf7, 0x84, 0x9e, 0x06, 0xbb,
|
||||
0x39, 0x33, 0x3d, 0x20, 0x97, 0xed, 0x75, 0x52, 0xfd, 0x98, 0xaf, 0xd8, 0xc9, 0x5a, 0x17, 0x23,
|
||||
0x74, 0x3a, 0x49, 0xd3, 0xb9, 0xf6, 0xff, 0x4f, 0x34, 0xa8, 0x6d, 0xc4, 0x96, 0x5c, 0xcd, 0xb2,
|
||||
0x33, 0x78, 0x98, 0xe9, 0xa9, 0x7f, 0xf7, 0x5e, 0x07, 0x87, 0xbb, 0x29, 0x01, 0x2b, 0x70, 0x3f
|
||||
};
|
||||
|
||||
static const u8 motionplus_activeflags[] = { //0xA600F0
|
||||
0x55, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, //Different flags, e.g. activation, calibration, initiaton, extensionstate.
|
||||
0x00, 0x00, 0xa6, 0x20, 0x00, 0x05 //Extension ID
|
||||
};
|
||||
|
||||
// Extension device IDs to be written to the last bytes of the extension reg
|
||||
static const u8 nunchuck_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 };
|
||||
static const u8 classic_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x01 };
|
||||
|
@ -180,8 +180,6 @@ static const u8 ghwtdrums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
|||
static const u8 wbb_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x4, 0x02 };
|
||||
static const u8 motionplus_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x04, 0x05 };
|
||||
static const u8 motionplusnunchuk_id[] = { 0x00, 0x00, 0xa6, 0x20, 0x05, 0x05 };
|
||||
//initial control packet for datatransfers over 0x37 reports
|
||||
static const u8 motionpluscheck_id[] = { 0xa3, 0x62, 0x45, 0xaa, 0x04, 0x02};
|
||||
// The id for nothing inserted
|
||||
static const u8 nothing_id[] = { 0x00, 0x00, 0x00, 0x00, 0x2e, 0x2e };
|
||||
// The id for a partially inserted extension
|
||||
|
|
|
@ -417,7 +417,6 @@ void ResetVariables()
|
|||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
g_ReportingAuto[i] = false;
|
||||
g_MotionPlusReadError[i] = 0;
|
||||
g_MotionPlusLastWriteReg[i] = 0;
|
||||
g_InterleavedData[i] = false;
|
||||
g_ReportingMode[i] = 0;
|
||||
|
@ -509,28 +508,29 @@ void UpdateExtRegisterBlocks(int Slot)
|
|||
if (WiiMapping[Slot].iExtensionConnected == EXT_NONE)
|
||||
{
|
||||
memset(g_RegExt[Slot],0,sizeof(g_RegExt[0]));
|
||||
memcpy(g_RegExt[Slot], motionplus_register, sizeof(motionplus_register));
|
||||
memcpy(g_RegExt[Slot] + 0x20, motion_plus_calibration, sizeof(motion_plus_calibration)); //reg 32bytes 0x20-3f;
|
||||
memset(g_RegMotionPlus[Slot] + 0x40, 0xFF, sizeof(nunchuck_calibration));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0x50, motionplus_accel_gyro_syncing, sizeof(motionplus_accel_gyro_syncing));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0xf0, motionplus_activeflags, sizeof(motionplus_activeflags));
|
||||
memcpy(g_RegExt[Slot] + 0xfa, motionplus_id, sizeof(motionplus_id));
|
||||
g_MotionPlus[Slot] = 1;
|
||||
|
||||
}
|
||||
else if(WiiMapping[Slot].iExtensionConnected == EXT_NUNCHUK)
|
||||
{
|
||||
memset(g_RegMotionPlus[Slot],0,sizeof(g_RegExt[0]));
|
||||
memcpy(g_RegMotionPlus[Slot], motionplus_register, sizeof(motionplus_register));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0x20, motion_plus_calibration, sizeof(motion_plus_calibration)); //reg 32bytes 0x20-3f;
|
||||
memcpy(g_RegMotionPlus[Slot] + 0x40, nunchuck_calibration, sizeof(nunchuck_calibration));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0x50, motionplus_accel_gyro_syncing, sizeof(motionplus_accel_gyro_syncing));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0xf0, motionplus_activeflags, sizeof(motionplus_activeflags));
|
||||
memcpy(g_RegMotionPlus[Slot] + 0xfa, motionplusnunchuk_id, sizeof(motionplusnunchuk_id));
|
||||
memcpy(g_RegExt[Slot] + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration));
|
||||
memcpy(g_RegExt[Slot] + 0x30, nunchuck_calibration, sizeof(nunchuck_calibration));
|
||||
memcpy(g_RegExt[Slot] + 0xfa, nunchuck_id, sizeof(nunchuck_id));
|
||||
|
||||
|
||||
g_MotionPlus[Slot] = 0;
|
||||
}
|
||||
g_MotionPlusReadError[Slot] = 0;
|
||||
|
||||
} else {
|
||||
g_MotionPlus[Slot] = (WiiMapping[Slot].iExtensionConnected) ? 0 : 1;
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
// Copy extension id and calibration to its register
|
||||
if(WiiMapping[Slot].iExtensionConnected == EXT_NUNCHUK)
|
||||
|
|
|
@ -346,9 +346,6 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI,
|
|||
{
|
||||
pReply->size = 0x0f;
|
||||
pReply->error = 0x07; //error: write-only area when activated/or not present
|
||||
// we use the read error at the same time as an indicator whether we need to send a faked 0x37 report or not
|
||||
g_MotionPlusReadError[g_ID]++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,22 +451,24 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
|
||||
}
|
||||
if (WiiMapping[g_ID].bMotionPlusConnected) {
|
||||
//If the MP+ gets activated, it's important to send a status report if there's another extension connected to MP
|
||||
//If the MP+ gets activated, it's important to send one or two status reports depending on the presence of a pass-through extension
|
||||
int sendreport = HandlingMotionPlusWrites(wd->data, addressHI, address);
|
||||
g_MotionPlusLastWriteReg[g_ID] = address;
|
||||
g_MotionPlusLastWriteReg[g_ID] = address;
|
||||
|
||||
switch (sendreport)
|
||||
{
|
||||
//reconnect device; unplug old extension && plug in new extension
|
||||
//pass-through extension disconnected and wm+ connected
|
||||
case 1:
|
||||
WmRequestStatus(_channelID, (wm_request_status*) wd, 0);
|
||||
WmRequestStatus(_channelID, (wm_request_status*) wd, 1);
|
||||
break;
|
||||
//device unplugged(on deactivation)
|
||||
|
||||
//wm+ unplugged(on deactivation)
|
||||
case 2:
|
||||
WmRequestStatus(_channelID, (wm_request_status*) wd, 0);
|
||||
break;
|
||||
//device plugged in(on activation)
|
||||
|
||||
//wm+ plugged in(on activation)
|
||||
case 3:
|
||||
WmRequestStatus(_channelID, (wm_request_status*) wd, 1);
|
||||
break;
|
||||
|
@ -549,99 +548,100 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
|||
}
|
||||
|
||||
//http://snzgoo.blogspot.com for more details on what this is doing
|
||||
int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address){
|
||||
int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address)
|
||||
{
|
||||
bool MPlusActiveExt = (g_RegExt[g_ID][0xFF] == 0x05) ? 1 : 0;
|
||||
|
||||
switch (addressHI)
|
||||
{
|
||||
case 0xA4:
|
||||
switch (address)
|
||||
{
|
||||
case 0x00FE:
|
||||
if (data[0] == 0x00) {
|
||||
if (g_RegExt[g_ID][0xFF] == 0x05)
|
||||
if (data[0] == 0x00)
|
||||
{
|
||||
if (MPlusActiveExt)
|
||||
{
|
||||
SwapExtRegisters();
|
||||
if (WiiMapping[g_ID].iExtensionConnected != EXT_NONE){
|
||||
if (WiiMapping[g_ID].iExtensionConnected)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Disabling WM+ and swapping registers back", data[0], addressHI, address);
|
||||
g_RegMotionPlus[g_ID][0xFE] = 0x00;
|
||||
|
||||
g_RegExt[g_ID][0xFE] = 0x00;
|
||||
SwapExtRegisters();
|
||||
return 1; // we need to issue a 0x20 report, if there's an extension connected to the MP+!
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM+ already inactive", data[0], addressHI, address);
|
||||
}
|
||||
g_MotionPlus[g_ID] = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
//1. Initializing the pass-through extension: writing 0x55 ->0xA400F0 and then 0x00 to 0xA400FB.
|
||||
//2. Disables an active wiimote; 0x20 report sent when iExtensionConnected != NONE : ext disconnect.
|
||||
//3. single write 0x00 to 0x00FB when MP got activated, part of the MP activation.
|
||||
//1. Disables an active wiimote; 0x20 report sent when iExtensionConnected != NONE : ext disconnect.
|
||||
//2. Initializing the pass-through extension: writing 0x55 ->0xA400F0 and then 0x00 to 0xA400FB.
|
||||
//3. Single write 0x00 to 0x00FB when MP got activated, part of the MP activation.
|
||||
case 0x00FB:
|
||||
|
||||
if ((data[0] == 0x00) && (g_MotionPlusLastWriteReg[g_ID] == 0xF0)) {
|
||||
|
||||
//1. Default extension init, disable mp if actitaved, else do nothing
|
||||
if (g_RegMotionPlus[g_ID][0xFF] == 0x05) //mp already deactivated, no register swap needed
|
||||
if ((data[0] == 0x00) && (g_MotionPlusLastWriteReg[g_ID] == 0xF0))
|
||||
{
|
||||
switch (g_MotionPlusLastWriteReg[g_ID])
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM+ already disabled [ext:%i] - no swapping", data[0], addressHI, address, WiiMapping[g_ID].iExtensionConnected);
|
||||
g_RegMotionPlus[g_ID][0xFE] = 0x05;
|
||||
g_RegMotionPlus[g_ID][0xF7] = 0x08;
|
||||
|
||||
} //2. disabling wiimote,
|
||||
else if (g_RegExt[g_ID][0xFF] == 0x05){
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Disabling WM+ and swapping registers back", data[0], addressHI, address)
|
||||
|
||||
if (!WiiMapping[g_ID].iExtensionConnected){
|
||||
g_RegExt[g_ID][0xFE] = 0x05;
|
||||
g_MotionPlus[g_ID] = 0;
|
||||
SwapExtRegisters();
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
case 0xF0:
|
||||
//1. disabling wiimote,
|
||||
if (MPlusActiveExt) //mp already deactivated, no register swap needed
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Disabling WM+ and swapping registers back", data[0], addressHI, address)
|
||||
g_MotionPlus[g_ID] = WiiMapping[g_ID].iExtensionConnected ? 1 : 0;
|
||||
g_RegExt[g_ID][0xFE] = 0x05;
|
||||
SwapExtRegisters();
|
||||
g_MotionPlus[g_ID] = 1;
|
||||
|
||||
if (!WiiMapping[g_ID].iExtensionConnected)
|
||||
return 2;
|
||||
} //2. Default extension init, disable mp if actitaved, else do nothing
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM+ already disabled [ext:%i] - no swapping", data[0], addressHI, address, WiiMapping[g_ID].iExtensionConnected);
|
||||
g_RegMotionPlus[g_ID][0xFE] = 0x05;
|
||||
g_RegMotionPlus[g_ID][0xF7] = 0x08;
|
||||
}
|
||||
|
||||
}
|
||||
} //3.
|
||||
else if ((data[0] == 0x00) && (g_MotionPlusLastWriteReg[g_ID] != 0xF0)) {
|
||||
|
||||
if (g_RegExt[g_ID][0xFF] == 0x05) {
|
||||
g_RegExt[g_ID][0xF1] = 0x01;
|
||||
g_RegExt[g_ID][0xF7] = 0x08; //init/calibration state flag
|
||||
|
||||
if (WiiMapping[g_ID].iExtensionConnected){
|
||||
//I don't know what these are for: F6h,F8h, F9h; but they seem necessary to be set to 0x00
|
||||
//if there's an extension connected to the MP, else they are 0xFF
|
||||
g_RegExt[g_ID][0xF6] = 0x00;
|
||||
g_RegExt[g_ID][0xF8] = 0x00;
|
||||
g_RegExt[g_ID][0xF9] = 0x00;
|
||||
break;
|
||||
//3. part of wm activation.
|
||||
default:
|
||||
if (MPlusActiveExt)
|
||||
{
|
||||
g_RegExt[g_ID][0xF1] = 0x01;
|
||||
g_RegExt[g_ID][0xF7] = 0x08; //init/calibration state flag
|
||||
|
||||
if (WiiMapping[g_ID].iExtensionConnected)
|
||||
{
|
||||
//I don't know what these are for: F6h,F8h, F9h. They seem necessary to be set to 0x00 instead of 0xFF(default),
|
||||
//when there's an extension connected to the MP
|
||||
g_RegExt[g_ID][0xF6] = 0x00;
|
||||
g_RegExt[g_ID][0xF8] = 0x00;
|
||||
g_RegExt[g_ID][0xF9] = 0x00;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//switch for invalid/valid data calibration (00/01)
|
||||
//switch for invalid/valid data calibration (0x00/0x01)
|
||||
case 0x00F1:
|
||||
if (g_RegExt[g_ID][0xFF] == 0x05) {
|
||||
g_RegExt[g_ID][0xF7] = 0x1A;
|
||||
if (MPlusActiveExt)
|
||||
{
|
||||
g_RegExt[g_ID][0xF7] = 0x1A; //syncing finished
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
//switch for triggering the calibration/syncing between wiimote and MP (corresponding data will be at 50h)
|
||||
case 0x00F2:
|
||||
if((g_RegExt[g_ID][0xFF] == 0x05) && (g_RegExt[g_ID][0xF7] < 0x0E)) {
|
||||
if(MPlusActiveExt && (g_RegExt[g_ID][0xF7] < 0x0E))
|
||||
{
|
||||
g_RegExt[g_ID][0xF7] = 0x0E;
|
||||
}
|
||||
break;
|
||||
|
||||
//case 0x00F3/0x00F4: //It'ss probably just the same as either F1/F2, needs more investigation tho,
|
||||
// but most likely just a different calibration sensitivity; wii sports resort does use it, but redsteel doesnt
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -649,48 +649,50 @@ int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address){
|
|||
case 0xA6:
|
||||
switch (address)
|
||||
{
|
||||
case 0x00FE:
|
||||
//Enabling WM+: swapping extension registers
|
||||
if ((data[0] == 0x04) || (data[0] == 0x05)) {
|
||||
if (g_RegMotionPlus[g_ID][0xFF] == 0x05) {
|
||||
//Enabling WM+: swapping extension registers
|
||||
case 0x00FE:
|
||||
if ((data[0] == 0x04) || (data[0] == 0x05))
|
||||
{
|
||||
if (!MPlusActiveExt)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: Enabling WM+ and swapping registers", data[0], addressHI, address);
|
||||
|
||||
//The WII will try to read from the A6 WM+ register directly after activation,
|
||||
//but we need to reply with an error each time as long the mp is still activate.
|
||||
//and we need to reply with an error each time as long the mp is still activate.
|
||||
//In addition, we need to sent 1-2 0x20 statusreports depending on if theres an extension connected to the MP or not.
|
||||
g_MotionPlusReadError[g_ID] = 0;
|
||||
|
||||
g_RegMotionPlus[g_ID][0xF7] = 0x08;
|
||||
g_RegMotionPlus[g_ID][0xFE] = data[0];
|
||||
g_MotionPlus[g_ID] = 1;
|
||||
SwapExtRegisters();
|
||||
|
||||
if (WiiMapping[g_ID].iExtensionConnected != EXT_NONE){
|
||||
g_RegExt[g_ID][0xF7] = 0x08; //Reset flag
|
||||
g_RegExt[g_ID][0xFE] = data[0];
|
||||
|
||||
if (WiiMapping[g_ID].iExtensionConnected != EXT_NONE)
|
||||
{
|
||||
g_RegExt[g_ID][0xF1] = 0x01;
|
||||
g_RegExt[g_ID][0xF6] = 0x00; // i dont knwo what these are for: F6h,F8h, F9h; but they are necessary to be set to 0x00 if theres a nunchuk/ext connected
|
||||
g_RegExt[g_ID][0xF6] = 0x00;
|
||||
g_RegExt[g_ID][0xF8] = 0x00;
|
||||
g_RegExt[g_ID][0xF9] = 0x00;
|
||||
return 1; // we need to issue 2 0x20 reports, if there's an extension connected to the MP
|
||||
}
|
||||
return 3; // we need to issue 1 0x20 report, if there's an extension connected to the MP
|
||||
return 3; // we need to issue 1 0x20 report, if there's no extension connected to the MP
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Writing [0x%02x] to [0x%02x:%04x]: WM already enabled no register swapping", data[0], addressHI, address);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x00F0: //Part of the WM+ init()
|
||||
//Part of the WM+ init()
|
||||
case 0x00F0:
|
||||
if (data[0] == 0x55) {
|
||||
|
||||
//if the wiimote is already active, we will init() the WM+ directly in the ExtReg, shouldnt happen usually
|
||||
if (g_RegExt[g_ID][0xFF] == 0x05) {
|
||||
//If the wiimote is already active, we will init() the WM+ directly in the ExtReg, shouldn't happen usually
|
||||
if (MPlusActiveExt)
|
||||
{
|
||||
g_RegExt[g_ID][0xFE] = 0x05;
|
||||
g_RegExt[g_ID][0xF7] = 0x08;//calibdata trigger
|
||||
g_RegExt[g_ID][0xF7] = 0x08;
|
||||
}
|
||||
if (WiiMapping[g_ID].iExtensionConnected == EXT_NONE)
|
||||
g_MotionPlus[g_ID] = 0;
|
||||
g_MotionPlus[g_ID] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -704,8 +706,8 @@ int HandlingMotionPlusWrites(u8* data, u8 addressHI, u32 address){
|
|||
}
|
||||
|
||||
//Swapping Ext/WM+-registers
|
||||
void SwapExtRegisters(){
|
||||
|
||||
void SwapExtRegisters()
|
||||
{
|
||||
memset(g_RegExtTmp, 0, sizeof(g_RegExtTmp));
|
||||
memcpy(g_RegExtTmp, g_RegExt[g_ID], sizeof(g_RegExt[0]));
|
||||
memset(g_RegExt[0], 0, sizeof(g_RegExt[0]));
|
||||
|
|
|
@ -1249,16 +1249,7 @@ void FillReportGuitarHero3Extension(wm_GH3_extension& _ext)
|
|||
pass-through mode supported for MotionPlus+Nunchuk */
|
||||
void FillReportMotionPlus(wm_extension& ext, bool extension){
|
||||
|
||||
//sending initial control packet, this must be sent first, its some kind of verification, all control bits are set to 0!(mp-mode only)
|
||||
if ((g_MotionPlusReadError[g_ID]) && (g_RegExt[g_ID][0xFE] == 0x05) && (!extension)) {
|
||||
// wont be not needed anymore, ill remove this if so next time
|
||||
memcpy(&ext, motionpluscheck_id, sizeof(motionpluscheck_id));
|
||||
|
||||
//g_MotionPlus[g_ID] = (extension) ? 1 : 0;
|
||||
g_MotionPlusReadError[g_ID] = 0;
|
||||
|
||||
} //nunchuk inserted
|
||||
else if (extension == 1) {
|
||||
if (extension == 1) {
|
||||
|
||||
switch (g_InterleavedData[g_ID])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue