From de8d3fb1ebf5d4ba86a930e46ed5aea78e46bb73 Mon Sep 17 00:00:00 2001 From: FlatOutPS2 Date: Sun, 13 Nov 2016 01:23:59 +0100 Subject: [PATCH 1/3] LilyPad: Add PS mouse support Adds Playstation Mouse as a new pad type. For use with PS1 games only. --- plugins/LilyPad/Config.cpp | 6 ++- plugins/LilyPad/Default.ini | 12 ++++++ plugins/LilyPad/InputManager.h | 1 + plugins/LilyPad/LilyPad.cpp | 35 ++++++++++++++--- plugins/LilyPad/LilyPad.rc | 72 ++++++++++++++++++++++++++++++++++ plugins/LilyPad/Tooltips.cpp | 6 +++ plugins/LilyPad/resource.h | 1 + 7 files changed, 127 insertions(+), 6 deletions(-) diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp index 926a8a0309..8629a0a091 100644 --- a/plugins/LilyPad/Config.cpp +++ b/plugins/LilyPad/Config.cpp @@ -36,7 +36,8 @@ const wchar_t *padTypes[] = { L"Unplugged", L"Dualshock 2", L"Guitar", - L"Pop'n Music controller"}; + L"Pop'n Music controller", + L"PS1 Mouse"}; // Hacks or configurations which PCSX2 needs with a specific value void PCSX2_overrideConfig(GeneralConfig &config_in_out) @@ -1890,6 +1891,8 @@ void UpdatePadPages() psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG_GUITAR); else if (config.padConfigs[port][slot].type == PopnPad) psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG_POPN); + else if (config.padConfigs[port][slot].type == MousePad) + psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG_PS1_MOUSE); else psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG); @@ -2055,6 +2058,7 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L AddTooltip(IDC_MOUSE_UNFOCUS, hWnd); AddTooltip(IDC_MULTIPLE_BINDING, hWnd); AddTooltip(IDC_PAD_LIST, hWnd); + AddTooltip(IDC_PAD_TYPE, hWnd); AddTooltip(ID_TEST, hWnd); AddTooltip(IDC_ANALOG_START1, hWnd); diff --git a/plugins/LilyPad/Default.ini b/plugins/LilyPad/Default.ini index 55335e0354..2ea5b523ea 100644 --- a/plugins/LilyPad/Default.ini +++ b/plugins/LilyPad/Default.ini @@ -95,6 +95,12 @@ Binding 43=0x0020000D, 0, 24, 65536, 0, 0, 1, 3 Binding 44=0x0020000E, 0, 26, 65536, 0, 0, 1, 3 Binding 45=0x00200010, 0, 29, 65536, 0, 0, 1, 3 Binding 46=0x00200011, 0, 20, 65536, 0, 0, 1, 3 +Binding 47=0x00200008, 0, 29, 65536, 0, 0, 1, 4 +Binding 48=0x00200009, 0, 30, 65536, 0, 0, 1, 4 +Binding 49=0x01020013, 0, 33, 3000, 0, 0, 13172, 4 +Binding 50=0x02020013, 0, 35, 3000, 0, 0, 13172, 4 +Binding 51=0x01020014, 0, 32, 3000, 0, 0, 13172, 4 +Binding 52=0x02020014, 0, 34, 3000, 0, 0, 13172, 4 FF Binding 0=Constant 0, 0, 0, 1, 0, 65536, 1, 0 FF Binding 1=Constant 0, 1, 0, 1, 0, 0, 1, 65536 [Device 1] @@ -149,6 +155,12 @@ Binding 43=0x0020000D, 1, 24, 65536, 0, 0, 1, 3 Binding 44=0x0020000E, 1, 26, 65536, 0, 0, 1, 3 Binding 45=0x00200010, 1, 29, 65536, 0, 0, 1, 3 Binding 46=0x00200011, 1, 20, 65536, 0, 0, 1, 3 +Binding 47=0x00200008, 1, 29, 65536, 0, 0, 1, 4 +Binding 48=0x00200009, 1, 30, 65536, 0, 0, 1, 4 +Binding 49=0x01020013, 1, 33, 3000, 0, 0, 13172, 4 +Binding 50=0x02020013, 1, 35, 3000, 0, 0, 13172, 4 +Binding 51=0x01020014, 1, 32, 3000, 0, 0, 13172, 4 +Binding 52=0x02020014, 1, 34, 3000, 0, 0, 13172, 4 FF Binding 0=Constant 1, 0, 0, 1, 0, 65536, 1, 0 FF Binding 1=Constant 1, 1, 0, 1, 0, 0, 1, 65536 [Device 12] diff --git a/plugins/LilyPad/InputManager.h b/plugins/LilyPad/InputManager.h index a8b20b35f9..a0366fcdf7 100644 --- a/plugins/LilyPad/InputManager.h +++ b/plugins/LilyPad/InputManager.h @@ -37,6 +37,7 @@ enum PadType { Dualshock2Pad, GuitarPad, PopnPad, + MousePad, numPadTypes // total number of PadTypes. Add new PadType above this line. }; diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index a698ba83c5..cf9baf70d7 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -86,6 +86,7 @@ unsigned char inBuf[50]; // windowThreadId = GetWindowThreadProcessId(hWnd, 0); +#define MODE_PS1_MOUSE 0x12 #define MODE_DIGITAL 0x41 #define MODE_ANALOG 0x73 #define MODE_DS2_NATIVE 0x79 @@ -789,7 +790,10 @@ void ResetPad(int port, int slot) SetVibrate(port, slot, 1, 0); memset(&pads[port][slot], 0, sizeof(pads[0][0])); - pads[port][slot].mode = MODE_DIGITAL; + if (config.padConfigs[port][slot].type == MousePad) + pads[port][slot].mode = MODE_PS1_MOUSE; + else + pads[port][slot].mode = MODE_DIGITAL; pads[port][slot].umask[0] = pads[port][slot].umask[1] = 0xFF; // Sets up vibrate variable. ResetVibrate(port, slot); @@ -1224,6 +1228,23 @@ u8 CALLBACK PADpoll(u8 value) Update(query.port, query.slot); ButtonSum *sum = &pad->sum; + if (config.padConfigs[query.port][query.slot].type == MousePad) { + u8 b1 = 0xFC; + if (sum->buttons[5 + 4] > 0) // Left button + b1 -= 2 << 2; + if (sum->buttons[6 + 4] > 0) // Right button + b1 -= 2 << 1; + + query.response[3] = 0xFF; + query.response[4] = b1; + query.response[5] = sum->sticks[1].horiz / 2; + query.response[6] = sum->sticks[1].vert / 2; + query.numBytes = 7; + query.lastByte = 1; + DEBUG_OUT(pad->mode); + return pad->mode; + } + u8 b1 = 0xFF, b2 = 0xFF; for (i = 0; i < 4; i++) { b1 -= (sum->buttons[i] > 0) << i; @@ -1291,7 +1312,7 @@ u8 CALLBACK PADpoll(u8 value) // QUERY_DS2_ANALOG_MODE case 0x41: // Right? Wrong? No clue. - if (pad->mode == MODE_DIGITAL) { + if (pad->mode == MODE_DIGITAL || pad->mode == MODE_PS1_MOUSE) { queryMaskMode[1] = queryMaskMode[2] = queryMaskMode[3] = 0; queryMaskMode[6] = 0x00; } else { @@ -1373,8 +1394,12 @@ u8 CALLBACK PADpoll(u8 value) // SET_MODE_AND_LOCK case 0x44: if (query.lastByte == 3 && value < 2) { - static const u8 modes[2] = {MODE_DIGITAL, MODE_ANALOG}; - pad->mode = modes[value]; + if (value == 0 && config.padConfigs[query.port][query.slot].type == MousePad) { + pad->mode = MODE_PS1_MOUSE; + } else { + static const u8 modes[2] = {MODE_DIGITAL, MODE_ANALOG}; + pad->mode = modes[value]; + } } else if (query.lastByte == 4) { if (value == 3) { pad->modeLock = 3; @@ -1596,7 +1621,7 @@ s32 CALLBACK PADfreeze(int mode, freezeData *data) for (int slot = 0; slot < 4; slot++) { u8 mode = pdata.padData[port][slot].mode; - if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE) { + if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE && mode != MODE_PS1_MOUSE) { break; } diff --git a/plugins/LilyPad/LilyPad.rc b/plugins/LilyPad/LilyPad.rc index cdb05091b2..b3a0ee46aa 100644 --- a/plugins/LilyPad/LilyPad.rc +++ b/plugins/LilyPad/LilyPad.rc @@ -274,6 +274,70 @@ BEGIN PUSHBUTTON "Small Motor",ID_SMALL_MOTOR,347,291,64,14 END +IDD_CONFIG_PS1_MOUSE DIALOGEX 0, 0, 424, 318 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,183,285,WS_EX_CLIENTEDGE + PUSHBUTTON "Delete Selected",ID_DELETE,7,296,59,15 + PUSHBUTTON "Clear All",ID_CLEAR,71,296,56,15 + PUSHBUTTON "Ignore Key",ID_IGNORE,132,296,58,15 + PUSHBUTTON "Mouse",ID_MOUSE,366,30,34,15 + PUSHBUTTON "X-axis Left",ID_LSTICK_LEFT,256,112,45,15 + PUSHBUTTON "X-axis Right",ID_LSTICK_RIGHT,307,112,45,15 + PUSHBUTTON "Y-axis Up",ID_LSTICK_UP,283,92,45,15 + PUSHBUTTON "Y-axis Down",ID_LSTICK_DOWN,283,132,45,15 + PUSHBUTTON "Left-click", ID_CIRCLE,256,56,45,15 + PUSHBUTTON "Right-click", ID_CROSS,307,56,45,15 + 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 + CONTROL "Flip",IDC_FF_AXIS1_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,60,35,10 + EDITTEXT IDC_FF_AXIS1_SCALE,375,60,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "",IDC_FF_AXIS2,"msctls_trackbar32",WS_TABSTOP,199,76,214,17 + CONTROL "Axis 2",IDC_FF_AXIS2_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,96,91,10 + CONTROL "Flip",IDC_FF_AXIS2_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,96,35,10 + EDITTEXT IDC_FF_AXIS2_SCALE,375,96,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "",IDC_FF_AXIS3,"msctls_trackbar32",WS_TABSTOP,199,112,214,17 + CONTROL "Axis 3",IDC_FF_AXIS3_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,132,91,10 + CONTROL "Flip",IDC_FF_AXIS3_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,132,35,10 + EDITTEXT IDC_FF_AXIS3_SCALE,375,132,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "",IDC_FF_AXIS4,"msctls_trackbar32",WS_TABSTOP,199,148,214,17 + CONTROL "Axis 4",IDC_FF_AXIS4_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,168,91,10 + CONTROL "Flip",IDC_FF_AXIS4_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,168,35,10 + EDITTEXT IDC_FF_AXIS4_SCALE,375,168,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "",IDC_FF_AXIS5,"msctls_trackbar32",WS_TABSTOP,199,184,214,17 + CONTROL "Axis 5",IDC_FF_AXIS5_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,204,91,10 + CONTROL "Flip",IDC_FF_AXIS5_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,204,35,10 + EDITTEXT IDC_FF_AXIS5_SCALE,375,204,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "",IDC_FF_AXIS6,"msctls_trackbar32",WS_TABSTOP,199,220,214,17 + CONTROL "Axis 6",IDC_FF_AXIS6_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,240,91,10 + CONTROL "Flip",IDC_FF_AXIS6_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,302,240,35,10 + EDITTEXT IDC_FF_AXIS6_SCALE,375,240,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + PUSHBUTTON "Test",ID_TEST,196,260,59,15 + PUSHBUTTON "Back to Controls",ID_CONTROLS,196,296,59,15 + GROUPBOX "Configure Binding",ID_SENSITIVITY,195,186,222,70 + EDITTEXT IDC_AXIS_DEVICE,202,199,74,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + COMBOBOX IDC_AXIS_DIRECTION,276,197,70,47,CBS_DROPDOWNLIST | WS_TABSTOP + EDITTEXT IDC_AXIS_CONTROL,349,199,65,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Sensitivity",IDC_LABEL_SENSITIVITY,202,215,42,8 + CONTROL "Turbo",IDC_TURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,202,225,34,10 + CONTROL "",IDC_SLIDER_SENSITIVITY,"msctls_trackbar32",WS_TABSTOP,240,215,131,17 + EDITTEXT IDC_AXIS_SENSITIVITY,377,213,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + CONTROL "Flip",IDC_FLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,385,224,27,10 + LTEXT "Dead Zone",IDC_LABEL_DEADZONE,202,240,42,8 + CONTROL "",IDC_SLIDER_DEADZONE,"msctls_trackbar32",WS_TABSTOP,240,236,131,17 + EDITTEXT IDC_AXIS_DEADZONE,377,239,33,12,ES_RIGHT | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RTLREADING + PUSHBUTTON "Lock Input",ID_LOCK_ALL_INPUT,196,260,59,15 + PUSHBUTTON "Lock Direction",ID_LOCK_DIRECTION,196,278,59,15 + PUSHBUTTON "Lock Buttons",ID_LOCK_BUTTONS,196,296,59,15 + GROUPBOX "Add Force Feedback Effect",IDC_STATIC,262,260,155,51 + COMBOBOX IDC_FORCEFEEDBACK,269,273,142,106,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Big Motor",ID_BIG_MOTOR,269,291,64,14 + PUSHBUTTON "Small Motor",ID_SMALL_MOTOR,347,291,64,14 +END + 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 @@ -376,6 +440,14 @@ BEGIN BOTTOMMARGIN, 311 END + IDD_CONFIG_PS1_MOUSE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 417 + TOPMARGIN, 7 + BOTTOMMARGIN, 311 + END + IDD_GENERAL, DIALOG BEGIN LEFTMARGIN, 7 diff --git a/plugins/LilyPad/Tooltips.cpp b/plugins/LilyPad/Tooltips.cpp index 18e7d85ae8..112dd17a9f 100644 --- a/plugins/LilyPad/Tooltips.cpp +++ b/plugins/LilyPad/Tooltips.cpp @@ -46,6 +46,12 @@ LPWSTR dialog_message(int ID, bool *updateText) L"Right-click to show a pop-up menu that allows for swapping all the settings and bindings, or just the bindings of individual pad types," L"between the selected pad and one of other active pads, and clearing all the settings and bindings from the selected pad or just the bindings from a selected pad type.\n\n" L"Note: To allow swapping different kinds of pad types(like DS2 to Guitar), the \"Allow binding multiple PS2 Controls...\" option needs to be enabled as well."; + case IDC_PAD_TYPE: + return L"\"Unplugged\" disables the controller and removes the corresponding pad tab.\n\n" + L"\"Dualshock 2\" emulates the default PS2 controller for use in both PS1 and PS2 games.\n\n" + L"\"Guitar\" emulates a PS2 controller used in the Guitar Hero and Rock Band series of games.\n\n" + L"\"Pop'n Music controller\" emulates a PS2 controller used exclusively in the Japanese Pop'n Music series of games.\n\n" + L"\"PS1 Mouse\" emulates the Playstation Mouse. This controller can only be used in a number of PS1 games like \"Command & Conquer: Red Alert\" and \"Myst\"."; case IDC_ANALOG_START1: return L"Automatically switch a pad from digital mode to analog mode whenever a pad is set to digital mode, if the pad's mode is not locked." L"This removes the need for manually enabling analog mode with a press of the analog button for games that support, but do not automatically enable analog mode.\n\n" diff --git a/plugins/LilyPad/resource.h b/plugins/LilyPad/resource.h index a05bb44c86..8df65e5af6 100644 --- a/plugins/LilyPad/resource.h +++ b/plugins/LilyPad/resource.h @@ -13,6 +13,7 @@ #define IDD_DIAG 110 #define IDR_INI1 111 #define IDD_CONFIG_POPN 112 +#define IDD_CONFIG_PS1_MOUSE 113 #define IDC_CLOSE_HACK1 1099 #define IDC_KB_DISABLE 1100 #define IDC_KB_DI 1101 From d1788ac1e9efb0bcaa8d67b3afdf89a4100011de Mon Sep 17 00:00:00 2001 From: FlatOutPS2 Date: Sun, 13 Nov 2016 10:56:35 +0100 Subject: [PATCH 2/3] fix --- plugins/LilyPad/LilyPad.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/LilyPad/LilyPad.rc b/plugins/LilyPad/LilyPad.rc index b3a0ee46aa..19c76d7a2f 100644 --- a/plugins/LilyPad/LilyPad.rc +++ b/plugins/LilyPad/LilyPad.rc @@ -287,8 +287,8 @@ BEGIN PUSHBUTTON "X-axis Right",ID_LSTICK_RIGHT,307,112,45,15 PUSHBUTTON "Y-axis Up",ID_LSTICK_UP,283,92,45,15 PUSHBUTTON "Y-axis Down",ID_LSTICK_DOWN,283,132,45,15 - PUSHBUTTON "Left-click", ID_CIRCLE,256,56,45,15 - PUSHBUTTON "Right-click", ID_CROSS,307,56,45,15 + PUSHBUTTON "Left-click",ID_CIRCLE,256,56,45,15 + PUSHBUTTON "Right-click",ID_CROSS,307,56,45,15 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 From 8db9a279700155b85deaebd1b5a4b27d50e43b14 Mon Sep 17 00:00:00 2001 From: FlatOutPS2 Date: Mon, 14 Nov 2016 13:55:55 +0100 Subject: [PATCH 3/3] fix2 --- plugins/LilyPad/LilyPad.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index cf9baf70d7..b182b3481e 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -1230,10 +1230,10 @@ u8 CALLBACK PADpoll(u8 value) if (config.padConfigs[query.port][query.slot].type == MousePad) { u8 b1 = 0xFC; - if (sum->buttons[5 + 4] > 0) // Left button - b1 -= 2 << 2; - if (sum->buttons[6 + 4] > 0) // Right button - b1 -= 2 << 1; + if (sum->buttons[9] > 0) // Left button + b1 -= 8; + if (sum->buttons[10] > 0) // Right button + b1 -= 4; query.response[3] = 0xFF; query.response[4] = b1;