mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-11-16 19:14:18 +01:00
LilyPad: Lots of new code that (ideally) makes absolutely no difference. And a fix for saving rumble settings in PADfreeze.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@794 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
1 parent
3f87ae7078
commit
0c95bbc9fd
10 files changed
+716
-595
No files matched your search
@@ -98,9 +98,17 @@ public:
|
||||
}
|
||||
|
||||
void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {
|
||||
unsigned int index = binding - pads[0].ffBindings;
|
||||
if (index >= (unsigned int)pads[0].numFFBindings) {
|
||||
index = pads[0].numFFBindings + (binding - pads[1].ffBindings);
|
||||
int index = 0;
|
||||
for (int port=0; port<2; port++) {
|
||||
for (int slot=0; slot<4; slot++) {
|
||||
unsigned int diff = binding - pads[port][slot].ffBindings;
|
||||
if (diff < (unsigned int)pads[port][slot].numFFBindings) {
|
||||
index += diff;
|
||||
port = 2;
|
||||
break;
|
||||
}
|
||||
index += pads[port][slot].numFFBindings;
|
||||
}
|
||||
}
|
||||
IDirectInputEffect *die = diEffects[index].die;
|
||||
if (die) {
|
||||
@@ -139,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
int Activate(void *d) {
|
||||
int i, j;
|
||||
int i;
|
||||
IDirectInput8 *di8 = GetDirectInput();
|
||||
Deactivate();
|
||||
if (!di8) return 0;
|
||||
@@ -211,74 +219,78 @@ public:
|
||||
return 0;
|
||||
}
|
||||
AllocState();
|
||||
diEffects = (DI8Effect*) calloc(pads[0].numFFBindings + pads[1].numFFBindings, sizeof(DI8Effect));
|
||||
for (i=0; i<pads[0].numFFBindings + pads[1].numFFBindings; i++) {
|
||||
ForceFeedbackBinding *b = 0;
|
||||
if (i >= pads[0].numFFBindings) {
|
||||
b = &pads[1].ffBindings[i-pads[0].numFFBindings];
|
||||
}
|
||||
else
|
||||
b = &pads[0].ffBindings[i];
|
||||
ForceFeedbackEffectType *eff = ffEffectTypes + b->effectIndex;
|
||||
GUID guid;
|
||||
if (!StringToGUID(&guid, eff->effectID)) continue;
|
||||
int count = GetFFBindingCount();
|
||||
diEffects = (DI8Effect*) calloc(count, sizeof(DI8Effect));
|
||||
i = 0;
|
||||
for (int port=0; port<2; port++) {
|
||||
for (int slot=0; slot<4; slot++) {
|
||||
int subIndex = i;
|
||||
for (int j=0; j<pads[port][slot].numFFBindings; j++) {
|
||||
ForceFeedbackBinding *b = 0;
|
||||
b = &pads[port][slot].ffBindings[i-subIndex];
|
||||
ForceFeedbackEffectType *eff = ffEffectTypes + b->effectIndex;
|
||||
GUID guid;
|
||||
if (!StringToGUID(&guid, eff->effectID)) continue;
|
||||
|
||||
DIEFFECT dieffect;
|
||||
memset(&dieffect, 0, sizeof(dieffect));
|
||||
dieffect.dwSize = sizeof(dieffect);
|
||||
dieffect.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTIDS;
|
||||
dieffect.dwDuration = 2000000;
|
||||
dieffect.dwGain = 10000;
|
||||
dieffect.dwTriggerButton = DIEB_NOTRIGGER;
|
||||
union {
|
||||
DIPERIODIC pediodic;
|
||||
DIRAMPFORCE ramp;
|
||||
DICONSTANTFORCE constant;
|
||||
} stuff = {0,0,0,0};
|
||||
DIEFFECT dieffect;
|
||||
memset(&dieffect, 0, sizeof(dieffect));
|
||||
dieffect.dwSize = sizeof(dieffect);
|
||||
dieffect.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTIDS;
|
||||
dieffect.dwDuration = 2000000;
|
||||
dieffect.dwGain = 10000;
|
||||
dieffect.dwTriggerButton = DIEB_NOTRIGGER;
|
||||
union {
|
||||
DIPERIODIC pediodic;
|
||||
DIRAMPFORCE ramp;
|
||||
DICONSTANTFORCE constant;
|
||||
} stuff = {0,0,0,0};
|
||||
|
||||
if (eff->type == EFFECT_CONSTANT) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
|
||||
}
|
||||
else if (eff->type == EFFECT_PERIODIC) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DIPERIODIC);
|
||||
}
|
||||
else if (eff->type == EFFECT_RAMP) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DIRAMPFORCE);
|
||||
}
|
||||
dieffect.lpvTypeSpecificParams = &stuff;
|
||||
|
||||
int maxForce = 0;
|
||||
int numAxes = 0;
|
||||
int *axes = (int*) malloc(sizeof(int) * 3 * numFFAxes);
|
||||
DWORD *axisIDs = (DWORD*)(axes + numFFAxes);
|
||||
LONG *dirList = (LONG*)(axisIDs + numFFAxes);
|
||||
dieffect.rgdwAxes = axisIDs;
|
||||
dieffect.rglDirection = dirList;
|
||||
for (j=0; j<numFFAxes; j++) {
|
||||
if (b->axes[j].force) {
|
||||
int force = abs(b->axes[j].force);
|
||||
if (force > maxForce) {
|
||||
maxForce = force;
|
||||
if (eff->type == EFFECT_CONSTANT) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
|
||||
}
|
||||
axes[numAxes] = j;
|
||||
axisIDs[numAxes] = ffAxes[j].id;
|
||||
dirList[numAxes] = b->axes[j].force;
|
||||
numAxes++;
|
||||
else if (eff->type == EFFECT_PERIODIC) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DIPERIODIC);
|
||||
}
|
||||
else if (eff->type == EFFECT_RAMP) {
|
||||
dieffect.cbTypeSpecificParams = sizeof(DIRAMPFORCE);
|
||||
}
|
||||
dieffect.lpvTypeSpecificParams = &stuff;
|
||||
|
||||
int maxForce = 0;
|
||||
int numAxes = 0;
|
||||
int *axes = (int*) malloc(sizeof(int) * 3 * numFFAxes);
|
||||
DWORD *axisIDs = (DWORD*)(axes + numFFAxes);
|
||||
LONG *dirList = (LONG*)(axisIDs + numFFAxes);
|
||||
dieffect.rgdwAxes = axisIDs;
|
||||
dieffect.rglDirection = dirList;
|
||||
for (int k=0; k<numFFAxes; k++) {
|
||||
if (b->axes[k].force) {
|
||||
int force = abs(b->axes[k].force);
|
||||
if (force > maxForce) {
|
||||
maxForce = force;
|
||||
}
|
||||
axes[numAxes] = k;
|
||||
axisIDs[numAxes] = ffAxes[k].id;
|
||||
dirList[numAxes] = b->axes[k].force;
|
||||
numAxes++;
|
||||
}
|
||||
}
|
||||
if (!numAxes) {
|
||||
free(axes);
|
||||
continue;
|
||||
}
|
||||
dieffect.cAxes = numAxes;
|
||||
diEffects[i].scale = maxForce;
|
||||
if (!SUCCEEDED(did->CreateEffect(guid, &dieffect, &diEffects[i].die, 0))) {
|
||||
diEffects[i].die = 0;
|
||||
diEffects[i].scale = 0;
|
||||
}
|
||||
|
||||
free(axes);
|
||||
axes = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!numAxes) {
|
||||
free(axes);
|
||||
continue;
|
||||
}
|
||||
dieffect.cAxes = numAxes;
|
||||
diEffects[i].scale = maxForce;
|
||||
if (!SUCCEEDED(did->CreateEffect(guid, &dieffect, &diEffects[i].die, 0))) {
|
||||
diEffects[i].die = 0;
|
||||
diEffects[i].scale = 0;
|
||||
}
|
||||
|
||||
free(axes);
|
||||
axes = 0;
|
||||
}
|
||||
active = 1;
|
||||
return 1;
|
||||
@@ -306,10 +318,21 @@ public:
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFFBindingCount() {
|
||||
int count = 0;
|
||||
for (int port = 0; port<2; port++) {
|
||||
for (int slot = 0; slot<4; slot++) {
|
||||
count += pads[port][slot].numFFBindings;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void Deactivate() {
|
||||
FreeState();
|
||||
if (diEffects) {
|
||||
for (int i=0; i<pads[0].numFFBindings + pads[1].numFFBindings; i++) {
|
||||
int count = GetFFBindingCount();
|
||||
for (int i=0; i<count; i++) {
|
||||
if (diEffects[i].die) {
|
||||
diEffects[i].die->Stop();
|
||||
diEffects[i].die->Release();
|
||||
|
||||
Reference in new issue
Block a user