diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp index 8fcc55938b..f69eff2407 100644 --- a/plugins/LilyPad/Config.cpp +++ b/plugins/LilyPad/Config.cpp @@ -1,7 +1,6 @@ #include "Global.h" #include "PS2Edefs.h" -#include "Resource.h" #include "Diagnostics.h" #include "DeviceEnumerator.h" #include "KeyboardQueue.h" @@ -783,14 +782,12 @@ int SaveSettings(wchar_t *file=0) { return !noError; } -static int loaded = 0; - u8 GetPrivateProfileBool(wchar_t *s1, wchar_t *s2, int def, wchar_t *ini) { return (0!=GetPrivateProfileIntW(s1, s2, def, ini)); } int LoadSettings(int force, wchar_t *file) { - if (loaded && !force) return 0; + if (dm && !force) return 0; CreateDirectory(L"inis", 0); // Could just do ClearDevices() instead, but if I ever add any extra stuff, // this will still work. @@ -826,6 +823,7 @@ int LoadSettings(int force, wchar_t *file) { if (config.closeHacks&1) config.closeHacks &= ~2; config.keyboardApi = (DeviceAPI)GetPrivateProfileIntW(L"General Settings", L"Keyboard Mode", WM, file); + if (!config.keyboardApi) config.keyboardApi = WM; config.mouseApi = (DeviceAPI) GetPrivateProfileIntW(L"General Settings", L"Mouse Mode", 0, file); config.volume = GetPrivateProfileInt(L"General Settings", L"Volume", 100, file); @@ -858,8 +856,6 @@ int LoadSettings(int force, wchar_t *file) { } } - loaded = 1; - int i=0; int multipleBinding = config.multipleBinding; // Disabling multiple binding only prevents new multiple bindings. @@ -1845,6 +1841,7 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L "\n" "Furthermore, It uses libusb to Initialize DS3 pads. Libusb can\n" "do odd things to USB and non-USB devices when it enumerates them.\n" + "\n" "That having been said, I know of no serious problems with it.\n" "\n" "I have no idea if it works with bluetooth or not.\n" @@ -1867,20 +1864,8 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L } for (i=0; i<4; i++) { - if (IsDlgButtonChecked(hWnd, IDC_KB_DISABLE+i) == BST_CHECKED) { - if (i != NO_API || config.keyboardApi == NO_API || IDOK == MessageBoxA(hWnd, - "Disabling keyboard input will prevent LilyPad from passing any\n" - "keyboard input on to PCSX2.\n" - "\n" - "This is only meant to be used if you're using two different\n" - "pad plugins. If both pads are set to LilyPad, then GS and PCSX2 \n" - "keyboard shortcuts will not work.\n" - "\n" - "Are you sure you want to do this?", "Warning", MB_OKCANCEL | MB_ICONWARNING)) { - - config.keyboardApi = (DeviceAPI)i; - } - CheckRadioButton(hWnd, IDC_KB_DISABLE, IDC_KB_RAW, IDC_KB_DISABLE + config.keyboardApi); + if (i && IsDlgButtonChecked(hWnd, IDC_KB_DISABLE+i) == BST_CHECKED) { + config.keyboardApi = (DeviceAPI)i; } if (IsDlgButtonChecked(hWnd, IDC_M_DISABLE+i) == BST_CHECKED) { config.mouseApi = (DeviceAPI)i; @@ -2006,8 +1991,8 @@ int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam) { return 0; } -void CALLBACK PADconfigure() { - // Can end up here without PadConfigure() being called first. +void Configure() { + // Can end up here without PADinit() being called first. LoadSettings(); // Can also end up here after running emulator a bit, and possibly // disabling some devices due to focus changes, or releasing mouse. @@ -2044,7 +2029,6 @@ void CALLBACK PADconfigure() { } void UnloadConfigs() { - loaded = 0; if (dm) { delete dm; dm = 0; diff --git a/plugins/LilyPad/Config.h b/plugins/LilyPad/Config.h index be5d96048a..27998324f4 100644 --- a/plugins/LilyPad/Config.h +++ b/plugins/LilyPad/Config.h @@ -73,9 +73,8 @@ void SetVolume(int volume); int LoadSettings(int force = 0, wchar_t *file = 0); -void CALLBACK PADconfigure(); - // Refreshes the set of enabled devices. void RefreshEnabledDevices(int updateDeviceList = 0); +void Configure(); #endif diff --git a/plugins/LilyPad/DeviceEnumerator.cpp b/plugins/LilyPad/DeviceEnumerator.cpp index cd41ce8fd7..0a6ce0b02a 100644 --- a/plugins/LilyPad/DeviceEnumerator.cpp +++ b/plugins/LilyPad/DeviceEnumerator.cpp @@ -14,10 +14,10 @@ void EnumDevices(int hideDXXinput) { InputDeviceManager *oldDm = dm; dm = new InputDeviceManager(); - EnumDualShock3s(); EnumHookDevices(); EnumWindowsMessagingDevices(); EnumRawInputDevices(); + EnumDualShock3s(); EnumXInputDevices(); EnumDirectInputDevices(hideDXXinput); diff --git a/plugins/LilyPad/Diagnostics.cpp b/plugins/LilyPad/Diagnostics.cpp index 6e19343fd9..2351f387ed 100644 --- a/plugins/LilyPad/Diagnostics.cpp +++ b/plugins/LilyPad/Diagnostics.cpp @@ -1,6 +1,5 @@ #include "Global.h" #include "DeviceEnumerator.h" -#include "resource.h" #include "KeyboardQueue.h" Device *dev; diff --git a/plugins/LilyPad/DualShock3.cpp b/plugins/LilyPad/DualShock3.cpp index fdc1cb8077..f37380da2e 100644 --- a/plugins/LilyPad/DualShock3.cpp +++ b/plugins/LilyPad/DualShock3.cpp @@ -43,9 +43,6 @@ _usb_control_msg pusb_control_msg; HMODULE hModLibusb = 0; -int DualShock3Possible(); -void EnumDualShock3s(); - void UninitLibUsb() { if (hModLibusb) { FreeLibrary(hModLibusb); diff --git a/plugins/LilyPad/Global.h b/plugins/LilyPad/Global.h index ef2823822c..734e365bc1 100644 --- a/plugins/LilyPad/Global.h +++ b/plugins/LilyPad/Global.h @@ -41,6 +41,10 @@ #include "PS2Etypes.h" #include "PS2Edefs.h" +#include "resource.h" +#include "InputManager.h" +#include "Config.h" + extern HINSTANCE hInst; // Needed for config screen void GetNameAndVersionString(wchar_t *out); @@ -77,8 +81,6 @@ EXPORT_C_(s32) PADfreeze(int mode, freezeData *data); EXPORT_C_(s32) PADsetSlot(u8 port, u8 slot); EXPORT_C_(s32) PADqueryMtap(u8 port); -#include "InputManager.h" -#include "Config.h" #ifdef NO_CRT #define malloc MyMalloc diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index 9a9a076f1b..59b3a09f95 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -9,7 +9,6 @@ #include "WndProcEater.h" #include "KeyboardQueue.h" #include "svnrev.h" -#include "resource.h" #include "DualShock3.h" #include "HidDevice.h" @@ -117,6 +116,8 @@ struct ButtonSum { Stick sticks[3]; }; +#define PAD_SAVE_STATE_VERSION 2 + // Freeze data, for a single pad. Basically has all pad state that // a PS2 can set. struct PadFreezeData { @@ -133,6 +134,16 @@ struct PadFreezeData { // Vibration indices. u8 vibrateI[2]; + + // Last vibration value sent to controller. + // Only used so as not to call vibration + // functions when old and new values are both 0. + u8 currentVibrate[2]; + + // Next vibrate val to send to controller. If next and current are + // both 0, nothing is sent to the controller. Otherwise, it's sent + // on every update. + u8 nextVibrate[2]; }; class Pad : public PadFreezeData { @@ -146,16 +157,6 @@ public: // Flags for which controls (buttons or axes) are locked, if any. DWORD lockedState; - // Last vibration value sent to controller. - // Only used so as not to call vibration - // functions when old and new values are both 0. - u8 currentVibrate[2]; - - // Next vibrate val to send to controller. If next and current are - // both 0, nothing is sent to the controller. Otherwise, it's sent - // on every update. - u8 nextVibrate[2]; - // 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 @@ -830,12 +831,17 @@ DWORD WINAPI MaximizeWindowThreadProc(void *lpParameter) { return 0; } +void CALLBACK PADconfigure() { + if (openCount) { + return; + } + Configure(); +} + s32 CALLBACK PADopen(void *pDsp) { if (openCount++) return 0; DEBUG_TEXT_OUT("LilyPad opened\n\n"); - // Not really needed, shouldn't do anything. - if (LoadSettings()) return -1; miceEnabled = !config.mouseUnfocus; if (!hWnd) { if (IsWindow((HWND)pDsp)) { @@ -1310,8 +1316,6 @@ keyEvent* CALLBACK PADkeyEvent() { return &ev; } -#define PAD_SAVE_STATE_VERSION 1 - struct PadPluginFreezeData { char format[8]; // Currently all different versions are incompatible. @@ -1322,7 +1326,6 @@ struct PadPluginFreezeData { u8 port; // active slot for port u8 slot; - // Currently only use padData[0]. Save room for all 4 slots for simplicity. PadFreezeData padData[4]; QueryInfo query; }; diff --git a/plugins/LilyPad/LilyPad.rc b/plugins/LilyPad/LilyPad.rc index 1fb8c2c575..1a8d01c1a6 100644 --- a/plugins/LilyPad/LilyPad.rc +++ b/plugins/LilyPad/LilyPad.rc @@ -202,19 +202,17 @@ IDD_GENERAL DIALOGEX 0, 0, 424, 327 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Input APIs",IDC_STATIC,7,6,410,141 - GROUPBOX "Keyboard API",IDC_STATIC,16,16,192,61 + GROUPBOX "Input APIs",IDC_STATIC,7,6,410,133 + GROUPBOX "Keyboard API",IDC_STATIC,16,16,192,51 CONTROL "Windows messaging (Recommended)",IDC_KB_WM,"Button",BS_AUTORADIOBUTTON | WS_GROUP,22,28,134,10 CONTROL "Raw input (XP and later only)",IDC_KB_RAW,"Button",BS_AUTORADIOBUTTON,22,40,112,10 CONTROL "DirectInput",IDC_KB_DI,"Button",BS_AUTORADIOBUTTON,22,52,112,10 - CONTROL "Disable (Intended for use with other pad plugins)",IDC_KB_DISABLE, - "Button",BS_AUTORADIOBUTTON,22,64,175,10 - GROUPBOX "Game Device APIs",IDC_STATIC,16,79,191,61 - CONTROL "DirectInput",IDC_G_DI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,91,65,10 - CONTROL "XInput (Xbox 360 controllers only)",IDC_G_XI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,103,125,10 + GROUPBOX "Game Device APIs",IDC_STATIC,16,70,191,62 + CONTROL "DirectInput",IDC_G_DI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,82,65,10 + CONTROL "XInput (Xbox 360 controllers only)",IDC_G_XI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,94,125,10 CONTROL "DualShock 3 native mode (Requires libusb)",IDC_G_DS3, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,115,151,10 - CONTROL "Monitor when in background",IDC_BACKGROUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,127,106,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,106,151,10 + CONTROL "Monitor when in background",IDC_BACKGROUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,118,106,10 GROUPBOX "Mouse API",IDC_STATIC,216,16,192,86 CONTROL "Windows messaging (Recommended)",IDC_M_WM,"Button",BS_AUTORADIOBUTTON | WS_GROUP,223,27,134,10 CONTROL "Raw input (XP and later only)",IDC_M_RAW,"Button",BS_AUTORADIOBUTTON,223,39,112,10 @@ -222,32 +220,32 @@ BEGIN CONTROL "Disable",IDC_M_DISABLE,"Button",BS_AUTORADIOBUTTON,223,63,39,10 CONTROL "Start without mouse focus",IDC_MOUSE_UNFOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,75,97,10 CONTROL "Always hide cursor",IDC_FORCE_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,87,71,10 - GROUPBOX "Advanced",IDC_STATIC,215,111,192,29 + GROUPBOX "Advanced",IDC_STATIC,215,105,192,27 CONTROL "Allow binding multiple PS2 controls to one PC control",IDC_MULTIPLE_BINDING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,124,182,10 - GROUPBOX "Pads",IDC_STATIC,7,150,410,67 - CONTROL "Port 1 Multitap",IDC_MULTITAP1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,162,63,10 - CONTROL "Port 2 Multitap",IDC_MULTITAP2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,174,63,10 - CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_TABSTOP,81,161,183,50,WS_EX_CLIENTEDGE - COMBOBOX IDC_PAD_TYPE,270,162,140,41,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,117,182,10 + GROUPBOX "Pads",IDC_STATIC,7,145,410,69 + CONTROL "Port 1 Multitap",IDC_MULTITAP1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,157,63,10 + CONTROL "Port 2 Multitap",IDC_MULTITAP2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,169,63,10 + CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_TABSTOP,81,156,183,52,WS_EX_CLIENTEDGE + COMBOBOX IDC_PAD_TYPE,270,155,140,41,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Use analog mode whenever possible",IDC_ANALOG_START1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,179,132,10 - GROUPBOX "Device Diagnostics",IDC_STATIC,7,221,201,99 - CONTROL "",IDC_LIST,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,15,234,185,61,WS_EX_CLIENTEDGE - PUSHBUTTON "Test Device",ID_TEST,86,299,57,15 - PUSHBUTTON "Refresh",ID_REFRESH,152,299,48,15 - GROUPBOX "Miscellaneous",IDC_STATIC,216,221,201,34 - CONTROL "Use GS thread",IDC_GS_THREAD_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,231,62,10 - CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,242,80,10 - CONTROL "Local volume control",IDC_VISTA_VOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,231,77,10 - CONTROL "Enable logging",IDC_DEBUG_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,242,62,10 - GROUPBOX "Hacks",IDC_STATIC,216,257,201,45 - CONTROL "Send escape on window close",IDC_CLOSE_HACK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,267,113,10 - CONTROL "Exit emulator on window close",IDC_CLOSE_HACK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,278,112,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,172,132,10 + GROUPBOX "Device Diagnostics",IDC_STATIC,7,219,201,101 + CONTROL "",IDC_LIST,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,14,231,187,65,WS_EX_CLIENTEDGE + PUSHBUTTON "Test Device",ID_TEST,87,300,57,15 + PUSHBUTTON "Refresh",ID_REFRESH,153,300,48,15 + GROUPBOX "Miscellaneous",IDC_STATIC,216,219,201,35 + CONTROL "Use GS thread",IDC_GS_THREAD_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,230,62,10 + CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,241,80,10 + CONTROL "Local volume control",IDC_VISTA_VOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,230,77,10 + CONTROL "Enable logging",IDC_DEBUG_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,241,62,10 + GROUPBOX "Hacks",IDC_STATIC,216,256,201,46 + CONTROL "Send escape on window close",IDC_CLOSE_HACK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,266,113,10 + CONTROL "Exit emulator on window close",IDC_CLOSE_HACK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,277,112,10 CONTROL "Safe fullscreen exit on escape",IDC_ESCAPE_FULLSCREEN_HACK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,289,112,10 - CONTROL "Save state # in title",IDC_SAVE_STATE_TITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,267,79,10 - CONTROL "Guitar Hero 2 Hack",IDC_GH2_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,278,76,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,288,112,10 + CONTROL "Save state # in title",IDC_SAVE_STATE_TITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,266,79,10 + CONTROL "Guitar Hero 2 Hack",IDC_GH2_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,277,76,10 PUSHBUTTON "Load Bindings",ID_LOAD,283,305,62,15 PUSHBUTTON "Save Bindings",ID_SAVE,355,305,62,15 END diff --git a/plugins/LilyPad/LilyPad_VC2008.vcproj b/plugins/LilyPad/LilyPad_VC2008.vcproj index c1fbce1b59..443601ba88 100644 --- a/plugins/LilyPad/LilyPad_VC2008.vcproj +++ b/plugins/LilyPad/LilyPad_VC2008.vcproj @@ -70,11 +70,9 @@ OutputFile="$(OutDir)\$(ProjectName)-dbg.dll" LinkIncremental="2" SuppressStartupBanner="true" - GenerateManifest="false" ModuleDefinitionFile=".\LilyPad.def" GenerateDebugInformation="true" RandomizedBaseAddress="1" - DataExecutionPrevention="0" TargetMachine="1" /> @@ -522,10 +516,11 @@ />