LilyPad: DS3 no longer disconnects when vibrating. Partial workaround for a DirectInput threading issue when vibration is triggered at the same time devices are being added/removed - probably do something better at some point. Some other DS3 related changes - change names of some controls, increased sensitivity of boolean buttons values to more closely match the DS3 as well. Poorly calibrated analog axes bound to the d-pad (Or buttons) may cause issues.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1815 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
mattmenke 2009-09-13 04:55:58 +00:00
parent 8b0d0dba7b
commit c1f8444fe1
3 changed files with 22 additions and 15 deletions

View File

@ -108,6 +108,9 @@ public:
void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {
int index = 0;
if (!diEffects) {
return;
}
for (int port=0; port<2; port++) {
for (int slot=0; slot<4; slot++) {
unsigned int diff = binding - pads[port][slot].ffBindings;

View File

@ -154,6 +154,7 @@ public:
unsigned char getState[49];
OVERLAPPED readop;
OVERLAPPED writeop;
int writeCount;
int writeQueued;
int StartRead() {
@ -164,8 +165,8 @@ public:
int StartWrite() {
writeop.Offset = writeop.OffsetHigh = 0;
for (int i=0; i<2; i++) {
if (vibration[i^1]) {
sendState.motors[i].duration = 0x7F;
if ((i^writeCount)&1) {
sendState.motors[i].duration = 0x4F;
int force = vibration[i^1] * 256/FULLY_DOWN;
if (force > 255) force = 255;
sendState.motors[i].force = (unsigned char) force;
@ -175,11 +176,13 @@ public:
sendState.motors[i].duration = 0;
}
}
writeCount++;
int res = WriteFile(hFile, &sendState, sizeof(sendState), 0, &writeop);
return (res || GetLastError() == ERROR_IO_PENDING);
}
DualShock3Device(int index, wchar_t *name, wchar_t *path) : Device(DS3, OTHER, name, path) {
writeCount = 0;
memset(&readop, 0, sizeof(readop));
memset(&writeop, 0, sizeof(writeop));
memset(&sendState, 0, sizeof(sendState));
@ -200,8 +203,8 @@ public:
for (; i<20; i++) {
AddPhysicalControl(ABSAXIS, i, 0);
}
AddFFAxis(L"Slow Motor", 0);
AddFFAxis(L"Fast Motor", 1);
AddFFAxis(L"Big Motor", 0);
AddFFAxis(L"Small Motor", 1);
AddFFEffectType(L"Constant Effect", L"Constant", EFFECT_CONSTANT);
hFile = INVALID_HANDLE_VALUE;
}
@ -224,10 +227,10 @@ public:
L"Up",
L"Start",
L"Select",
L"Left Thumb X",
L"Left Thumb Y",
L"Right Thumb X",
L"Right Thumb Y",
L"L-Stick X",
L"L-Stick Y",
L"R-Stick X",
L"R-Stick Y",
};
unsigned int i = (unsigned int) (c - physicalControls);
if (i < 20) {
@ -296,7 +299,8 @@ public:
}
else if (res == WAIT_OBJECT_0+1) {
writeQueued--;
if (writeQueued) {
if (writeQueued | vibration[0] | vibration[1]) {
if (vibration[0] | vibration[1]) writeQueued = 3;
if (!StartWrite()) {
Deactivate();
return 0;

View File

@ -973,20 +973,20 @@ u8 CALLBACK PADpoll(u8 value) {
u8 b1 = 0xFF, b2 = 0xFF;
for (i = 0; i<4; i++) {
b1 -= (sum->buttons[i]>=0x30) << i;
b1 -= (sum->buttons[i]>=0x10) << i;
}
for (i = 0; i<8; i++) {
b2 -= (sum->buttons[i+4]>=0x30) << i;
b2 -= (sum->buttons[i+4]>=0x10) << i;
}
if (config.padConfigs[query.port][query.slot].type == GuitarPad && !config.GH2) {
sum->sticks[0].horiz = -255;
// Not sure about this. Forces wammy to be from 0 to 0x7F.
// if (sum->sticks[2].vert > 0) sum->sticks[2].vert = 0;
}
b1 -= ((sum->sticks[0].vert<=-0x30) << 4);
b1 -= ((sum->sticks[0].horiz>=0x30) << 5);
b1 -= ((sum->sticks[0].vert>=0x30) << 6);
b1 -= ((sum->sticks[0].horiz<=-0x30) << 7);
b1 -= ((sum->sticks[0].vert<=-0x10) << 4);
b1 -= ((sum->sticks[0].horiz>=0x10) << 5);
b1 -= ((sum->sticks[0].vert>=0x10) << 6);
b1 -= ((sum->sticks[0].horiz<=-0x10) << 7);
query.response[3] = b1;
query.response[4] = b2;