From e172d0e104cca13056dbaa6f7f79eb8204b89b09 Mon Sep 17 00:00:00 2001 From: mattmenke Date: Thu, 19 Mar 2009 06:28:23 +0000 Subject: [PATCH] LilyPad: Svn release builds now have svn numbers, some configuration load/save/populate code cleanup. Two additional checkboxes that at the moment do absolutely nothing useful, so don't get too excited, probably be quite a while before I get around to hooking everything up... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@816 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/LilyPad/Config.cpp | 289 ++++++++++++++------------ plugins/LilyPad/Config.h | 40 ++-- plugins/LilyPad/LilyPad.cpp | 30 ++- plugins/LilyPad/LilyPad.rc | 8 +- plugins/LilyPad/LilyPad_VC2005.vcproj | 1 + plugins/LilyPad/resource.h | 3 +- 6 files changed, 201 insertions(+), 170 deletions(-) diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp index 3ba081f37f..2b956fefd1 100644 --- a/plugins/LilyPad/Config.cpp +++ b/plugins/LilyPad/Config.cpp @@ -32,6 +32,37 @@ int selected = 0; HWND hWnds[2][4]; HWND hWndGeneral = 0; +struct GeneralSettingsBool { + wchar_t *name; + unsigned int ControlId; + u8 defaultValue; +}; + +// Ties together config data structure, config files, and general config +// dialog. +const GeneralSettingsBool BoolOptionsInfo[] = { + {L"Force Cursor Hide", IDC_FORCE_HIDE, 0}, + {L"Mouse Unfocus", IDC_MOUSE_UNFOCUS, 1}, + {L"Background", IDC_BACKGROUND, 1}, + {L"Multiple Bindings", IDC_MULTIPLE_BINDING, 0}, + + {L"DirectInput Game Devices", IDC_G_DI, 1}, + {L"XInput", IDC_G_XI, 1}, + + {L"Multitap 1", IDC_MULTITAP1, 0}, + {L"Multitap 2", IDC_MULTITAP2, 0}, + + {L"GS Thread Updates", IDC_GS_THREAD_INPUT, 1}, + {L"Escape Fullscreen Hack", IDC_ESCAPE_FULLSCREEN_HACK, 1}, + {L"Disable Screen Saver", IDC_DISABLE_SCREENSAVER, 1}, + {L"Logging", IDC_DEBUG_FILE, 0}, + + {L"Save State in Title", IDC_SAVE_STATE_TITLE, 1}, + {L"GH2", IDC_GH2_HACK, 0}, + + {L"Vista Volume", IDC_VISTA_VOLUME, 1}, +}; + void Populate(int port, int slot); void SetupLogSlider(HWND hWndSlider) { @@ -675,26 +706,16 @@ int SaveSettings(wchar_t *file=0) { // Just check first, last, and all pad bindings. Should be more than enough. No real need to check // config path. - int noError = WritePrivateProfileInt(L"General Settings", L"Force Cursor Hide", config.forceHide, file); + int noError = 1; + + for (int i=0; i= 2 + 3*(config.multitap[0]+config.multitap[1])) { + *port = 0; + *slot = 0; + return 0; + } + if (index < 1 + 3*config.multitap[0]) { + *port = 0; + *slot = index; + } + else { + *port = 1; + *slot = index-1-3*config.multitap[0]; + } + return 1; +} + void UpdatePadList(HWND hWnd) { HWND hWndList = GetDlgItem(hWnd, IDC_PAD_LIST); HWND hWndCombo = GetDlgItem(hWnd, IDC_PAD_TYPE); HWND hWndAnalog = GetDlgItem(hWnd, IDC_ANALOG_START1); - int slot = 0; + int slot; + int port; int index = 0; - for (int port=0; port<2; port++) { - wchar_t text[100]; - wsprintf(text, L"Pad %i", port); - LVITEM item; - item.iItem = index; - item.iSubItem = 0; - item.mask = LVIF_TEXT; - item.pszText = text; - if (SendMessage(hWndList, LVM_GETITEMCOUNT, 0, 0) <= index) { - ListView_InsertItem(hWndList, &item); - } - else { + wchar_t *strings[] = {L"Disabled", L"Dualshock 2", L"Guitar"}; + for (port=0; port<2; port++) { + for (slot = 0; slot<4; slot++) { + wchar_t text[100]; + if (!slot) + wsprintf(text, L"Pad %i", port+1); + else { + if (!config.multitap[port]) continue; + wsprintf(text, L"Pad %i-%i", port+1, slot+1); + } + LVITEM item; + item.iItem = index; + item.iSubItem = 0; + item.mask = LVIF_TEXT; + item.pszText = text; + if (SendMessage(hWndList, LVM_GETITEMCOUNT, 0, 0) <= index) { + ListView_InsertItem(hWndList, &item); + } + else { + ListView_SetItem(hWndList, &item); + } + + item.iSubItem = 1; + if (2 < (unsigned int)config.padConfigs[port][slot].type) config.padConfigs[port][slot].type = Dualshock2Pad; + item.pszText = strings[config.padConfigs[port][slot].type]; ListView_SetItem(hWndList, &item); - } - item.iSubItem = 1; - wchar_t *strings[] = {L"Disabled", L"Dualshock 2", L"Guitar"}; - if (2 < (unsigned int)config.padConfigs[port][slot].type) config.padConfigs[port][slot].type = Dualshock2Pad; - item.pszText = strings[config.padConfigs[port][slot].type]; - ListView_SetItem(hWndList, &item); - - item.iSubItem = 2; - int count = 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; + item.iSubItem = 2; + int count = 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++; } - wsprintf(text, L"%i", count); - item.pszText = text; - ListView_SetItem(hWndList, &item); - index++; } + while (ListView_DeleteItem(hWndList, index)); int sel = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); - EnableWindow(hWndCombo, sel>=0); - EnableWindow(hWndAnalog, sel>=0); - if (sel < 0) { + int enable; + if (!ListIndexToPortAndSlot(sel, &port, &slot)) { + enable = 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); + enable = 1; + SendMessage(hWndCombo, CB_SETCURSEL, config.padConfigs[port][slot].type, 0); + CheckDlgButton(hWnd, IDC_ANALOG_START1, BST_CHECKED*config.padConfigs[port][slot].autoAnalog); } + EnableWindow(hWndCombo, enable); + EnableWindow(hWndAnalog, enable); } INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam) { @@ -1632,37 +1675,24 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L RefreshEnabledDevicesAndDisplay(0, hWnd, 0); UpdatePadList(hWnd); - CheckDlgButton(hWnd, IDC_BACKGROUND, BST_CHECKED * config.background); - CheckDlgButton(hWnd, IDC_FORCE_HIDE, BST_CHECKED * config.forceHide); + for (int j=0; j>1)); - CheckDlgButton(hWnd, IDC_CLOSE_HACK3, BST_CHECKED * ((config.closeHacks&4)>>2)); - CheckDlgButton(hWnd, IDC_MOUSE_UNFOCUS, BST_CHECKED * config.mouseUnfocus); - CheckDlgButton(hWnd, IDC_GS_THREAD_INPUT, BST_CHECKED * config.GSThreadUpdates); if (!ps2e) { EnableWindow(GetDlgItem(hWnd, IDC_GS_THREAD_INPUT), 0); } - CheckDlgButton(hWnd, IDC_ESCAPE_FULLSCREEN_HACK, BST_CHECKED * config.escapeFullscreenHack); - CheckDlgButton(hWnd, IDC_DISABLE_SCREENSAVER, BST_CHECKED * config.disableScreenSaver); - CheckDlgButton(hWnd, IDC_GH2_HACK, BST_CHECKED * config.GH2); - CheckDlgButton(hWnd, IDC_SAVE_STATE_TITLE, BST_CHECKED * config.saveStateTitle); - - CheckDlgButton(hWnd, IDC_VISTA_VOLUME, BST_CHECKED * config.vistaVolume); if (config.osVersion < 6) EnableWindow(GetDlgItem(hWnd, IDC_VISTA_VOLUME), 0); - CheckDlgButton(hWnd, IDC_DEBUG_FILE, BST_CHECKED * config.debug); - CheckDlgButton(hWnd, IDC_MULTIPLE_BINDING, BST_CHECKED * config.multipleBinding); - if (config.keyboardApi < 0 || config.keyboardApi > 3) config.keyboardApi = NO_API; CheckRadioButton(hWnd, IDC_KB_DISABLE, IDC_KB_RAW, IDC_KB_DISABLE + config.keyboardApi); if (config.mouseApi < 0 || config.mouseApi > 3) config.mouseApi = NO_API; CheckRadioButton(hWnd, IDC_M_DISABLE, IDC_M_RAW, IDC_M_DISABLE + config.mouseApi); - CheckDlgButton(hWnd, IDC_G_DI, BST_CHECKED * config.gameApis.directInput); - CheckDlgButton(hWnd, IDC_G_XI, BST_CHECKED * config.gameApis.xInput); - if (!InitializeRawInput()) { EnableWindow(GetDlgItem(hWnd, IDC_KB_RAW), 0); @@ -1678,11 +1708,13 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L case WM_COMMAND: 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 index = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); int sel = SendMessage(hWndCombo, CB_GETCURSEL, 0, 0); - if (pad >= 0 && sel >= 0 && sel != config.padConfigs[pad][0].type) { - config.padConfigs[pad][0].type = (PadType)sel; + int port, slot; + if (sel < 0 || !ListIndexToPortAndSlot(index, &port, &slot)) break; + if (sel != config.padConfigs[port][slot].type) { + config.padConfigs[port][slot].type = (PadType)sel; UpdatePadList(hWnd); UpdatePadPages(); RefreshEnabledDevicesAndDisplay(0, hWnd, 1); @@ -1732,11 +1764,11 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L UpdatePadList(hWnd); } 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); - } + int index = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); + int port, slot; + if (!ListIndexToPortAndSlot(index, &port, &slot)) break; + config.padConfigs[port][slot].autoAnalog = (IsDlgButtonChecked(hWnd, IDC_ANALOG_START1) == BST_CHECKED); + PropSheet_Changed(hWndProp, hWnd); } else { int t = IDC_CLOSE_HACK1; @@ -1748,28 +1780,18 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L CheckDlgButton(hWnd, IDC_CLOSE_HACK1, BST_UNCHECKED); } - config.forceHide = (IsDlgButtonChecked(hWnd, IDC_FORCE_HIDE) == BST_CHECKED); - config.closeHacks = (IsDlgButtonChecked(hWnd, IDC_CLOSE_HACK1) == BST_CHECKED) | - ((IsDlgButtonChecked(hWnd, IDC_CLOSE_HACK2) == BST_CHECKED)<<1) | - ((IsDlgButtonChecked(hWnd, IDC_CLOSE_HACK3) == BST_CHECKED)<<2); - config.background = (IsDlgButtonChecked(hWnd, IDC_BACKGROUND) == BST_CHECKED); - config.mouseUnfocus = (IsDlgButtonChecked(hWnd, IDC_MOUSE_UNFOCUS) == BST_CHECKED); + int mtap = config.multitap[0] + 2*config.multitap[1]; - config.GSThreadUpdates = (IsDlgButtonChecked(hWnd, IDC_GS_THREAD_INPUT) == BST_CHECKED); - config.escapeFullscreenHack = (IsDlgButtonChecked(hWnd, IDC_ESCAPE_FULLSCREEN_HACK) == BST_CHECKED); - - config.disableScreenSaver = (IsDlgButtonChecked(hWnd, IDC_DISABLE_SCREENSAVER) == BST_CHECKED); - config.GH2 = (IsDlgButtonChecked(hWnd, IDC_GH2_HACK) == BST_CHECKED); - config.saveStateTitle = (IsDlgButtonChecked(hWnd, IDC_SAVE_STATE_TITLE) == BST_CHECKED); - - u8 newVistaVolume = (IsDlgButtonChecked(hWnd, IDC_VISTA_VOLUME) == BST_CHECKED); - if (config.vistaVolume != newVistaVolume) { - config.vistaVolume = newVistaVolume; - SetVolume(100); + for (int j=0; j>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); +#elif (_MSC_VER != 1400) + wsprintfW(out, L"LilyPad svn %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #else wsprintfW(out, L"LilyPad %i.%i.%i", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #endif @@ -537,6 +539,11 @@ char* CALLBACK PSEgetLibName() { sprintf(version, "LilyPad Debug (r%i)", SVN_REV); return version; #else + #if (_MSC_VER != 1400) + static char version[50]; + sprintf(version, "LilyPad svn (r%i)", SVN_REV); + return version; + #endif return "LilyPad"; #endif } @@ -617,6 +624,11 @@ s32 CALLBACK PADinit(u32 flags) { query.lastByte = 1; query.numBytes = 0; + ClearKeyQueue(); + // Just in case, when resuming emulation. + QueueKeyEvent(VK_SHIFT, KEYRELEASE); + QueueKeyEvent(VK_MENU, KEYRELEASE); + QueueKeyEvent(VK_CONTROL, KEYRELEASE); return 0; } @@ -1142,21 +1154,6 @@ DWORD WINAPI RenameWindowThreadProc(void *lpParameter) { return 0; } -// For escape fullscreen hack. This doesn't work when called from another thread, for some reason. -// That includes a new thread, independent of GS and PCSX2 thread, so use this to make sure it's -// called from the right spot. -ExtraWndProcResult KillFullScreenProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) { - // Prevent infinite recursion. Could also just remove this function from the list, - // but CONTINUE_BLISSFULLY_AND_RELEASE_PROC is a safer way to do that. - static int inFunction = 0; - if (!inFunction) { - inFunction = 1; - ShowWindow(hWnd, SW_MINIMIZE); - inFunction = 0; - } - return CONTINUE_BLISSFULLY_AND_RELEASE_PROC; -} - keyEvent* CALLBACK PADkeyEvent() { if (!config.GSThreadUpdates) { Update(2); @@ -1172,7 +1169,6 @@ keyEvent* CALLBACK PADkeyEvent() { QueueKeyEvent(-2, KEYPRESS); HANDLE hThread = CreateThread(0, 0, MaximizeWindowThreadProc, 0, 0, 0); if (hThread) CloseHandle(hThread); - //ShowWindowAsync(hWnd, SW_HIDE); restoreFullScreen = 1; return 0; } @@ -1190,7 +1186,7 @@ keyEvent* CALLBACK PADkeyEvent() { saveStateIndex = (saveStateIndex+10)%10; if (config.saveStateTitle) { // GSDX only checks its window's message queue at certain points or something, so - // have to do this in another thread to prevent lockup. + // have to do this in another thread to prevent deadlock. HANDLE hThread = CreateThread(0, 0, RenameWindowThreadProc, 0, 0, 0); if (hThread) CloseHandle(hThread); } diff --git a/plugins/LilyPad/LilyPad.rc b/plugins/LilyPad/LilyPad.rc index 4f9d958551..9fd6224740 100644 --- a/plugins/LilyPad/LilyPad.rc +++ b/plugins/LilyPad/LilyPad.rc @@ -224,10 +224,12 @@ BEGIN CONTROL "Allow binding multiple PS2 controls to one PC control",IDC_MULTIPLE_BINDING, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,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,209,153,140,41,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Port 1 Multitap",IDC_MULTITAP1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,152,63,10 + CONTROL "Port 2 Multitap",IDC_MULTITAP2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,164,63,10 + CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_TABSTOP,81,152,183,48,WS_EX_CLIENTEDGE + COMBOBOX IDC_PAD_TYPE,270,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,209,172,132,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,170,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/LilyPad_VC2005.vcproj b/plugins/LilyPad/LilyPad_VC2005.vcproj index 961edad7c9..c7ac387621 100644 --- a/plugins/LilyPad/LilyPad_VC2005.vcproj +++ b/plugins/LilyPad/LilyPad_VC2005.vcproj @@ -80,6 +80,7 @@