From 0c95bbc9fdf069dc4516e71ca61750da837c5437 Mon Sep 17 00:00:00 2001 From: mattmenke Date: Sun, 15 Mar 2009 15:00:22 +0000 Subject: [PATCH] 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 --- plugins/LilyPad/Config.cpp | 510 ++++++++++++++++++------------- plugins/LilyPad/Config.h | 16 +- plugins/LilyPad/DirectInput.cpp | 159 +++++----- plugins/LilyPad/InputManager.cpp | 102 ++++--- plugins/LilyPad/InputManager.h | 6 +- plugins/LilyPad/KeyboardHook.cpp | 4 +- plugins/LilyPad/LilyPad.cpp | 450 +++++++++++++-------------- plugins/LilyPad/LilyPad.rc | 22 +- plugins/LilyPad/XInput.cpp | 28 +- plugins/LilyPad/resource.h | 14 +- 10 files changed, 716 insertions(+), 595 deletions(-) diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp index f384f726da..e3ce0d465f 100644 --- a/plugins/LilyPad/Config.cpp +++ b/plugins/LilyPad/Config.cpp @@ -29,10 +29,10 @@ HWND hWndProp = 0; int selected = 0; -HWND hWnds[2] = {0,0}; +HWND hWnds[2][4]; HWND hWndGeneral = 0; -void Populate(int pad); +void Populate(int port, int slot); void SetupLogSlider(HWND hWndSlider) { SendMessage(hWndSlider, TBM_SETRANGEMIN, 0, 1); @@ -173,16 +173,17 @@ void RefreshEnabledDevicesAndDisplay(int updateDeviceList = 0, HWND hWnd = 0, in } } if (populate) { - Populate(0); - Populate(1); + for (int i=0; i<8; i++) { + Populate(i&1, i>>1); + } } } -wchar_t *GetCommandStringW(u8 command, int pad) { +wchar_t *GetCommandStringW(u8 command, int port, int slot) { static wchar_t temp[34]; if (command >= 0x20 && command <= 0x27) { - if (config.guitar[pad] && (command == 0x20 || command == 0x22)) { - HWND hWnd = GetDlgItem(hWnds[pad], 0x10F0+command); + if (config.padConfigs[port][slot].type == GuitarPad && (command == 0x20 || command == 0x22)) { + HWND hWnd = GetDlgItem(hWnds[port][slot], 0x10F0+command); int res = GetWindowTextW(hWnd, temp, 20); if ((unsigned int)res-1 <= 18) return temp; } @@ -195,7 +196,7 @@ wchar_t *GetCommandStringW(u8 command, int pad) { } /* Get text from the buttons. */ if (command >= 0x0C && command <=0x28) { - HWND hWnd = GetDlgItem(hWnds[pad], 0x10F0+command); + HWND hWnd = GetDlgItem(hWnds[port][slot], 0x10F0+command); if (!hWnd) { wchar_t *strings[] = { L"Lock Buttons", @@ -243,13 +244,13 @@ inline void GetSettingsFileName(wchar_t *out) { wcscpy(out, L"inis\\LilyPad.ini"); } -int GetBinding(int pad, int index, Device *&dev, Binding *&b, ForceFeedbackBinding *&ffb); -int BindCommand(Device *dev, unsigned int uid, unsigned int pad, int command, int sensitivity, int turbo); +int GetBinding(int port, int slot, int index, Device *&dev, Binding *&b, ForceFeedbackBinding *&ffb); +int BindCommand(Device *dev, unsigned int uid, unsigned int port, unsigned int slot, int command, int sensitivity, int turbo); -int CreateEffectBinding(Device *dev, wchar_t *effectName, unsigned int pad, unsigned int motor, ForceFeedbackBinding **binding); +int CreateEffectBinding(Device *dev, wchar_t *effectName, unsigned int port, unsigned int slot, unsigned int motor, ForceFeedbackBinding **binding); -void SelChanged(int pad) { - HWND hWnd = hWnds[pad]; +void SelChanged(int port, int slot) { + HWND hWnd = hWnds[port][slot]; if (!hWnd) return; HWND hWndTemp, hWndList = GetDlgItem(hWnd, IDC_LIST); int j, i = ListView_GetSelectedCount(hWndList); @@ -308,7 +309,7 @@ void SelChanged(int pad) { devName = temp[0]; key = temp[1]; command = temp[2]; - if (GetBinding(pad, index, dev, b, ffb)) { + if (GetBinding(port, slot, index, dev, b, ffb)) { if (b) { bFound ++; VirtualControl *control = &dev->virtualControls[b->controlIndex]; @@ -466,40 +467,40 @@ void UnselectAll(HWND hWnd) { } -int GetItemIndex(int pad, Device *dev, ForceFeedbackBinding *binding) { +int GetItemIndex(int port, int slot, Device *dev, ForceFeedbackBinding *binding) { int count = 0; for (int i = 0; inumDevices; i++) { Device *dev2 = dm->devices[i]; if (!dev2->enabled) continue; if (dev2 != dev) { - count += dev2->pads[pad].numBindings + dev2->pads[pad].numFFBindings; + count += dev2->pads[port][slot].numBindings + dev2->pads[port][slot].numFFBindings; continue; } - return count += dev2->pads[pad].numBindings + (binding - dev2->pads[pad].ffBindings); + return count += dev2->pads[port][slot].numBindings + (binding - dev2->pads[port][slot].ffBindings); } return -1; } -int GetItemIndex(int pad, Device *dev, Binding *binding) { +int GetItemIndex(int port, int slot, Device *dev, Binding *binding) { int count = 0; for (int i = 0; inumDevices; i++) { Device *dev2 = dm->devices[i]; if (!dev2->enabled) continue; if (dev2 != dev) { - count += dev2->pads[pad].numBindings + dev2->pads[pad].numFFBindings; + count += dev2->pads[port][slot].numBindings + dev2->pads[port][slot].numFFBindings; continue; } - return count += binding - dev->pads[pad].bindings; + return count += binding - dev->pads[port][slot].bindings; } return -1; } // Doesn't check if already displayed. -int ListBoundCommand(int pad, Device *dev, Binding *b) { - if (!hWnds[pad]) return -1; - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); +int ListBoundCommand(int port, int slot, Device *dev, Binding *b) { + if (!hWnds[port][slot]) return -1; + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); int index = -1; if (hWndList) { - index = GetItemIndex(pad, dev, b); + index = GetItemIndex(port, slot, dev, b); if (index >= 0) { LVITEM item; item.mask = LVIF_TEXT; @@ -512,19 +513,19 @@ int ListBoundCommand(int pad, Device *dev, Binding *b) { item.pszText = dev->GetVirtualControlName(&dev->virtualControls[b->controlIndex]); SendMessage(hWndList, LVM_SETITEM, 0, (LPARAM)&item); item.iSubItem = 2; - item.pszText = GetCommandStringW(b->command, pad); + item.pszText = GetCommandStringW(b->command, port, slot); SendMessage(hWndList, LVM_SETITEM, 0, (LPARAM)&item); } } return index; } -int ListBoundEffect(int pad, Device *dev, ForceFeedbackBinding *b) { - if (!hWnds[pad]) return -1; - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); +int ListBoundEffect(int port, int slot, Device *dev, ForceFeedbackBinding *b) { + if (!hWnds[port][slot]) return -1; + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); int index = -1; if (hWndList) { - index = GetItemIndex(pad, dev, b); + index = GetItemIndex(port, slot, dev, b); if (index >= 0) { LVITEM item; item.mask = LVIF_TEXT; @@ -546,9 +547,9 @@ int ListBoundEffect(int pad, Device *dev, ForceFeedbackBinding *b) { } // Only for use with control bindings. Affects all highlighted bindings. -void ChangeValue(int pad, int *newSensitivity, int *turbo) { - if (!hWnds[pad]) return; - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); +void ChangeValue(int port, int slot, int *newSensitivity, int *turbo) { + if (!hWnds[port][slot]) return; + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); int count = ListView_GetSelectedCount(hWndList); if (count < 1) return; int index = -1; @@ -558,7 +559,7 @@ void ChangeValue(int pad, int *newSensitivity, int *turbo) { Device *dev; Binding *b; ForceFeedbackBinding *ffb; - if (!GetBinding(pad, index, dev, b, ffb) || ffb) return; + if (!GetBinding(port, slot, index, dev, b, ffb) || ffb) return; if (newSensitivity) { // Don't change flip state when modifying multiple controls. if (count > 1 && b->sensitivity < 0) @@ -570,21 +571,21 @@ void ChangeValue(int pad, int *newSensitivity, int *turbo) { b->turbo = *turbo; } } - PropSheet_Changed(hWndProp, hWnds[pad]); - SelChanged(pad); + PropSheet_Changed(hWndProp, hWnds[port][slot]); + SelChanged(port, slot); } // Only for use with effect bindings. -void ChangeEffect(int pad, int id, int *newForce, unsigned int *newEffectType) { - if (!hWnds[pad]) return; - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); +void ChangeEffect(int port, int slot, int id, int *newForce, unsigned int *newEffectType) { + if (!hWnds[port][slot]) return; + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); int i = ListView_GetSelectedCount(hWndList); if (i != 1) return; int index = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); Device *dev; Binding *b; ForceFeedbackBinding *ffb; - if (!GetBinding(pad, index, dev, b, ffb) || b) return; + if (!GetBinding(port, slot, index, dev, b, ffb) || b) return; if (newForce) { unsigned int axisIndex = (id - IDC_FF_AXIS1_ENABLED)/16; if (axisIndex < (unsigned int)dev->numFFAxes) { @@ -594,18 +595,18 @@ void ChangeEffect(int pad, int id, int *newForce, unsigned int *newEffectType) { if (newEffectType && *newEffectType < (unsigned int)dev->numFFEffectTypes) { ffb->effectIndex = *newEffectType; ListView_DeleteItem(hWndList, index); - index = ListBoundEffect(pad, dev, ffb); + index = ListBoundEffect(port, slot, dev, ffb); ListView_SetItemState(hWndList, index, LVIS_SELECTED, LVIS_SELECTED); } - PropSheet_Changed(hWndProp, hWnds[pad]); - SelChanged(pad); + PropSheet_Changed(hWndProp, hWnds[port][slot]); + SelChanged(port, slot); } -void Populate(int pad) { - if (!hWnds[pad]) return; - HWND hWnd = GetDlgItem(hWnds[pad], IDC_LIST); +void Populate(int port, int slot) { + if (!hWnds[port][slot]) return; + HWND hWnd = GetDlgItem(hWnds[port][slot], IDC_LIST); ListView_DeleteAllItems(hWnd); int i, j; @@ -614,16 +615,16 @@ void Populate(int pad) { for (j=0; jnumDevices; j++) { Device *dev = dm->devices[j]; if (!dev->enabled) continue; - for (i=0; ipads[pad].numBindings; i++) { - ListBoundCommand(pad, dev, dev->pads[pad].bindings+i); + for (i=0; ipads[port][slot].numBindings; i++) { + ListBoundCommand(port, slot, dev, dev->pads[port][slot].bindings+i); } - for (i=0; ipads[pad].numFFBindings; i++) { - ListBoundEffect(pad, dev, dev->pads[pad].ffBindings+i); + for (i=0; ipads[port][slot].numFFBindings; i++) { + ListBoundEffect(port, slot, dev, dev->pads[port][slot].ffBindings+i); } } config.multipleBinding = multipleBinding; - hWnd = GetDlgItem(hWnds[pad], IDC_FORCEFEEDBACK); + hWnd = GetDlgItem(hWnds[port][slot], IDC_FORCEFEEDBACK); SendMessage(hWnd, CB_RESETCONTENT, 0, 0); int added = 0; for (i=0; inumDevices; i++) { @@ -636,10 +637,10 @@ void Populate(int pad) { } SendMessage(hWnd, CB_SETCURSEL, 0, 0); EnableWindow(hWnd, added!=0); - EnableWindow(GetDlgItem(hWnds[pad], ID_BIG_MOTOR), added!=0); - EnableWindow(GetDlgItem(hWnds[pad], ID_SMALL_MOTOR), added!=0); + EnableWindow(GetDlgItem(hWnds[port][slot], ID_BIG_MOTOR), added!=0); + EnableWindow(GetDlgItem(hWnds[port][slot], ID_SMALL_MOTOR), added!=0); - SelChanged(pad); + SelChanged(port, slot); } int WritePrivateProfileInt(wchar_t *s1, wchar_t *s2, int v, wchar_t *ini) { @@ -696,8 +697,6 @@ int SaveSettings(wchar_t *file=0) { WritePrivateProfileInt(L"General Settings", L"Disable Screen Saver", config.disableScreenSaver, file); WritePrivateProfileInt(L"General Settings", L"GH2", config.GH2, file); WritePrivateProfileInt(L"General Settings", L"Mouse Unfocus", config.mouseUnfocus, file); - WritePrivateProfileInt(L"General Settings", L"Pad1 Disable", config.disablePad[0], file); - WritePrivateProfileInt(L"General Settings", L"Pad2 Disable", config.disablePad[1], file); WritePrivateProfileInt(L"General Settings", L"Logging", config.debug, file); WritePrivateProfileInt(L"General Settings", L"Keyboard Mode", config.keyboardApi, file); WritePrivateProfileInt(L"General Settings", L"Mouse Mode", config.mouseApi, file); @@ -710,10 +709,14 @@ int SaveSettings(wchar_t *file=0) { WritePrivateProfileInt(L"General Settings", L"Vista Volume", config.vistaVolume, file); WritePrivateProfileInt(L"General Settings", L"Volume", config.volume, file); - WritePrivateProfileInt(L"Pad1", L"Guitar", config.guitar[0], file); - WritePrivateProfileInt(L"Pad2", L"Guitar", config.guitar[1], file); - WritePrivateProfileInt(L"Pad1", L"Auto Analog", config.AutoAnalog[0], file); - noError &= WritePrivateProfileInt(L"Pad2", L"Auto Analog", config.AutoAnalog[1], file); + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + wchar_t temp[50]; + wsprintf(temp, L"Pad %i %i", port, slot); + WritePrivateProfileInt(temp, L"Mode", config.padConfigs[port][slot].type, file); + noError &= WritePrivateProfileInt(temp, L"Auto Analog", config.padConfigs[port][slot].autoAnalog, file); + } + } for (int i=0; inumDevices; i++) { wchar_t id[50]; @@ -734,29 +737,29 @@ int SaveSettings(wchar_t *file=0) { } WritePrivateProfileInt(id, L"API", dev->api, file); WritePrivateProfileInt(id, L"Type", dev->type, file); + int ffBindingCount = 0; int bindingCount = 0; - for (int pad=0; pad<2; pad++) { - for (int j=0; jpads[pad].numBindings; j++) { - Binding *b = dev->pads[pad].bindings+j; - VirtualControl *c = &dev->virtualControls[b->controlIndex]; - wsprintfW(temp, L"Binding %i", bindingCount++); - wsprintfW(temp2, L"0x%08X, %i, %i, %i, %i", c->uid, pad, b->command, b->sensitivity, b->turbo); - noError &= WritePrivateProfileStringW(id, temp, temp2, file); - } - } - bindingCount = 0; - for (int pad=0; pad<2; pad++) { - for (int j=0; jpads[pad].numFFBindings; j++) { - ForceFeedbackBinding *b = dev->pads[pad].ffBindings+j; - ForceFeedbackEffectType *eff = &dev->ffEffectTypes[b->effectIndex]; - wsprintfW(temp, L"FF Binding %i", bindingCount++); - wsprintfW(temp2, L"%s %i, %i", eff->effectID, pad, b->motor); - for (int k=0; knumFFAxes; k++) { - ForceFeedbackAxis *axis = dev->ffAxes + k; - AxisEffectInfo *info = b->axes + k; - wsprintfW(wcschr(temp2,0), L", %i, %i", axis->id, info->force); + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + for (int j=0; jpads[port][slot].numBindings; j++) { + Binding *b = dev->pads[port][slot].bindings+j; + VirtualControl *c = &dev->virtualControls[b->controlIndex]; + wsprintfW(temp, L"Binding %i", bindingCount++); + wsprintfW(temp2, L"0x%08X, %i, %i, %i, %i, %i", c->uid, port, b->command, b->sensitivity, b->turbo, slot); + noError &= WritePrivateProfileStringW(id, temp, temp2, file); + } + for (int j=0; jpads[port][slot].numFFBindings; j++) { + ForceFeedbackBinding *b = dev->pads[port][slot].ffBindings+j; + ForceFeedbackEffectType *eff = &dev->ffEffectTypes[b->effectIndex]; + wsprintfW(temp, L"FF Binding %i", ffBindingCount++); + wsprintfW(temp2, L"%s %i, %i, %i", eff->effectID, port, b->motor, slot); + for (int k=0; knumFFAxes; k++) { + ForceFeedbackAxis *axis = dev->ffAxes + k; + AxisEffectInfo *info = b->axes + k; + wsprintfW(wcschr(temp2,0), L", %i, %i", axis->id, info->force); + } + noError &= WritePrivateProfileStringW(id, temp, temp2, file); } - noError &= WritePrivateProfileStringW(id, temp, temp2, file); } } } @@ -814,8 +817,6 @@ int LoadSettings(int force, wchar_t *file) { config.closeHacks = (u8)GetPrivateProfileIntW(L"General Settings", L"Close Hacks", 0, file); if (config.closeHacks&1) config.closeHacks &= ~2; - config.disablePad[0] = GetPrivateProfileBool(L"General Settings", L"Pad1 Disable", 0, file); - config.disablePad[1] = GetPrivateProfileBool(L"General Settings", L"Pad2 Disable", 0, file); config.debug = GetPrivateProfileBool(L"General Settings", L"Logging", 0, file); config.multipleBinding = GetPrivateProfileBool(L"General Settings", L"Multiple Bindings", 0, file); config.forceHide = GetPrivateProfileBool(L"General Settings", L"Force Cursor Hide", 0, file); @@ -850,11 +851,15 @@ int LoadSettings(int force, wchar_t *file) { else CreateDirectory(L"logs", 0); } - const int slot = 1; - config.guitar[0] = GetPrivateProfileBool(L"Pad1", L"Guitar", 0, file); - config.guitar[1] = GetPrivateProfileBool(L"Pad2", L"Guitar", 0, file); - config.AutoAnalog[0] = GetPrivateProfileBool(L"Pad1", L"Auto Analog", 0, file); - config.AutoAnalog[1] = GetPrivateProfileBool(L"Pad2", L"Auto Analog", 0, file); + + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + wchar_t temp[50]; + wsprintf(temp, L"Pad %i %i", port, slot); + config.padConfigs[port][slot].type = (PadType) GetPrivateProfileInt(temp, L"Mode", Dualshock2Pad, file); + config.padConfigs[port][slot].autoAnalog = GetPrivateProfileBool(temp, L"Auto Analog", 0, file); + } + } loaded = 1; @@ -895,7 +900,7 @@ int LoadSettings(int force, wchar_t *file) { } last = 1; unsigned int uid; - int pad, command, sensitivity, turbo; + int port, command, sensitivity, turbo, slot = 0; int w = 0; char string[1000]; while (temp2[w]) { @@ -903,11 +908,12 @@ int LoadSettings(int force, wchar_t *file) { w++; } string[w] = 0; - if (sscanf(string, " %i , %i , %i , %i , %i", &uid, &pad, &command, &sensitivity, &turbo) == 5 && type) { + int len = sscanf(string, " %i , %i , %i , %i , %i , %i", &uid, &port, &command, &sensitivity, &turbo, &slot); + if (len >= 5 && type) { VirtualControl *c = dev->GetVirtualControl(uid); if (!c) c = dev->AddVirtualControl(uid, -1); if (c) { - BindCommand(dev, uid, pad, command, sensitivity, turbo); + BindCommand(dev, uid, port, slot, command, sensitivity, turbo); } } } @@ -922,7 +928,7 @@ int LoadSettings(int force, wchar_t *file) { continue; } last = 1; - int pad, motor; + int port, slot, motor; int w = 0; char string[1000]; char effect[1000]; @@ -933,8 +939,8 @@ int LoadSettings(int force, wchar_t *file) { string[w] = 0; // wcstok not in ntdll. More effore than its worth to shave off // whitespace without it. - if (sscanf(string, " %s %i , %i", effect, &pad, &motor) == 3) { - char *s = strchr(strchr(string, ',')+1, ','); + if (sscanf(string, " %s %i , %i , %i", effect, &port, &motor, &slot) == 4) { + char *s = strchr(strchr(strchr(string, ',')+1, ',')+1, ','); if (!s) continue; s++; w = 0; @@ -951,7 +957,7 @@ int LoadSettings(int force, wchar_t *file) { // eff = &dev->ffEffectTypes[dev->numFFEffectTypes-1]; } ForceFeedbackBinding *b; - int res = CreateEffectBinding(dev, temp2, pad, motor, &b); + CreateEffectBinding(dev, temp2, port, slot, motor, &b); if (b) { while (1) { int axisID = atoi(s); @@ -980,10 +986,14 @@ int LoadSettings(int force, wchar_t *file) { return 0; } -inline int GetPAD(HWND hWnd) { - for (int i=0; i>1] == hWnd) { + *slot = i>>1; + return i&1; + } } + *slot = 0; return 0; } @@ -1002,95 +1012,94 @@ void Diagnostics(HWND hWnd) { RefreshEnabledDevicesAndDisplay(0, hWnd, 1); } -int GetBinding(int pad, int index, Device *&dev, Binding *&b, ForceFeedbackBinding *&ffb) { +int GetBinding(int port, int slot, int index, Device *&dev, Binding *&b, ForceFeedbackBinding *&ffb) { ffb = 0; b = 0; for (int i = 0; inumDevices; i++) { dev = dm->devices[i]; if (!dev->enabled) continue; - if (index < dev->pads[pad].numBindings) { - b = dev->pads[pad].bindings + index; + if (index < dev->pads[port][slot].numBindings) { + b = dev->pads[port][slot].bindings + index; return 1; } - index -= dev->pads[pad].numBindings; + index -= dev->pads[port][slot].numBindings; - if (index < dev->pads[pad].numFFBindings) { - ffb = dev->pads[pad].ffBindings + index; + if (index < dev->pads[port][slot].numFFBindings) { + ffb = dev->pads[port][slot].ffBindings + index; return 1; } - index -= dev->pads[pad].numFFBindings; + index -= dev->pads[port][slot].numFFBindings; } return 0; } // Only used when deleting things from ListView. Will remove from listview if needed. -void DeleteBinding(int pad, Device *dev, Binding *b) { - if (dev->enabled && hWnds[pad]) { - int count = GetItemIndex(pad, dev, b); +void DeleteBinding(int port, int slot, Device *dev, Binding *b) { + if (dev->enabled && hWnds[port][slot]) { + int count = GetItemIndex(port, slot, dev, b); if (count >= 0) { - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); if (hWndList) { ListView_DeleteItem(hWndList, count); } } } - Binding *bindings = dev->pads[pad].bindings; + Binding *bindings = dev->pads[port][slot].bindings; int i = b - bindings; - memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[pad].numBindings - i - 1)); - dev->pads[pad].numBindings--; + memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[port][slot].numBindings - i - 1)); + dev->pads[port][slot].numBindings--; } -void DeleteBinding(int pad, Device *dev, ForceFeedbackBinding *b) { - if (dev->enabled && hWnds[pad]) { - int count = GetItemIndex(pad, dev, b); +void DeleteBinding(int port, int slot, Device *dev, ForceFeedbackBinding *b) { + if (dev->enabled && hWnds[port][slot]) { + int count = GetItemIndex(port, slot, dev, b); if (count >= 0) { - HWND hWndList = GetDlgItem(hWnds[pad], IDC_LIST); + HWND hWndList = GetDlgItem(hWnds[port][slot], IDC_LIST); if (hWndList) { ListView_DeleteItem(hWndList, count); } } } - ForceFeedbackBinding *bindings = dev->pads[pad].ffBindings; + ForceFeedbackBinding *bindings = dev->pads[port][slot].ffBindings; int i = b - bindings; - memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[pad].numFFBindings - i - 1)); - dev->pads[pad].numFFBindings--; + memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[port][slot].numFFBindings - i - 1)); + dev->pads[port][slot].numFFBindings--; } -int DeleteByIndex(int pad, int index) { +int DeleteByIndex(int port, int slot, int index) { ForceFeedbackBinding *ffb; Binding *b; Device *dev; - if (GetBinding(pad, index, dev, b, ffb)) { + if (GetBinding(port, slot, index, dev, b, ffb)) { if (b) { - DeleteBinding(pad, dev, b); + DeleteBinding(port, slot, dev, b); } else { - DeleteBinding(pad, dev, ffb); + DeleteBinding(port, slot, dev, ffb); } return 1; } return 0; } -int DeleteSelected(int pad) { - if (!hWnds[pad]) return 0; - HWND hWnd = GetDlgItem(hWnds[pad], IDC_LIST); - int i = ListView_GetSelectedCount(hWnd); +int DeleteSelected(int port, int slot) { + if (!hWnds[port][slot]) return 0; + HWND hWnd = GetDlgItem(hWnds[port][slot], IDC_LIST); int changes = 0; - while (i-- > 0) { + while (1) { int index = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED); - if (index >= 0) { - changes += DeleteByIndex(pad, index); - } + if (index < 0) break; + changes += DeleteByIndex(port, slot, index); } //ShowScrollBar(hWnd, SB_VERT, 1); return changes; } -int CreateEffectBinding(Device *dev, wchar_t *effectID, unsigned int pad, unsigned int motor, ForceFeedbackBinding **binding) { +int CreateEffectBinding(Device *dev, wchar_t *effectID, unsigned int port, unsigned int slot, unsigned int motor, ForceFeedbackBinding **binding) { // Checks needed because I use this directly when loading bindings. // Note: dev->numFFAxes *can* be 0, for loading from file. - if (pad > 1 || motor > 1 || !dev->numFFEffectTypes) { + *binding = 0; + if (port > 1 || slot>3 || motor > 1 || !dev->numFFEffectTypes) { return -1; } if (!effectID) { @@ -1099,24 +1108,24 @@ int CreateEffectBinding(Device *dev, wchar_t *effectID, unsigned int pad, unsign ForceFeedbackEffectType *eff = dev->GetForcefeedbackEffect(effectID); if (!eff) return -1; int effectIndex = eff - dev->ffEffectTypes; - dev->pads[pad].ffBindings = (ForceFeedbackBinding*) realloc(dev->pads[pad].ffBindings, (dev->pads[pad].numFFBindings+1) * sizeof(ForceFeedbackBinding)); - int newIndex = dev->pads[pad].numFFBindings; - while (newIndex && dev->pads[pad].ffBindings[newIndex-1].motor >= motor) { - dev->pads[pad].ffBindings[newIndex] = dev->pads[pad].ffBindings[newIndex-1]; + dev->pads[port][slot].ffBindings = (ForceFeedbackBinding*) realloc(dev->pads[port][slot].ffBindings, (dev->pads[port][slot].numFFBindings+1) * sizeof(ForceFeedbackBinding)); + int newIndex = dev->pads[port][slot].numFFBindings; + while (newIndex && dev->pads[port][slot].ffBindings[newIndex-1].motor >= motor) { + dev->pads[port][slot].ffBindings[newIndex] = dev->pads[port][slot].ffBindings[newIndex-1]; newIndex--; } - ForceFeedbackBinding *b = dev->pads[pad].ffBindings + newIndex; + ForceFeedbackBinding *b = dev->pads[port][slot].ffBindings + newIndex; b->axes = (AxisEffectInfo*) calloc(dev->numFFAxes, sizeof(AxisEffectInfo)); b->motor = motor; b->effectIndex = effectIndex; - dev->pads[pad].numFFBindings++; + dev->pads[port][slot].numFFBindings++; if (binding) *binding = b; - return ListBoundEffect(pad, dev, b); + return ListBoundEffect(port, slot, dev, b); } -int BindCommand(Device *dev, unsigned int uid, unsigned int pad, int command, int sensitivity, int turbo) { +int BindCommand(Device *dev, unsigned int uid, unsigned int port, unsigned int slot, int command, int sensitivity, int turbo) { // Checks needed because I use this directly when loading bindings. - if (pad > 1) { + if (port > 1 || slot>3) { return -1; } if (!sensitivity) sensitivity = BASE_SENSITIVITY; @@ -1129,7 +1138,7 @@ int BindCommand(Device *dev, unsigned int uid, unsigned int pad, int command, in // Add before deleting. Means I won't scroll up one line when scrolled down to bottom. int controlIndex = c - dev->virtualControls; int index = 0; - PadBindings *p = dev->pads+pad; + PadBindings *p = dev->pads[port]+slot; p->bindings = (Binding*) realloc(p->bindings, (p->numBindings+1) * sizeof(Binding)); for (index = p->numBindings; index > 0; index--) { if (p->bindings[index-1].controlIndex < controlIndex) break; @@ -1142,7 +1151,7 @@ int BindCommand(Device *dev, unsigned int uid, unsigned int pad, int command, in b->turbo = turbo; b->sensitivity = sensitivity; // Where it appears in listview. - int count = ListBoundCommand(pad, dev, b); + int count = ListBoundCommand(port, slot, dev, b); int newBindingIndex = index; index = 0; @@ -1170,7 +1179,7 @@ int BindCommand(Device *dev, unsigned int uid, unsigned int pad, int command, in newBindingIndex--; count --; } - DeleteBinding(pad, dev, b); + DeleteBinding(port, slot, dev, b); } return count; @@ -1209,7 +1218,8 @@ void EndBinding(HWND hWnd) { INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam) { int index = (hWnd == PropSheet_IndexToHwnd(hWndProp, 1)); - int pad = GetPAD(hWnd); + int slot; + int port = GetPort(hWnd, &slot); HWND hWndList = GetDlgItem(hWnd, IDC_LIST); switch (msg) { case WM_INITDIALOG: @@ -1227,14 +1237,16 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l c.pszText = L"PS2 Control"; ListView_InsertColumn(hWndList, 2, &c); selected = 0; - hWnds[pad = (int)((PROPSHEETPAGE *)lParam)->lParam] = hWnd; + port = (int)((PROPSHEETPAGE *)lParam)->lParam & 1; + slot = (int)((PROPSHEETPAGE *)lParam)->lParam >> 1; + hWnds[port][slot] = hWnd; SendMessage(hWndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); HWND hWndSlider = GetDlgItem(hWnd, IDC_SLIDER1); SetupLogSlider(hWndSlider); - if (pad == 1) + if (port || slot) EnableWindow(GetDlgItem(hWnd, ID_IGNORE), 0); - Populate(pad); + Populate(port, slot); } break; case WM_DEVICECHANGE: @@ -1263,16 +1275,16 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l int index = -1; if (command == 0x7F) { if (dev->api == IGNORE_KEYBOARD) { - index = BindCommand(dev, uid, 0, command, BASE_SENSITIVITY, 0); + index = BindCommand(dev, uid, 0, 0, command, BASE_SENSITIVITY, 0); } } else if (command < 0x30) { if (!(uid & UID_POV)) { - index = BindCommand(dev, uid, pad, command, BASE_SENSITIVITY, 0); + index = BindCommand(dev, uid, port, slot, command, BASE_SENSITIVITY, 0); } } if (index >= 0) { - PropSheet_Changed(hWndProp, hWnds[pad]); + PropSheet_Changed(hWndProp, hWnds[port][slot]); if (index >= 0) ListView_SetItemState(hWndList, index, LVIS_SELECTED, LVIS_SELECTED); } @@ -1312,7 +1324,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l if (key->wVKey == VK_DELETE || key->wVKey == VK_BACK) { - if (DeleteSelected(pad)) + if (DeleteSelected(port, slot)) PropSheet_Changed(hWndProp, hWnds[0]); } } @@ -1325,7 +1337,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l } else if (n->hdr.code == NM_CUSTOMDRAW && NeedUpdate) { NeedUpdate = 0; - SelChanged(pad); + SelChanged(port, slot); } EndBinding(hWnd); } @@ -1339,10 +1351,10 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l int id = GetDlgCtrlID((HWND)lParam); int val = GetLogSliderVal(hWnd, id); if (id == IDC_SLIDER1) { - ChangeValue(pad, &val, 0); + ChangeValue(port, slot, &val, 0); } else { - ChangeEffect(pad, id, &val, 0); + ChangeEffect(port, slot, id, &val, 0); } } break; @@ -1355,13 +1367,13 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l ForceFeedbackBinding *ffb; Binding *b; Device *dev; - if (GetBinding(pad, index, dev, b, ffb)) { + if (GetBinding(port, slot, index, dev, b, ffb)) { int uid = dev->virtualControls[b->controlIndex].uid; const static unsigned int axisUIDs[3] = {UID_AXIS_NEG, UID_AXIS_POS, UID_AXIS}; uid = (uid&0x00FFFFFF) | axisUIDs[cbsel]; Binding backup = *b; - DeleteSelected(pad); - int index = BindCommand(dev, uid, pad, backup.command, backup.sensitivity, backup.turbo); + DeleteSelected(port, slot); + int index = BindCommand(dev, uid, port, slot, backup.command, backup.sensitivity, backup.turbo); ListView_SetItemState(hWndList, index, LVIS_SELECTED, LVIS_SELECTED); } } @@ -1370,18 +1382,18 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l else if (HIWORD(wParam)==CBN_SELCHANGE && LOWORD(wParam) == IDC_FF_EFFECT) { unsigned int typeIndex = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0); if (typeIndex >= 0) - ChangeEffect(pad, 0, 0, &typeIndex); + ChangeEffect(port, slot, 0, 0, &typeIndex); } else if (HIWORD(wParam)==BN_CLICKED) { EndBinding(hWnd); int cmd = LOWORD(wParam); if (cmd == ID_DELETE) { - if (DeleteSelected(pad)) + if (DeleteSelected(port, slot)) PropSheet_Changed(hWndProp, hWnd); } else if (cmd == ID_CLEAR) { int changed=0; - while (DeleteByIndex(pad, 0)) changed++; + while (DeleteByIndex(port, slot, 0)) changed++; if (changed) PropSheet_Changed(hWndProp, hWnd); } @@ -1391,7 +1403,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l unsigned int index = (unsigned int)SendMessage(GetDlgItem(hWnd, IDC_FORCEFEEDBACK), CB_GETITEMDATA, i, 0); if (index < (unsigned int) dm->numDevices) { ForceFeedbackBinding *b; - int count = CreateEffectBinding(dm->devices[index], 0, pad, cmd-ID_BIG_MOTOR, &b); + int count = CreateEffectBinding(dm->devices[index], 0, port, slot, cmd-ID_BIG_MOTOR, &b); if (b) { for (int j=0; j<2 && j devices[index]->numFFAxes; j++) { b->axes[j].force = BASE_SENSITIVITY; @@ -1414,7 +1426,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l ForceFeedbackBinding *ffb = 0; int selIndex = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); if (selIndex >= 0) { - if (GetBinding(pad, selIndex, dev, b, ffb)) { + if (GetBinding(port, slot, selIndex, dev, b, ffb)) { selected = 0xFF; InitInfo info = {0, hWndProp, hWnd, GetDlgItem(hWnd, cmd)}; EatWndProc(info.hWndButton, DoNothingWndProc); @@ -1470,11 +1482,11 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l // Don't allow setting it back to indeterminate. SendMessage(GetDlgItem(hWnd, IDC_TURBO), BM_SETSTYLE, BS_AUTOCHECKBOX, 0); int turbo = (IsDlgButtonChecked(hWnd, IDC_TURBO) == BST_CHECKED); - ChangeValue(pad, 0, &turbo); + ChangeValue(port, slot, 0, &turbo); } else if (cmd == IDC_FLIP1 || cmd == IDC_TURBO) { int val = GetLogSliderVal(hWnd, IDC_SLIDER1); - ChangeValue(pad, &val, 0); + ChangeValue(port, slot, &val, 0); } else if (cmd >= IDC_FF_AXIS1_ENABLED && cmd < IDC_FF_AXIS8_ENABLED + 16) { int index = (cmd - IDC_FF_AXIS1_ENABLED)/16; @@ -1482,7 +1494,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l if (IsDlgButtonChecked(hWnd, 16*index + IDC_FF_AXIS1_ENABLED) != BST_CHECKED) { val = 0; } - ChangeEffect(pad, cmd, &val, 0); + ChangeEffect(port, slot, cmd, &val, 0); } } break; @@ -1492,29 +1504,37 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l return 0; } -int CreatePadPages(HPROPSHEETPAGE *pages) { +void UpdatePadPages() { + HPROPSHEETPAGE pages[10]; int count = 0; - for (int pad=0; pad<2; pad++) { - if (config.disablePad[pad]) continue; + memset(hWnds, 0, sizeof(hWnds)); + int slot = 0; + for (int port=0; port<2; port++) { + if (config.padConfigs[port][slot].type == DisabledPad) continue; PROPSHEETPAGE psp; ZeroMemory(&psp, sizeof(psp)); psp.dwSize = sizeof(psp); psp.dwFlags = PSP_USETITLE | PSP_PREMATURE; psp.hInstance = hInst; psp.pfnDlgProc = (DLGPROC) DialogProc; - psp.lParam = pad; - if (pad == 0) + psp.lParam = port | (slot<<1); + if (port == 0) psp.pszTitle = L"Pad 1"; else psp.pszTitle = L"Pad 2"; - if (!config.guitar[pad]) + if (config.padConfigs[port][slot].type != GuitarPad) psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG); else psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG_GUITAR); pages[count] = CreatePropertySheetPage(&psp); if (pages[count]) count++; } - return count; + while (SendMessage(hWndProp, PSM_INDEXTOPAGE, 1, 0)) { + PropSheet_RemovePage(hWndProp, 1, 0); + } + for (int i=0; inumDevices; i++) { + Device *dev = dm->devices[i]; + if (!dev->enabled) continue; + count += dev->pads[port][slot].numBindings + dev->pads[port][slot].numFFBindings; + } + wsprintf(text, L"%i", count); + item.pszText = text; + ListView_SetItem(hWndList, &item); + index++; + } + int sel = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); + + EnableWindow(hWndCombo, sel>=0); + EnableWindow(hWndAnalog, sel>=0); + if (sel < 0) { + SendMessage(hWndCombo, CB_SETCURSEL, -1, 0); + CheckDlgButton(hWnd, IDC_ANALOG_START1, BST_UNCHECKED); + } + else { + SendMessage(hWndCombo, CB_SETCURSEL, config.padConfigs[sel][0].type, 0); + CheckDlgButton(hWnd, IDC_ANALOG_START1, BST_CHECKED*config.padConfigs[sel][0].autoAnalog); + } +} INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam) { int i; + HWND hWndList = GetDlgItem(hWnd, IDC_PAD_LIST); switch (msg) { case WM_INITDIALOG: { - HPROPSHEETPAGE pages[10]; - int count = CreatePadPages(pages); - while (SendMessage(hWndProp, PSM_INDEXTOPAGE, 1, 0)) { - PropSheet_RemovePage(hWndProp, 1, 0); - } - for (int i=0; i>1)); CheckDlgButton(hWnd, IDC_CLOSE_HACK3, BST_CHECKED * ((config.closeHacks&4)>>2)); - CheckDlgButton(hWnd, IDC_DISABLE_PAD1, BST_CHECKED * config.disablePad[0]); - CheckDlgButton(hWnd, IDC_DISABLE_PAD2, BST_CHECKED * config.disablePad[1]); CheckDlgButton(hWnd, IDC_MOUSE_UNFOCUS, BST_CHECKED * config.mouseUnfocus); CheckDlgButton(hWnd, IDC_GS_THREAD_INPUT, BST_CHECKED * config.GSThreadUpdates); @@ -1571,10 +1656,6 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L CheckDlgButton(hWnd, IDC_VISTA_VOLUME, BST_CHECKED * config.vistaVolume); if (config.osVersion < 6) EnableWindow(GetDlgItem(hWnd, IDC_VISTA_VOLUME), 0); - CheckDlgButton(hWnd, IDC_GUITAR1, BST_CHECKED * config.guitar[0]); - CheckDlgButton(hWnd, IDC_GUITAR2, BST_CHECKED * config.guitar[1]); - CheckDlgButton(hWnd, IDC_ANALOG_START1, BST_CHECKED * config.AutoAnalog[0]); - CheckDlgButton(hWnd, IDC_ANALOG_START2, BST_CHECKED * config.AutoAnalog[1]); CheckDlgButton(hWnd, IDC_DEBUG_FILE, BST_CHECKED * config.debug); CheckDlgButton(hWnd, IDC_MULTIPLE_BINDING, BST_CHECKED * config.multipleBinding); @@ -1598,7 +1679,18 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L } break; case WM_COMMAND: - if (HIWORD(wParam)==BN_CLICKED && (LOWORD(wParam) == ID_LOAD || LOWORD(wParam) == ID_SAVE)) { + if (LOWORD(wParam) == IDC_PAD_TYPE) { + if (HIWORD(wParam) == CBN_SELCHANGE) { + int pad = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); + HWND hWndCombo = GetDlgItem(hWnd, IDC_PAD_TYPE); + int sel = SendMessage(hWndCombo, CB_GETCURSEL, 0, 0); + if (pad >= 0 && sel >= 0 && sel != config.padConfigs[sel][0].type) { + config.padConfigs[sel][0].type = (PadType)sel; + PropSheet_Changed(hWndProp, hWnd); + } + } + } + else if (HIWORD(wParam)==BN_CLICKED && (LOWORD(wParam) == ID_LOAD || LOWORD(wParam) == ID_SAVE)) { OPENFILENAMEW ofn; memset (&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -1616,6 +1708,7 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L if (GetOpenFileNameW(&ofn)) { LoadSettings(1, ofn.lpstrFile); GeneralDialogProc(hWnd, WM_INITDIALOG, 0, 0); + PropSheet_Changed(hWndProp, hWnd); } } else { @@ -1637,6 +1730,13 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L else if (HIWORD(wParam)==BN_CLICKED && LOWORD(wParam) == ID_REFRESH) { RefreshEnabledDevicesAndDisplay(1, hWnd, 1); } + else if (HIWORD(wParam)==BN_CLICKED && LOWORD(wParam) == IDC_ANALOG_START1) { + int pad = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); + if (pad >= 0) { + config.padConfigs[pad][0].autoAnalog = (IsDlgButtonChecked(hWnd, IDC_ANALOG_START1) == BST_CHECKED); + PropSheet_Changed(hWndProp, hWnd); + } + } else { int t = IDC_CLOSE_HACK1; int test = LOWORD(wParam); @@ -1668,26 +1768,6 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L } - unsigned int needUpdate = 0; - unsigned int disablePad1New = (IsDlgButtonChecked(hWnd, IDC_DISABLE_PAD1) == BST_CHECKED); - unsigned int disablePad2New = (IsDlgButtonChecked(hWnd, IDC_DISABLE_PAD2) == BST_CHECKED); - unsigned int guitarNew1 = (IsDlgButtonChecked(hWnd, IDC_GUITAR1) == BST_CHECKED); - unsigned int guitarNew2 = (IsDlgButtonChecked(hWnd, IDC_GUITAR2) == BST_CHECKED); - if (config.disablePad[0] != disablePad1New || - config.disablePad[1] != disablePad2New || - config.guitar[0] != guitarNew1 || - config.guitar[1] != guitarNew2) { - - config.disablePad[0] = disablePad1New; - config.disablePad[1] = disablePad2New; - config.guitar[0] = guitarNew1; - config.guitar[1] = guitarNew2; - - needUpdate = 1; - } - - config.AutoAnalog[0] = (IsDlgButtonChecked(hWnd, IDC_ANALOG_START1) == BST_CHECKED); - config.AutoAnalog[1] = (IsDlgButtonChecked(hWnd, IDC_ANALOG_START2) == BST_CHECKED); config.debug = (IsDlgButtonChecked(hWnd, IDC_DEBUG_FILE) == BST_CHECKED); config.multipleBinding = (IsDlgButtonChecked(hWnd, IDC_MULTIPLE_BINDING) == BST_CHECKED); @@ -1719,9 +1799,10 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L RefreshEnabledDevicesAndDisplay(0, hWnd, 1); PropSheet_Changed(hWndProp, hWnd); + /* if (needUpdate) { - GeneralDialogProc(hWnd, WM_INITDIALOG, 0, 0); - } + UpdatePadPages(); + }//*/ } break; case WM_NOTIFY: @@ -1746,9 +1827,12 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L return 1; } } - else { - if (n->hdr.idFrom == IDC_LIST && n->hdr.code == NM_DBLCLK) { - Diagnostics(hWnd); + else if (n->hdr.idFrom == IDC_LIST && n->hdr.code == NM_DBLCLK) { + Diagnostics(hWnd); + } + else if (n->hdr.idFrom == IDC_PAD_LIST) { + if (n->hdr.code == NM_CLICK) { + UpdatePadList(hWnd); } } } @@ -1787,7 +1871,7 @@ void CALLBACK PADconfigure() { psh.pszCaption = title; PropertySheet(&psh); LoadSettings(1); - hWnds[0] = hWnds[1] = 0; + memset(hWnds, 0, sizeof(hWnds)); } void UnloadConfigs() { diff --git a/plugins/LilyPad/Config.h b/plugins/LilyPad/Config.h index 87b648f401..07ef8cbfbc 100644 --- a/plugins/LilyPad/Config.h +++ b/plugins/LilyPad/Config.h @@ -6,9 +6,20 @@ extern u8 ps2e; +enum PadType { + DisabledPad, + Dualshock2Pad, + GuitarPad +}; + +struct PadConfig { + PadType type; + u8 autoAnalog; +}; + struct GeneralConfig { public: - u8 disablePad[2]; + PadConfig padConfigs[2][4]; u8 mouseUnfocus; u8 disableScreenSaver; @@ -32,9 +43,6 @@ public: u8 GSThreadUpdates; u8 escapeFullscreenHack; - u8 guitar[2]; - u8 AutoAnalog[2]; - u8 saveStateTitle; u8 vistaVolume; diff --git a/plugins/LilyPad/DirectInput.cpp b/plugins/LilyPad/DirectInput.cpp index e000e9540c..f66235e064 100644 --- a/plugins/LilyPad/DirectInput.cpp +++ b/plugins/LilyPad/DirectInput.cpp @@ -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) { - 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; jeffectIndex; + 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; jaxes[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; kaxes[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; iStop(); diEffects[i].die->Release(); diff --git a/plugins/LilyPad/InputManager.cpp b/plugins/LilyPad/InputManager.cpp index 809dab4649..2be1429dca 100644 --- a/plugins/LilyPad/InputManager.cpp +++ b/plugins/LilyPad/InputManager.cpp @@ -67,12 +67,14 @@ Device::~Device() { // Generally called by deactivate, but just in case... FreeState(); int i; - for (int pad=0; pad<2; pad++) { - free(pads[pad].bindings); - for (i=0; iaxes = (AxisEffectInfo*) realloc(b->axes, sizeof(AxisEffectInfo) * (numFFAxes)); - memset(b->axes + (numFFAxes-1), 0, sizeof(AxisEffectInfo)); + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + for (int i=0; iaxes = (AxisEffectInfo*) realloc(b->axes, sizeof(AxisEffectInfo) * (numFFAxes)); + memset(b->axes + (numFFAxes-1), 0, sizeof(AxisEffectInfo)); + } } } } @@ -254,9 +258,9 @@ PhysicalControl *Device::AddPhysicalControl(ControlType type, unsigned short id, return control; } -void Device::SetEffects(unsigned char pad, unsigned char motor, unsigned char force) { - for (int i=0; imotor == motor) { SetEffect(binding, force); } @@ -451,7 +455,7 @@ ForceFeedbackAxis *Device::GetForceFeedbackAxis(int id) { void InputDeviceManager::CopyBindings(int numOldDevices, Device **oldDevices) { int *oldMatches = (int*) malloc(sizeof(int) * numOldDevices); int *matches = (int*) malloc(sizeof(int) * numDevices); - int i, j, pad; + int i, j, port, slot; Device *old, *dev; for (i=0; ipads[pad].numBindings + old->pads[pad].numFFBindings) { - // Means that there are bindings. - oldMatches[i] = -1; + for (port=0; port<2; port++) { + for (slot=0; slot<4; slot++) { + if (old->pads[port][slot].numBindings + old->pads[port][slot].numFFBindings) { + // Means that there are bindings. + oldMatches[i] = -1; + } } } } @@ -514,37 +520,39 @@ void InputDeviceManager::CopyBindings(int numOldDevices, Device **oldDevices) { } else { dev = devices[oldMatches[i]]; - for (pad=0; pad<2; pad++) { - if (old->pads[pad].numBindings) { - dev->pads[pad].bindings = (Binding*) malloc(old->pads[pad].numBindings * sizeof(Binding)); - for (int j=0; jpads[pad].numBindings; j++) { - Binding *bo = old->pads[pad].bindings + j; - Binding *bn = dev->pads[pad].bindings + dev->pads[pad].numBindings; - VirtualControl *cn = dev->GetVirtualControl(old->virtualControls[bo->controlIndex].uid); - if (cn) { - *bn = *bo; - bn->controlIndex = cn - dev->virtualControls; - dev->pads[pad].numBindings++; + for (port=0; port<2; port++) { + for (slot=0; slot<4; slot++) { + if (old->pads[port][slot].numBindings) { + dev->pads[port][slot].bindings = (Binding*) malloc(old->pads[port][slot].numBindings * sizeof(Binding)); + for (int j=0; jpads[port][slot].numBindings; j++) { + Binding *bo = old->pads[port][slot].bindings + j; + Binding *bn = dev->pads[port][slot].bindings + dev->pads[port][slot].numBindings; + VirtualControl *cn = dev->GetVirtualControl(old->virtualControls[bo->controlIndex].uid); + if (cn) { + *bn = *bo; + bn->controlIndex = cn - dev->virtualControls; + dev->pads[port][slot].numBindings++; + } } } - } - if (old->pads[pad].numFFBindings) { - dev->pads[pad].ffBindings = (ForceFeedbackBinding*) malloc(old->pads[pad].numFFBindings * sizeof(ForceFeedbackBinding)); - for (int j=0; jpads[pad].numFFBindings; j++) { - ForceFeedbackBinding *bo = old->pads[pad].ffBindings + j; - ForceFeedbackBinding *bn = dev->pads[pad].ffBindings + dev->pads[pad].numFFBindings; - ForceFeedbackEffectType *en = dev->GetForcefeedbackEffect(old->ffEffectTypes[bo->effectIndex].effectID); - if (en) { - *bn = *bo; - bn->effectIndex = en - dev->ffEffectTypes; - bn->axes = (AxisEffectInfo*)calloc(dev->numFFAxes, sizeof(AxisEffectInfo)); - for (int k=0; knumFFAxes; k++) { - ForceFeedbackAxis *newAxis = dev->GetForceFeedbackAxis(old->ffAxes[k].id); - if (newAxis) { - bn->axes[newAxis - dev->ffAxes] = bo->axes[k]; + if (old->pads[port][slot].numFFBindings) { + dev->pads[port][slot].ffBindings = (ForceFeedbackBinding*) malloc(old->pads[port][slot].numFFBindings * sizeof(ForceFeedbackBinding)); + for (int j=0; jpads[port][slot].numFFBindings; j++) { + ForceFeedbackBinding *bo = old->pads[port][slot].ffBindings + j; + ForceFeedbackBinding *bn = dev->pads[port][slot].ffBindings + dev->pads[port][slot].numFFBindings; + ForceFeedbackEffectType *en = dev->GetForcefeedbackEffect(old->ffEffectTypes[bo->effectIndex].effectID); + if (en) { + *bn = *bo; + bn->effectIndex = en - dev->ffEffectTypes; + bn->axes = (AxisEffectInfo*)calloc(dev->numFFAxes, sizeof(AxisEffectInfo)); + for (int k=0; knumFFAxes; k++) { + ForceFeedbackAxis *newAxis = dev->GetForceFeedbackAxis(old->ffAxes[k].id); + if (newAxis) { + bn->axes[newAxis - dev->ffAxes] = bo->axes[k]; + } } + dev->pads[port][slot].numFFBindings++; } - dev->pads[pad].numFFBindings++; } } } @@ -555,11 +563,11 @@ void InputDeviceManager::CopyBindings(int numOldDevices, Device **oldDevices) { free(matches); } -void InputDeviceManager::SetEffect(unsigned char pad, unsigned char motor, unsigned char force) { +void InputDeviceManager::SetEffect(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force) { for (int i=0; ienabled && dev->numFFEffectTypes) { - dev->SetEffects(pad, motor, force); + dev->SetEffects(port, slot, motor, force); } } } diff --git a/plugins/LilyPad/InputManager.h b/plugins/LilyPad/InputManager.h index 26120ee6a9..97e7c95227 100644 --- a/plugins/LilyPad/InputManager.h +++ b/plugins/LilyPad/InputManager.h @@ -194,7 +194,7 @@ public: }; }; - PadBindings pads[2]; + PadBindings pads[2][4]; // Virtual controls. All basically act like pressure sensitivity buttons, with // values between 0 and 2^16. 2^16 is fully down, 0 is up. Larger values @@ -267,7 +267,7 @@ public: // Note: Only used externally for binding, so if override the other one, can assume // all other forces are currently 0. inline virtual void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {} - inline virtual void SetEffects(unsigned char pad, unsigned char motor, unsigned char force); + inline virtual void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force); // Called after reading. Basically calls FlipState(). // Some device types (Those that don't incrementally update) @@ -303,7 +303,7 @@ public: // Called after reading state, after Update(). void PostRead(); - void SetEffect(unsigned char pad, unsigned char motor, unsigned char force); + void SetEffect(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force); // Update does this as needed. // void GetInput(void *v); diff --git a/plugins/LilyPad/KeyboardHook.cpp b/plugins/LilyPad/KeyboardHook.cpp index a8f25bd133..0c7a146b98 100644 --- a/plugins/LilyPad/KeyboardHook.cpp +++ b/plugins/LilyPad/KeyboardHook.cpp @@ -87,8 +87,8 @@ LRESULT CALLBACK IgnoreKeyboardHook(int code, WPARAM wParam, LPARAM lParam) { if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) { KBDLLHOOKSTRUCT* key = (KBDLLHOOKSTRUCT*) lParam; if (key->vkCode < 256) { - for (int i=0; ipads[0].numBindings; i++) { - if (ikhd->pads[0].bindings[i].controlIndex == key->vkCode) { + for (int i=0; ipads[0][0].numBindings; i++) { + if (ikhd->pads[0][0].bindings[i].controlIndex == key->vkCode) { return 1; } } diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index 482356c678..70f628b172 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -106,28 +106,38 @@ struct ButtonSum { Stick sticks[3]; }; -class Pad { + +struct PadFreezeData { + // Digital / Analog / Full Analog (aka DS2 Native) + u8 mode; + u8 modeLock; + + // In config mode + u8 config; + + u8 vibrate[8]; + u8 umask[2]; +}; + +class Pad : public PadFreezeData { public: ButtonSum sum, lockedSum; int lockedState; - u8 vibrate[8]; - - u8 umask[2]; u8 vibrateI[2]; u8 vibrateVal[2]; - // Digital / Analog / Full Analog (aka DS2 Native) - u8 mode; - u8 modeLock; - // In config mode - u8 config; // Used to keep track of which pads I'm running. // Note that initialized pads *can* be disabled. // I keep track of state of non-disabled non-initialized // pads, but should never be asked for their state. u8 initialized; -} pads[2]; +} pads[2][4]; + +// Active slots for each port. +int slots[2]; +// Which ports we're running on. +int portInitialized[2]; // Force value to be from 0 to 255. u8 Cap (int i) { @@ -149,9 +159,15 @@ void UpdateEnabledDevices(int updateList = 0) { // Enable all devices I might want. Can ignore the rest. RefreshEnabledDevices(updateList); // Figure out which pads I'm getting input for. - int padsEnabled[2] = { - pads[0].initialized && !config.disablePad[0], - pads[1].initialized && !config.disablePad[1] + int padsEnabled[2][4] = { + {pads[0][0].initialized && config.padConfigs[0][0].type != DisabledPad, + pads[0][1].initialized && config.padConfigs[0][1].type != DisabledPad, + pads[0][2].initialized && config.padConfigs[0][2].type != DisabledPad, + pads[0][3].initialized && config.padConfigs[0][3].type != DisabledPad}, + {pads[1][0].initialized && config.padConfigs[1][0].type != DisabledPad, + pads[1][1].initialized && config.padConfigs[1][1].type != DisabledPad, + pads[1][2].initialized && config.padConfigs[1][2].type != DisabledPad, + pads[1][3].initialized && config.padConfigs[1][3].type != DisabledPad} }; for (int i=0; inumDevices; i++) { Device *dev = dm->devices[i]; @@ -164,7 +180,7 @@ void UpdateEnabledDevices(int updateList = 0) { // Disable ignore keyboard if don't have focus or there are no keys to ignore. if (dev->api == IGNORE_KEYBOARD) { - if ((!config.vistaVolume && (config.keyboardApi == NO_API || !dev->pads[0].numBindings)) || !activeWindow) { + if ((!config.vistaVolume && (config.keyboardApi == NO_API || !dev->pads[0][0].numBindings)) || !activeWindow) { dm->DisableDevice(i); } continue; @@ -181,9 +197,11 @@ void UpdateEnabledDevices(int updateList = 0) { else if (!activeWindow && !config.background) dm->DisableDevice(i); else { int numActiveBindings = 0; - for (int pad=0; pad<2; pad++) { - if (padsEnabled[pad]) { - numActiveBindings += dev->pads[pad].numBindings + dev->pads[pad].numFFBindings; + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + if (padsEnabled[port][slot]) { + numActiveBindings += dev->pads[port][slot].numBindings + dev->pads[port][slot].numFFBindings; + } } } if (!numActiveBindings) @@ -297,7 +315,6 @@ void CapSum(ButtonSum *sum) { // key press info requests. int summed[3] = {0, 0, 0}; -int lockStateChanged[2] = {0,0}; #define LOCK_DIRECTION 2 #define LOCK_BUTTONS 4 #define LOCK_BOTH 1 @@ -310,9 +327,13 @@ void Update(int pad) { return; } int i; - ButtonSum s[2]; - s[0] = pads[0].lockedSum; - s[1] = pads[1].lockedSum; + ButtonSum s[2][4]; + u8 lockStateChanged[2][4]; + memset(lockStateChanged, 0, sizeof(lockStateChanged)); + + for (i=0; i<8; i++) { + s[i&1][i>>1] = pads[i&1][i>>1].lockedSum; + } InitInfo info = { 0, hWnd, hWnd, 0 }; @@ -328,36 +349,38 @@ void Update(int pad) { // 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; - for (int pad=0; pad<2; pad++) { - if (config.disablePad[pad]) continue; - for (int j=0; jpads[pad].numBindings; j++) { - Binding *b = dev->pads[pad].bindings+j; - int cmd = b->command; - int state = dev->virtualControlState[b->controlIndex]; - if (!(turbo & b->turbo)) { - if (cmd > 0x0F && cmd != 0x28) { - ProcessButtonBinding(b, s+pad, state); - } - else if ((state>>15) && !(dev->oldVirtualControlState[b->controlIndex]>>15)) { - if (cmd == 0x0F) { - miceEnabled = !miceEnabled; - UpdateEnabledDevices(); + 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; + for (int j=0; jpads[port][slot].numBindings; j++) { + Binding *b = dev->pads[port][slot].bindings+j; + int cmd = b->command; + int state = dev->virtualControlState[b->controlIndex]; + if (!(turbo & b->turbo)) { + if (cmd > 0x0F && cmd != 0x28) { + ProcessButtonBinding(b, &s[port][slot], state); } - else if (cmd == 0x0C) { - lockStateChanged[pad] |= LOCK_BUTTONS; - } - else if (cmd == 0x0E) { - lockStateChanged[pad] |= LOCK_DIRECTION; - } - else if (cmd == 0x0D) { - lockStateChanged[pad] |= LOCK_BOTH; - } - else if (cmd == 0x28) { - if (!pads[pad].modeLock) { - if (pads[pad].mode != MODE_DIGITAL) - pads[pad].mode = MODE_DIGITAL; - else - pads[pad].mode = MODE_ANALOG; + else if ((state>>15) && !(dev->oldVirtualControlState[b->controlIndex]>>15)) { + if (cmd == 0x0F) { + miceEnabled = !miceEnabled; + UpdateEnabledDevices(); + } + else if (cmd == 0x0C) { + lockStateChanged[port][slot] |= LOCK_BUTTONS; + } + else if (cmd == 0x0E) { + lockStateChanged[port][slot] |= LOCK_DIRECTION; + } + else if (cmd == 0x0D) { + lockStateChanged[port][slot] |= LOCK_BOTH; + } + else if (cmd == 0x28) { + if (!pads[port][slot].modeLock) { + if (pads[port][slot].mode != MODE_DIGITAL) + pads[port][slot].mode = MODE_DIGITAL; + else + pads[port][slot].mode = MODE_ANALOG; + } } } } @@ -371,101 +394,99 @@ void Update(int pad) { LeaveCriticalSection(&readInputCriticalSection); } - for (int currentPad = 0; currentPad<2; currentPad++) { - if (config.guitar[currentPad]) { - if (!config.GH2) { - s[currentPad].sticks[1].vert = -s[currentPad].sticks[1].vert; - } - // GH2 hack. - else if (config.GH2) { - const unsigned int oldIdList[5] = {ID_R2, ID_CIRCLE, ID_TRIANGLE, ID_CROSS, ID_SQUARE}; - const unsigned int idList[5] = {ID_L2, ID_L1, ID_R1, ID_R2, ID_CROSS}; - int values[5]; - int i; - for (i=0; i<5; i++) { - int id = oldIdList[i] - 0x1104; - values[i] = s[currentPad].buttons[id]; - s[currentPad].buttons[id] = 0; + 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; + if (config.padConfigs[port][slot].type == GuitarPad) { + if (!config.GH2) { + s[port][slot].sticks[1].vert = -s[port][slot].sticks[1].vert; } - s[currentPad].buttons[ID_TRIANGLE-0x1104] = values[1]; - for (i=0; i<5; i++) { - int id = idList[i] - 0x1104; - s[currentPad].buttons[id] = values[i]; - } - if (abs(s[currentPad].sticks[0].vert) <= 48) { - for (int i=0; i<5; i++) { - unsigned int id = idList[i] - 0x1104; - if (pads[currentPad].sum.buttons[id] < s[currentPad].buttons[id]) { - s[currentPad].buttons[id] = pads[currentPad].sum.buttons[id]; + // GH2 hack. + else if (config.GH2) { + const unsigned int oldIdList[5] = {ID_R2, ID_CIRCLE, ID_TRIANGLE, ID_CROSS, ID_SQUARE}; + const unsigned int idList[5] = {ID_L2, ID_L1, ID_R1, ID_R2, ID_CROSS}; + int values[5]; + int i; + for (i=0; i<5; i++) { + int id = oldIdList[i] - 0x1104; + values[i] = s[port][slot].buttons[id]; + s[port][slot].buttons[id] = 0; + } + s[port][slot].buttons[ID_TRIANGLE-0x1104] = values[1]; + for (i=0; i<5; i++) { + int id = idList[i] - 0x1104; + s[port][slot].buttons[id] = values[i]; + } + if (abs(s[port][slot].sticks[0].vert) <= 48) { + for (int i=0; i<5; i++) { + unsigned int id = idList[i] - 0x1104; + if (pads[port][slot].sum.buttons[id] < s[port][slot].buttons[id]) { + s[port][slot].buttons[id] = pads[port][slot].sum.buttons[id]; + } } } - } - else if (abs(pads[currentPad].sum.sticks[0].vert) <= 48) { - for (int i=0; i<5; i++) { - unsigned int id = idList[i] - 0x1104; - if (pads[currentPad].sum.buttons[id]) { - s[currentPad].buttons[id] = 0; + else if (abs(pads[port][slot].sum.sticks[0].vert) <= 48) { + for (int i=0; i<5; i++) { + unsigned int id = idList[i] - 0x1104; + if (pads[port][slot].sum.buttons[id]) { + s[port][slot].buttons[id] = 0; + } } } } } - } - if (pads[currentPad].mode == 0x41) { - s[currentPad].sticks[0].horiz += - s[currentPad].sticks[1].horiz + - s[currentPad].sticks[2].horiz; - s[currentPad].sticks[0].vert += - s[currentPad].sticks[1].vert + - s[currentPad].sticks[2].vert; - } + if (pads[port][slot].mode == 0x41) { + s[port][slot].sticks[0].horiz += + s[port][slot].sticks[1].horiz + + s[port][slot].sticks[2].horiz; + s[port][slot].sticks[0].vert += + s[port][slot].sticks[1].vert + + s[port][slot].sticks[2].vert; + } - CapSum(&s[currentPad]); - if (lockStateChanged[currentPad]) { - if (lockStateChanged[currentPad] & LOCK_BOTH) { - if (pads[currentPad].lockedState != (LOCK_DIRECTION | LOCK_BUTTONS)) { - // Enable the one that's not enabled. - lockStateChanged[currentPad] ^= pads[currentPad].lockedState^(LOCK_DIRECTION | LOCK_BUTTONS); + CapSum(&s[port][slot]); + if (lockStateChanged[port][slot]) { + if (lockStateChanged[port][slot] & LOCK_BOTH) { + if (pads[port][slot].lockedState != (LOCK_DIRECTION | LOCK_BUTTONS)) { + // Enable the one that's not enabled. + lockStateChanged[port][slot] ^= pads[port][slot].lockedState^(LOCK_DIRECTION | LOCK_BUTTONS); + } + else { + // Disable both + lockStateChanged[port][slot] ^= LOCK_DIRECTION | LOCK_BUTTONS; + } } - else { - // Disable both - lockStateChanged[currentPad] ^= LOCK_DIRECTION | LOCK_BUTTONS; + if (lockStateChanged[port][slot] & LOCK_DIRECTION) { + if (pads[port][slot].lockedState & LOCK_DIRECTION) { + memset(pads[port][slot].lockedSum.sticks, 0, sizeof(pads[port][slot].lockedSum.sticks)); + } + else { + memcpy(pads[port][slot].lockedSum.sticks, s[port][slot].sticks, sizeof(pads[port][slot].lockedSum.sticks)); + } + pads[port][slot].lockedState ^= LOCK_DIRECTION; + } + if (lockStateChanged[port][slot] & LOCK_BUTTONS) { + if (pads[port][slot].lockedState & LOCK_BUTTONS) { + memset(pads[port][slot].lockedSum.buttons, 0, sizeof(pads[port][slot].lockedSum.buttons)); + } + else { + memcpy(pads[port][slot].lockedSum.buttons, s[port][slot].buttons, sizeof(pads[port][slot].lockedSum.buttons)); + } + pads[port][slot].lockedState ^= LOCK_BUTTONS; + } + for (i=0; i>1].sum = s[i&1][i>>1]; } summed[0] = 1; summed[1] = 1; @@ -477,10 +498,10 @@ void CALLBACK PADupdate(int pad) { if (config.GSThreadUpdates) Update(pad); } -inline void SetVibrate(Pad *pad, int motor, u8 val) { - if (val | pad->vibrateVal[motor]) { - dm->SetEffect(pad - pads, motor, val); - pad->vibrateVal[motor] = val; +inline void SetVibrate(int port, int slot, int motor, u8 val) { + if (val || pads[port][slot].vibrateVal[motor]) { + dm->SetEffect(port,slot, motor, val); + pads[port][slot].vibrateVal[motor] = val; } } @@ -527,34 +548,48 @@ char* CALLBACK PS2EgetLibName(void) { //} void CALLBACK PADshutdown() { - pads[0].initialized = 0; - pads[1].initialized = 0; + for (int i=0; i<8; i++) + pads[i&1][i>>1].initialized = 0; UnloadConfigs(); } inline void StopVibrate() { - for (int i=0; i<4; i++) { - SetVibrate(&pads[i/2], i&1, 0); + for (int i=0; i<8; i++) { + SetVibrate(i&1, i>>1, 0, 0); + SetVibrate(i&1, i>>1, 1, 0); } } -inline void ResetVibrate(Pad *pad) { - SetVibrate(pad, 0, 0); - SetVibrate(pad, 1, 0); - ((int*)(pad->vibrate))[0] = 0xFFFFFF5A; - ((int*)(pad->vibrate))[1] = 0xFFFFFFFF; +inline void ResetVibrate(int port, int slot) { + SetVibrate(port, slot, 0, 0); + SetVibrate(port, slot, 1, 0); + ((int*)(pads[port][slot].vibrate))[0] = 0xFFFFFF5A; + ((int*)(pads[port][slot].vibrate))[1] = 0xFFFFFFFF; } -void ResetPad(int pad) { - memset(&pads[pad], 0, sizeof(pads[0])); - pads[pad].mode = MODE_DIGITAL; - pads[pad].umask[0] = pads[pad].umask[1] = 0xFF; - ResetVibrate(pads+pad); - if (config.AutoAnalog[pad]) { - pads[pad].mode = MODE_ANALOG; +void ResetPad(int port, int slot) { + memset(&pads[port][slot], 0, sizeof(pads[0])); + pads[port][slot].mode = MODE_DIGITAL; + pads[port][slot].umask[0] = pads[port][slot].umask[1] = 0xFF; + ResetVibrate(port, slot); + if (config.padConfigs[port][slot].autoAnalog) { + pads[port][slot].mode = MODE_ANALOG; } } + +struct QueryInfo { + u8 port; + u8 slot; + u8 lastByte; + u8 currentCommand; + u8 numBytes; + u8 queryDone; + u8 response[42]; +} query = {0,0,0,0, 0,0xFF, 0xF3}; + +int saveStateIndex = 0; + s32 CALLBACK PADinit(u32 flags) { // Note: Won't load settings if already loaded. if (LoadSettings() < 0) { @@ -572,10 +607,13 @@ s32 CALLBACK PADinit(u32 flags) { #endif pad --; - ResetPad(pad); + ResetPad(pad, 0); - pads[pad].initialized = 1; + pads[pad][0].initialized = 1; + memset(slots, 0, sizeof(slots)); + query.lastByte = 1; + query.numBytes = 0; return 0; } @@ -618,17 +656,6 @@ static const u8 queryMode[7] = {0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static const u8 setNativeMode[7] = {0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A}; -struct QueryInfo { - u8 pad; - u8 lastByte; - u8 currentCommand; - u8 numBytes; - u8 queryDone; - u8 response[42]; -} query = {0,0,0,0, 0,0xFF, 0xF3}; - -int saveStateIndex = 0; - // Implements a couple of the hacks, also responsible for monitoring device addition/removal and focus // changes. ExtraWndProcResult HackWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) { @@ -759,15 +786,14 @@ s32 CALLBACK PADopen(void *pDsp) { } restoreFullScreen = 0; } - memset(&pads[0].sum, 0, sizeof(pads[0].sum)); - memset(&pads[0].lockedSum, 0, sizeof(pads[0].lockedSum)); - pads[0].lockedState = 0; - memset(&pads[1].sum, 0, sizeof(pads[0].sum)); - memset(&pads[1].lockedSum, 0, sizeof(pads[0].lockedSum)); - pads[1].lockedState = 0; + for (int port=0; port<2; port++) { + for (int slot=0; slot<4; slot++) { + memset(&pads[port][slot].sum, 0, sizeof(pads[port][slot].sum)); + memset(&pads[port][slot].lockedSum, 0, sizeof(pads[port][slot].lockedSum)); + pads[port][slot].lockedState = 0; + } + } - query.lastByte = 1; - query.numBytes = 0; // I'd really rather use this line, but GetActiveWindow() does not have complete specs. // It *seems* to return null when no window from this thread has focus, but the // Microsoft specs seem to imply it returns the window from this thread that would have focus, @@ -794,7 +820,8 @@ u8 CALLBACK PADstartPoll(int pad) { pad--; if ((unsigned int)pad <= 1) { query.queryDone = 0; - query.pad = pad; + query.port = pad; + query.slot = slots[query.port]; query.numBytes = 2; query.lastByte = 0; DEBUG_IN(pad); @@ -835,7 +862,7 @@ u8 CALLBACK PADpoll(u8 value) { return query.response[++query.lastByte]; }//*/ int i; - Pad *pad = &pads[query.pad]; + Pad *pad = &pads[query.port][query.slot]; if (query.lastByte == 0) { query.lastByte++; query.currentCommand = value; @@ -853,7 +880,7 @@ u8 CALLBACK PADpoll(u8 value) { query.response[2] = 0x5A; { if (!config.GSThreadUpdates) { - Update(pad != pads); + Update(query.port); } ButtonSum *sum = &pad->sum; @@ -864,7 +891,7 @@ u8 CALLBACK PADpoll(u8 value) { for (i = 0; i<8; i++) { b2 -= (sum->buttons[i+4]>=128) << i; } - if (config.guitar[query.pad] && !config.GH2) { + 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; @@ -936,11 +963,11 @@ u8 CALLBACK PADpoll(u8 value) { // SET_MODE_AND_LOCK case 0x44: SET_RESULT(setMode); - ResetVibrate(pad); + ResetVibrate(query.port, query.slot); break; // QUERY_MODEL_AND_MODE case 0x45: - if (!config.guitar[query.pad] || config.GH2) SET_FINAL_RESULT(queryModelDS2) + if (config.padConfigs[query.port][query.slot].type != GuitarPad || config.GH2) SET_FINAL_RESULT(queryModelDS2) else SET_FINAL_RESULT(queryModelDS1); query.response[5] = pad->mode != MODE_DIGITAL; break; @@ -960,7 +987,7 @@ u8 CALLBACK PADpoll(u8 value) { case 0x4D: memcpy(query.response+2, pad->vibrate, 7); query.numBytes = 9; - ResetVibrate(pad); + ResetVibrate(query.port, query.slot); break; // SET_DS2_NATIVE_MODE case 0x4F: @@ -980,10 +1007,10 @@ u8 CALLBACK PADpoll(u8 value) { // READ_DATA_AND_VIBRATE case 0x42: if (query.lastByte == pad->vibrateI[0]) { - SetVibrate(pad, 1, 255*(0!=value)); + SetVibrate(query.port, query.slot, 1, 255*(0!=value)); } else if (query.lastByte == pad->vibrateI[1]) { - SetVibrate(pad, 0, value); + SetVibrate(query.port, query.slot, 0, value); } break; // CONFIG_MODE @@ -1005,7 +1032,7 @@ u8 CALLBACK PADpoll(u8 value) { } else { pad->modeLock = 0; - if (pad->mode == MODE_DIGITAL && config.AutoAnalog[query.pad]) { + if (pad->mode == MODE_DIGITAL && config.padConfigs[query.port][query.slot].autoAnalog) { pad->mode = MODE_ANALOG; } } @@ -1188,14 +1215,6 @@ keyEvent* CALLBACK PADkeyEvent() { #define PAD_SAVE_STATE_VERSION 0 -struct PadFreezeData { - u8 mode; - u8 locked; - u8 config; - u8 vibrate[8]; - u8 umask[2]; -}; - struct PadPluginFreezeData { char format[8]; // Currently all different versions are incompatible. @@ -1204,6 +1223,8 @@ struct PadPluginFreezeData { // 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. u8 port; + // active slot for port + u8 slot; // Currently only use padData[0]. Save room for all 4 slots for simplicity. PadFreezeData padData[4]; }; @@ -1215,37 +1236,40 @@ s32 CALLBACK PADfreeze(int mode, freezeData *data) { else if (mode == FREEZE_LOAD) { if (data->size < sizeof(PadPluginFreezeData)) return 0; PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data); - if (pdata.version != PAD_SAVE_STATE_VERSION || strcmp(pdata.format, "PadMode")) return 0; + if (pdata.version != PAD_SAVE_STATE_VERSION || strcmp(pdata.format, "PadMode")) { + return 0; + } StopVibrate(); int port = pdata.port; - for (int i=0; i<1; i++) { - u8 mode = pads[port].mode = pdata.padData[i].mode; + for (int slot=0; slot<4; slot++) { + u8 mode = pads[port][slot].mode = pdata.padData[slot].mode; if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE) { - ResetPad(i); + ResetPad(port, slot); continue; } - pads[port].config = pdata.padData[i].config; - pads[port].modeLock = pdata.padData[i].locked; - memcpy(pads[port].umask, pdata.padData[i].umask, sizeof(pads[port].umask)); + 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)); + slots[port] = slot; // 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. - PADstartPoll(i+1); + PADstartPoll(port+1); PADpoll(0x4D); - PADpoll(0x00); for (int j=0; j<7; j++) { - PADpoll(pdata.padData[i].vibrate[j]); + PADpoll(pdata.padData[slot].vibrate[j]); } } + slots[port] = pdata.slot; } else if (mode == FREEZE_SAVE) { if (data->size != sizeof(PadPluginFreezeData)) return 0; PadPluginFreezeData &pdata = *(PadPluginFreezeData*)(data->data); static int nextPort = 0; - if (!pads[nextPort].initialized) nextPort ^= 1; + if (!portInitialized[nextPort]) nextPort ^= 1; int port = nextPort; - if (!pads[nextPort^1].initialized) nextPort = 0; + if (!portInitialized[nextPort^1]) nextPort = 0; else nextPort ^= 1; @@ -1253,25 +1277,9 @@ s32 CALLBACK PADfreeze(int mode, freezeData *data) { strcpy(pdata.format, "PadMode"); pdata.version = PAD_SAVE_STATE_VERSION; pdata.port = port; - for (int i=0; i<1; i++) { - pdata.padData[i].mode = pads[port].mode; - pdata.padData[i].locked = pads[port].modeLock; - memcpy(pdata.padData[i].umask, pads[port].umask, sizeof(pads[port].umask)); - memcpy(pdata.padData[i].vibrate, pads[port].vibrate, sizeof(pads[port].vibrate)); - - - // 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. - pads[port].config = 1; - PADstartPoll(port+1); - PADpoll(0x4D); - PADpoll(0x00); - for (int j=0; j<7; j++) { - PADpoll(pdata.padData[port].vibrate[j]); - } - - pdata.padData[port].config = pads[port].config; + pdata.slot = slots[port]; + for (int slot=0; slot<4; slot++) { + pdata.padData[slot] = pads[port][slot]; } } else return -1; diff --git a/plugins/LilyPad/LilyPad.rc b/plugins/LilyPad/LilyPad.rc index c6cf057224..f903c77b46 100644 --- a/plugins/LilyPad/LilyPad.rc +++ b/plugins/LilyPad/LilyPad.rc @@ -89,7 +89,7 @@ BEGIN PUSHBUTTON "Left",ID_RSTICK_LEFT,324,144,35,15 PUSHBUTTON "Right",ID_RSTICK_RIGHT,364,144,35,15 PUSHBUTTON "Down",ID_RSTICK_DOWN,342,164,35,15 - GROUPBOX "",ID_FF,195,6,222,250 + GROUPBOX "",ID_FF,195,6,222,248 COMBOBOX IDC_FF_EFFECT,203,20,206,106,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "",IDC_FF_AXIS1,"msctls_trackbar32",WS_TABSTOP,199,40,214,17 CONTROL "Axis 1",IDC_FF_AXIS1_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,60,91,10 @@ -153,7 +153,7 @@ BEGIN PUSHBUTTON "Whammy Bar Down",ID_LSTICK_DOWN,219,164,69,15 PUSHBUTTON "Strum Bar Up",ID_DPAD_UP,336,146,58,15 PUSHBUTTON "Strum Bar Down",ID_DPAD_DOWN,336,164,58,15 - GROUPBOX "",ID_FF,195,6,222,250 + GROUPBOX "",ID_FF,195,6,222,248 COMBOBOX IDC_FF_EFFECT,203,20,206,106,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "",IDC_FF_AXIS1,"msctls_trackbar32",WS_TABSTOP,199,40,214,17 CONTROL "Axis 1",IDC_FF_AXIS1_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,60,91,10 @@ -220,20 +220,14 @@ BEGIN CONTROL "Disable",IDC_M_DISABLE,"Button",BS_AUTORADIOBUTTON,224,63,39,10 CONTROL "Start without mouse focus",IDC_MOUSE_UNFOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,75,97,10 CONTROL "Always hide cursor",IDC_FORCE_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,87,71,10 - GROUPBOX "Advanced",IDC_STATIC,216,103,192,27 + GROUPBOX "Advanced",IDC_STATIC,216,105,192,25 CONTROL "Allow binding multiple PS2 controls to one PC control",IDC_MULTIPLE_BINDING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,115,182,10 - GROUPBOX "Pad Options",IDC_STATIC,7,140,410,67 - GROUPBOX "Pad 1",IDC_STATIC,16,150,192,49 - CONTROL "Disable pad",IDC_DISABLE_PAD1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,162,53,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,116,182,10 + GROUPBOX "Pads",IDC_STATIC,7,140,410,67 + CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_TABSTOP,17,152,183,48,WS_EX_CLIENTEDGE + COMBOBOX IDC_PAD_TYPE,211,153,140,41,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "Use analog mode whenever possible",IDC_ANALOG_START1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,174,132,10 - CONTROL "Guitar",IDC_GUITAR1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,186,35,10 - GROUPBOX "Pad 2",IDC_STATIC,216,150,192,49 - CONTROL "Disable pad",IDC_DISABLE_PAD2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,162,53,10 - CONTROL "Use analog mode whenever possible",IDC_ANALOG_START2, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,174,132,10 - CONTROL "Guitar",IDC_GUITAR2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,186,35,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,172,132,10 GROUPBOX "Device Diagnostics",IDC_STATIC,7,211,201,99 CONTROL "",IDC_LIST,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,15,224,185,61,WS_EX_CLIENTEDGE PUSHBUTTON "Test Device",ID_TEST,86,289,57,15 diff --git a/plugins/LilyPad/XInput.cpp b/plugins/LilyPad/XInput.cpp index f20141312d..12b1d5656f 100644 --- a/plugins/LilyPad/XInput.cpp +++ b/plugins/LilyPad/XInput.cpp @@ -27,7 +27,7 @@ __forceinline int ShortToAxis(int v) { class XInputDevice : public Device { // Cached last vibration values by pad and motor. // Need this, as only one value is changed at a time. - int ps2Vibration[2][2]; + int ps2Vibration[2][4][2]; // Minor optimization - cache last set vibration values // When there's no change, no need to do anything. XINPUT_VIBRATION xInputVibration; @@ -112,15 +112,17 @@ public: return 1; } - void SetEffects(unsigned char pad, unsigned char motor, unsigned char force) { - ps2Vibration[pad][motor] = force; + void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force) { + ps2Vibration[port][slot][motor] = force; int newVibration[2] = {0,0}; for (int p=0; p<2; p++) { - for (int i=0; iaxes[0].force * (__int64)ps2Vibration[p][ffb->motor]) / 255); - newVibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][ffb->motor]) / 255); + for (int s=0; s<4; s++) { + for (int i=0; iaxes[0].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255); + newVibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255); + } } } newVibration[0] = abs(newVibration[0]); @@ -140,11 +142,11 @@ public: } void SetEffect(ForceFeedbackBinding *binding, unsigned char force) { - PadBindings pBackup = pads[0]; - pads[0].ffBindings = binding; - pads[0].numFFBindings = 1; - SetEffects(0, binding->motor, 255); - pads[0] = pBackup; + PadBindings pBackup = pads[0][0]; + pads[0][0].ffBindings = binding; + pads[0][0].numFFBindings = 1; + SetEffects(0, 0, binding->motor, 255); + pads[0][0] = pBackup; } void Deactivate() { diff --git a/plugins/LilyPad/resource.h b/plugins/LilyPad/resource.h index 7bb44e981c..1e51bec3b3 100644 --- a/plugins/LilyPad/resource.h +++ b/plugins/LilyPad/resource.h @@ -17,7 +17,6 @@ #define IDC_KB_WM 1102 #define IDC_KB_RAW 1103 #define IDC_DISABLE_PAD1 1104 -#define IDC_DISABLE_PAD2 1105 #define IDC_M_DISABLE 1106 #define IDC_M_DI 1107 #define IDC_M_WM 1108 @@ -28,27 +27,22 @@ #define IDC_CLOSE_HACK3 1113 #define IDC_DEBUG_FILE 1114 #define IDC_GUITAR1 1115 -#define IDC_GUITAR2 1116 #define IDC_ANALOG_START1 1117 -#define IDC_ANALOG_START2 1118 #define IDC_DISABLE_SCREENSAVER 1119 #define IDC_MOUSE_UNFOCUS 1120 -#define IDC_MOUSE_UNFOCUS2 1121 #define IDC_AXIS_BUTTONS 1121 #define IDC_BACKGROUND 1122 #define IDC_MULTIPLE_BINDING 1123 #define IDC_DISABLE_SCREENSAVER2 1124 #define IDC_FORCE_HIDE 1124 -#define IDC_FORCE_HIDE2 1125 #define IDC_GH2_HACK 1125 #define IDC_FORCEFEEDBACK_HACK1 1126 -#define IDC_GH2_HACK2 1126 #define IDC_VISTA_VOLUME 1126 -#define IDC_DISABLE_SCREENSAVER4 1127 -#define IDC_FORCEFEEDBACK_HACK2 1127 -#define IDC_FORCE_HIDE3 1127 #define IDC_GS_THREAD_INPUT 1128 #define IDC_SAVE_STATE_TITLE 1129 +#define IDC_PAD_LIST 1133 +#define IDC_COMBO1 1134 +#define IDC_PAD_TYPE 1134 #define IDC_SLIDER1 0x1000 #define IDC_FLIP1 0x1001 #define IDC_AXIS_DIRECTION 0x1002 @@ -148,7 +142,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 112 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1130 +#define _APS_NEXT_CONTROL_VALUE 1135 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif