mirror of https://github.com/PCSX2/pcsx2.git
Forum user ateste was so kind and found/fixed a savestate issue with Lilypad :)
The problem would cause lost controls or "Controller disconnected" messages in a few games. This fix is temporary and only works with Lilypad, until we take care of the core issue. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4959 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
66db797478
commit
c234e1f6dd
|
@ -20,7 +20,7 @@
|
||||||
#define FORCE_UPDATE_LPARAM ((LPARAM)0x89437437)
|
#define FORCE_UPDATE_LPARAM ((LPARAM)0x89437437)
|
||||||
|
|
||||||
// LilyPad version.
|
// LilyPad version.
|
||||||
#define VERSION ((0<<8) | 10 | (0<<24))
|
#define VERSION ((0<<8) | 11 | (0<<24))
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
@ -135,7 +135,7 @@ struct ButtonSum {
|
||||||
Stick sticks[3];
|
Stick sticks[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PAD_SAVE_STATE_VERSION 2
|
#define PAD_SAVE_STATE_VERSION 3
|
||||||
|
|
||||||
// Freeze data, for a single pad. Basically has all pad state that
|
// Freeze data, for a single pad. Basically has all pad state that
|
||||||
// a PS2 can set.
|
// a PS2 can set.
|
||||||
|
@ -1414,69 +1414,80 @@ keyEvent* CALLBACK PADkeyEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PadPluginFreezeData {
|
struct PadPluginFreezeData {
|
||||||
char format[8];
|
char format[8];
|
||||||
// Currently all different versions are incompatible.
|
// Currently all different versions are incompatible.
|
||||||
// May split into major/minor with some compatibility rules.
|
// May split into major/minor with some compatibility rules.
|
||||||
u32 version;
|
u32 version;
|
||||||
// So when loading, know which plugin's settings I'm loading.
|
// So when loading, know which plugin's settings I'm loading.
|
||||||
// Not a big deal. Use a static variable when saving to figure it out.
|
// Not a big deal. Use a static variable when saving to figure it out.
|
||||||
u8 port;
|
u8 port;
|
||||||
// active slot for port
|
// active slot for port
|
||||||
u8 slot;
|
u8 slot[2];
|
||||||
PadFreezeData padData[4];
|
PadFreezeData padData[2][4];
|
||||||
QueryInfo query;
|
QueryInfo query;
|
||||||
};
|
};
|
||||||
|
|
||||||
s32 CALLBACK PADfreeze(int mode, freezeData *data) {
|
s32 CALLBACK PADfreeze(int mode, freezeData *data) {
|
||||||
if (mode == FREEZE_SIZE) {
|
if (mode == FREEZE_SIZE) {
|
||||||
data->size = sizeof(PadPluginFreezeData);
|
data->size = sizeof(PadPluginFreezeData);
|
||||||
}
|
}
|
||||||
else if (mode == FREEZE_LOAD) {
|
else if (mode == FREEZE_LOAD) {
|
||||||
PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data);
|
PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data);
|
||||||
StopVibrate();
|
StopVibrate();
|
||||||
if (data->size != sizeof(PadPluginFreezeData) ||
|
if (data->size != sizeof(PadPluginFreezeData) ||
|
||||||
pdata.version != PAD_SAVE_STATE_VERSION ||
|
pdata.version != PAD_SAVE_STATE_VERSION ||
|
||||||
strcmp(pdata.format, "PadMode")) return 0;
|
strcmp(pdata.format, "PadMode")) return 0;
|
||||||
unsigned int port = pdata.port;
|
|
||||||
if (port >= 2) return 0;
|
|
||||||
if (pdata.query.port == port && pdata.query.slot < 4) {
|
|
||||||
query = pdata.query;
|
|
||||||
}
|
|
||||||
for (int slot=0; slot<4; slot++) {
|
|
||||||
u8 mode = pdata.padData[slot].mode;
|
|
||||||
if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not sure if the cast is strictly necessary, but feel safest with it there...
|
if( pdata.port >= 2 ) return 0;
|
||||||
*(PadFreezeData*)&pads[port][slot] = pdata.padData[slot];
|
|
||||||
}
|
query = pdata.query;
|
||||||
if (pdata.slot < 4)
|
if (pdata.query.slot < 4) {
|
||||||
slots[port] = pdata.slot;
|
query = pdata.query;
|
||||||
}
|
}
|
||||||
else if (mode == FREEZE_SAVE) {
|
|
||||||
if (data->size != sizeof(PadPluginFreezeData)) return 0;
|
// Tales of the Abyss - pad fix
|
||||||
PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data);
|
// - restore data for both ports
|
||||||
static int nextPort = 0;
|
for (int port=0; port<2; port++) {
|
||||||
if (!portInitialized[nextPort]) nextPort ^= 1;
|
for (int slot=0; slot<4; slot++) {
|
||||||
int port = nextPort;
|
u8 mode = pdata.padData[port][slot].mode;
|
||||||
if (!portInitialized[nextPort^1]) nextPort = 0;
|
|
||||||
else nextPort ^= 1;
|
if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not sure if the cast is strictly necessary, but feel safest with it there...
|
||||||
|
*(PadFreezeData*)&pads[port][slot] = pdata.padData[port][slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdata.slot[port] < 4)
|
||||||
|
slots[port] = pdata.slot[port];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mode == FREEZE_SAVE) {
|
||||||
|
if (data->size != sizeof(PadPluginFreezeData)) return 0;
|
||||||
|
PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data);
|
||||||
|
|
||||||
|
|
||||||
memset(&pdata, 0, sizeof(pdata));
|
// Tales of the Abyss - pad fix
|
||||||
strcpy(pdata.format, "PadMode");
|
// - PCSX2 only saves port0 (save #1), then port1 (save #2)
|
||||||
pdata.version = PAD_SAVE_STATE_VERSION;
|
|
||||||
pdata.port = port;
|
memset(&pdata, 0, sizeof(pdata));
|
||||||
pdata.slot = slots[port];
|
strcpy(pdata.format, "PadMode");
|
||||||
pdata.query = query;
|
pdata.version = PAD_SAVE_STATE_VERSION;
|
||||||
for (int slot=0; slot<4; slot++) {
|
pdata.port = 0;
|
||||||
pdata.padData[slot] = pads[port][slot];
|
pdata.query = query;
|
||||||
}
|
|
||||||
}
|
for (int port=0; port<2; port++) {
|
||||||
else return -1;
|
for (int slot=0; slot<4; slot++) {
|
||||||
return 0;
|
pdata.padData[port][slot] = pads[port][slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdata.slot[port] = slots[port];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
u32 CALLBACK PADreadPort1 (PadDataS* pads) {
|
u32 CALLBACK PADreadPort1 (PadDataS* pads) {
|
||||||
PADstartPoll(1);
|
PADstartPoll(1);
|
||||||
|
|
Loading…
Reference in New Issue