LilyPad: PADfreeze() now saves state of current poll, just in case it hasn't been completed. In practice, state never seems to be saved in the middle of a poll, but best to be safe.

Note that this "breaks" old LilyPad savestates, but that just means you'll need to wait for your pad to be initialized before loading older states for picky games, like you do when using states saved with other pad plugins.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@845 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
mattmenke 2009-03-27 06:58:00 +00:00
parent 007c34a8b0
commit 1df68eca73
3 changed files with 14 additions and 21 deletions

View File

@ -127,6 +127,9 @@ struct PadFreezeData {
u8 vibrate[8];
u8 umask[2];
// Vibration indices.
u8 vibrateI[2];
};
class Pad : public PadFreezeData {
@ -135,9 +138,6 @@ public:
int lockedState;
// Vibration indices.
u8 vibrateI[2];
// Last vibration value. Only used so as not to call vibration
// functions when old and new values are both 0.
u8 vibrateVal[2];
@ -387,7 +387,7 @@ void Update(unsigned int port, unsigned int slot) {
Device *dev = dm->devices[i];
// Skip both disabled devices and inactive enabled devices.
// Shouldn't be any of the latter, in general, but just in case...
if (!dev->virtualControlState) continue;
if (!dev->active) continue;
for (int port=0; port<2; port++) {
for (int slot=0; slot<4; slot++) {
if (config.padConfigs[port][slot].type == DisabledPad || !pads[port][slot].initialized) continue;
@ -1273,7 +1273,7 @@ keyEvent* CALLBACK PADkeyEvent() {
return &ev;
}
#define PAD_SAVE_STATE_VERSION 0
#define PAD_SAVE_STATE_VERSION 1
struct PadPluginFreezeData {
char format[8];
@ -1287,6 +1287,7 @@ struct PadPluginFreezeData {
u8 slot;
// Currently only use padData[0]. Save room for all 4 slots for simplicity.
PadFreezeData padData[4];
QueryInfo query;
};
s32 CALLBACK PADfreeze(int mode, freezeData *data) {
@ -1301,26 +1302,17 @@ s32 CALLBACK PADfreeze(int mode, freezeData *data) {
strcmp(pdata.format, "PadMode")) return 0;
unsigned int port = pdata.port;
if (port >= 2) return 0;
if (pdata.query.port == port) {
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;
}
pads[port][slot].mode = mode;
pads[port][slot].config = pdata.padData[slot].config;
pads[port][slot].modeLock = pdata.padData[slot].modeLock;
memcpy(pads[port][slot].umask, pdata.padData[slot].umask, sizeof(pads[port][slot].umask));
// Means I only have to have one chunk of code to parse vibrate info.
// Other plugins don't store it exactly, but think it's technically correct
// to do so, though I could be wrong.
slots[port] = slot;
PADstartPoll(port+1);
PADpoll(0x4D);
for (int j=0; j<7; j++) {
PADpoll(pdata.padData[slot].vibrate[j]);
}
// Note sure if the cast is strictly necessary, but feel safest with it there...
*(PadFreezeData*)&pads[port][slot] = pdata.padData[slot];
}
slots[port] = pdata.slot;
}
@ -1339,6 +1331,7 @@ s32 CALLBACK PADfreeze(int mode, freezeData *data) {
pdata.version = PAD_SAVE_STATE_VERSION;
pdata.port = port;
pdata.slot = slots[port];
pdata.query = query;
for (int slot=0; slot<4; slot++) {
pdata.padData[slot] = pads[port][slot];
}

View File

@ -80,7 +80,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Winmm.lib setupapi.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
OutputFile="..\..\bin\plugins\$(ProjectName).dll"
OutputFile="..\..\bin\plugins\$(ProjectName)-dbg.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateManifest="false"

View File

@ -21,7 +21,7 @@ __forceinline int ShortToAxis(int v) {
// If positive and at least 1 << 14, increment.
v += (!((v>>15)&1)) & ((v>>14)&1);
// Just double.
return v << 1;
return v * 2;
}
class XInputDevice : public Device {