Skip to content

Commit

Permalink
USB: Add keyboardmania
Browse files Browse the repository at this point in the history
Signed-off-by: jackun <[email protected]>
  • Loading branch information
aleksre authored and jackun committed Jul 10, 2021
1 parent 98b1965 commit 09a239a
Show file tree
Hide file tree
Showing 12 changed files with 481 additions and 12 deletions.
1 change: 1 addition & 0 deletions pcsx2/USB/device_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void RegisterDevice::Register()
inst.Add(DEVTYPE_EYETOY, new DeviceProxy<usb_eyetoy::EyeToyWebCamDevice>());
inst.Add(DEVTYPE_BEATMANIA_DADADA, new DeviceProxy<usb_hid::BeatManiaDevice>());
inst.Add(DEVTYPE_SEGA_SEAMIC, new DeviceProxy<usb_pad::SeamicDevice>());
inst.Add(DEVTYPE_KEYBOARDMANIA, new DeviceProxy<usb_pad::KeyboardmaniaDevice>());

RegisterAPIs();
}
Expand Down
3 changes: 2 additions & 1 deletion pcsx2/USB/deviceproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum DeviceType
DEVTYPE_EYETOY,
DEVTYPE_BEATMANIA_DADADA,
DEVTYPE_SEGA_SEAMIC,
DEVTYPE_KEYBOARDMANIA,
};

struct SelectDeviceName
Expand Down Expand Up @@ -210,7 +211,7 @@ class RegisterDevice
return *registerDevice;
}

~RegisterDevice() { }
~RegisterDevice() {}

static void Register();
void Unregister();
Expand Down
1 change: 0 additions & 1 deletion pcsx2/USB/linux/config-gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ void USBconfigure()
const char* players[] = {"Player 1:", "Player 2:"};

GtkWidget *rs_cb, *vbox;
uint32_t sel_idx = 0;

// Create the dialog window
GtkWidget* dlg = gtk_dialog_new_with_buttons(
Expand Down
78 changes: 78 additions & 0 deletions pcsx2/USB/usb-pad/dx/dinput-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ namespace usb_pad
IDC_LABEL17,
IDC_LABEL18,
IDC_LABEL19,
IDC_LABEL20,
IDC_LABEL21,
IDC_LABEL22,
IDC_LABEL23,
IDC_LABEL24,
IDC_LABEL25,
IDC_LABEL26,
IDC_LABEL27,
IDC_LABEL28,
IDC_LABEL29,
IDC_LABEL30,
};

struct DXDlgSettings
Expand Down Expand Up @@ -990,6 +1001,14 @@ namespace usb_pad
}
}
break;
case IDC_DELALL:
{
for (int i = 0; i < CID_COUNT; i++)
{
DeleteControl(s->port, (ControlID)i);
}
}
break;

case IDC_ASS0:
{
Expand Down Expand Up @@ -1091,6 +1110,61 @@ namespace usb_pad
StartListen(CID_START);
break;
}
case IDC_ASS20:
{
StartListen(CID_BUTTON20);
break;
}
case IDC_ASS21:
{
StartListen(CID_BUTTON21);
break;
}
case IDC_ASS22:
{
StartListen(CID_BUTTON22);
break;
}
case IDC_ASS23:
{
StartListen(CID_BUTTON23);
break;
}
case IDC_ASS24:
{
StartListen(CID_BUTTON24);
break;
}
case IDC_ASS25:
{
StartListen(CID_BUTTON25);
break;
}
case IDC_ASS26:
{
StartListen(CID_BUTTON26);
break;
}
case IDC_ASS27:
{
StartListen(CID_BUTTON27);
break;
}
case IDC_ASS28:
{
StartListen(CID_BUTTON28);
break;
}
case IDC_ASS29:
{
StartListen(CID_BUTTON29);
break;
}
case IDC_ASS30:
{
StartListen(CID_BUTTON30);
break;
}
case IDC_DEL0:
{
DeleteControl(s->port, CID_STEERING);
Expand Down Expand Up @@ -1390,6 +1464,10 @@ namespace usb_pad
{
return DialogBoxParam(h.hInst, MAKEINTRESOURCE(IDD_DLG_BUZZ), h.hWnd, DxDialogProc, (LPARAM)&s);
}
if (strcmp(dev_type, "keyboardmania") == 0)
{
return DialogBoxParam(h.hInst, MAKEINTRESOURCE(IDD_DLG_KEYBOARDMANIA), h.hWnd, DxDialogProc, (LPARAM)&s);
}
return DialogBoxParam(h.hInst, MAKEINTRESOURCE(IDD_DIALOG1), h.hWnd, DxDialogProc, (LPARAM)&s);
}

Expand Down
11 changes: 11 additions & 0 deletions pcsx2/USB/usb-pad/dx/dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ namespace usb_pad
CID_R3,
CID_SELECT,
CID_START,
CID_BUTTON20,
CID_BUTTON21,
CID_BUTTON22,
CID_BUTTON23,
CID_BUTTON24,
CID_BUTTON25,
CID_BUTTON26,
CID_BUTTON27,
CID_BUTTON28,
CID_BUTTON29,
CID_BUTTON30,
CID_COUNT,
};

Expand Down
13 changes: 13 additions & 0 deletions pcsx2/USB/usb-pad/dx/usb-pad-dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ namespace usb_pad
return 5;
}

if (mType == WT_KEYBOARDMANIA_CONTROLLER)
{
for (int i = 0; i < 31; i++)
{
if (GetControl(mPort, i))
{
mWheelData.buttons |= 1 << i;
}
}
pad_copy_data(mType, buf, mWheelData);
return len;
}

//Allow in both ports but warn in configure dialog that only one DX wheel is supported for now
//if(idx == 0){
//mWheelData.steering = 8191 + (int)(GetControl(STEERING, false)* 8191.0f) ;
Expand Down
24 changes: 24 additions & 0 deletions pcsx2/USB/usb-pad/dx/versionproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define IDC_STATIC -1
#define IDOK2 2
#define IDD_DLG_BUZZ 114
#define IDD_DLG_KEYBOARDMANIA 115
#define IDD_DIALOG1 202
#define IDC_DEL0 1001
#define IDC_ASS0 1002
Expand Down Expand Up @@ -165,6 +166,29 @@
#define IDC_BZ_CTL4_LBL3 1135
#define IDC_BZ_CTL4_LBL4 1136
#define IDC_BZ_CTL4_LBL5 1137
#define IDC_LABEL20 1138
#define IDC_ASS20 1139
#define IDC_LABEL21 1140
#define IDC_ASS21 1141
#define IDC_LABEL22 1142
#define IDC_ASS22 1143
#define IDC_LABEL23 1144
#define IDC_ASS23 1145
#define IDC_LABEL24 1146
#define IDC_ASS24 1147
#define IDC_LABEL25 1148
#define IDC_ASS25 1149
#define IDC_LABEL26 1150
#define IDC_ASS26 1151
#define IDC_LABEL27 1152
#define IDC_ASS27 1153
#define IDC_LABEL28 1154
#define IDC_ASS28 1155
#define IDC_LABEL29 1156
#define IDC_ASS29 1157
#define IDC_LABEL30 1158
#define IDC_ASS30 1159
#define IDC_DELALL 1160

// Next default values for new objects
//
Expand Down
80 changes: 80 additions & 0 deletions pcsx2/USB/usb-pad/dx/versionproxy.rc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,77 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,354,142,50,14
END

IDD_DLG_KEYBOARDMANIA DIALOGEX 0, 0, 580, 160
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Keyboardmania controller"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Buttons",IDC_STATIC,5,5,140,50
PUSHBUTTON "Start",IDC_ASS22,90,15,50,15
PUSHBUTTON "Select",IDC_ASS14,90,35,50,15
LTEXT "1/1/1/1",IDC_LABEL22,10,17,50,8
LTEXT "1/1/1/1",IDC_LABEL14,10,37,50,8
GROUPBOX "Wheel",IDC_STATIC,150,5,140,50
PUSHBUTTON "Up",IDC_ASS29,235,15,50,15
PUSHBUTTON "Down",IDC_ASS30,235,35,50,15
LTEXT "1/1/1/1",IDC_LABEL29,155,17,50,8
LTEXT "1/1/1/1",IDC_LABEL30,155,37,50,8

GROUPBOX "Keys",IDC_STATIC,5,60,570,70
PUSHBUTTON "C 1",IDC_ASS0,10,95,40,15
PUSHBUTTON "C# 1",IDC_ASS1,30,80,40,15
PUSHBUTTON "D 1",IDC_ASS2,50,95,40,15
PUSHBUTTON "D# 1",IDC_ASS3,70,80,40,15
PUSHBUTTON "E 1",IDC_ASS4,90,95,40,15
PUSHBUTTON "F 1",IDC_ASS5,130,95,40,15
PUSHBUTTON "F# 1",IDC_ASS6,150,80,40,15
PUSHBUTTON "G 1",IDC_ASS8,170,95,40,15
PUSHBUTTON "G# 1",IDC_ASS9,190,80,40,15
PUSHBUTTON "A 1",IDC_ASS10,210,95,40,15
PUSHBUTTON "A# 1",IDC_ASS11,230,80,40,15
PUSHBUTTON "B 1",IDC_ASS12,250,95,40,15
PUSHBUTTON "C 2",IDC_ASS13,290,95,40,15
PUSHBUTTON "C# 2",IDC_ASS16,310,80,40,15
PUSHBUTTON "D 2",IDC_ASS17,330,95,40,15
PUSHBUTTON "D# 2",IDC_ASS18,350,80,40,15
PUSHBUTTON "E 2",IDC_ASS19,370,95,40,15
PUSHBUTTON "F 2",IDC_ASS20,410,95,40,15
PUSHBUTTON "F# 2",IDC_ASS21,430,80,40,15
PUSHBUTTON "G 2",IDC_ASS24,450,95,40,15
PUSHBUTTON "G# 2",IDC_ASS25,470,80,40,15
PUSHBUTTON "A 2",IDC_ASS26,490,95,40,15
PUSHBUTTON "A# 2",IDC_ASS27,510,80,40,15
PUSHBUTTON "B 2",IDC_ASS28,530,95,40,15
LTEXT "1/1/1/1",IDC_LABEL0,10,110,38,8
LTEXT "1/1/1/1",IDC_LABEL1,30,70,38,8
LTEXT "1/1/1/1",IDC_LABEL2,50,110,38,8
LTEXT "1/1/1/1",IDC_LABEL3,70,70,38,8
LTEXT "1/1/1/1",IDC_LABEL4,90,110,38,8
LTEXT "1/1/1/1",IDC_LABEL5,130,110,38,8
LTEXT "1/1/1/1",IDC_LABEL6,150,70,38,8
LTEXT "1/1/1/1",IDC_LABEL8,170,110,38,8
LTEXT "1/1/1/1",IDC_LABEL9,190,70,38,8
LTEXT "1/1/1/1",IDC_LABEL10,210,110,38,8
LTEXT "1/1/1/1",IDC_LABEL11,230,70,38,8
LTEXT "1/1/1/1",IDC_LABEL12,250,110,38,8
LTEXT "1/1/1/1",IDC_LABEL13,290,110,38,8
LTEXT "1/1/1/1",IDC_LABEL16,310,70,38,8
LTEXT "1/1/1/1",IDC_LABEL17,330,110,38,8
LTEXT "1/1/1/1",IDC_LABEL18,350,70,38,8
LTEXT "1/1/1/1",IDC_LABEL19,370,110,38,8
LTEXT "1/1/1/1",IDC_LABEL20,410,110,38,8
LTEXT "1/1/1/1",IDC_LABEL21,430,70,38,8
LTEXT "1/1/1/1",IDC_LABEL24,450,110,38,8
LTEXT "1/1/1/1",IDC_LABEL25,470,70,38,8
LTEXT "1/1/1/1",IDC_LABEL26,490,110,38,8
LTEXT "1/1/1/1",IDC_LABEL27,510,70,38,8
LTEXT "1/1/1/1",IDC_LABEL28,530,110,38,8

PUSHBUTTON "Reset all",IDC_DELALL,5,140,50,15
DEFPUSHBUTTON "OK",IDOK,470,140,50,15
PUSHBUTTON "Cancel",IDCANCEL,525,140,50,15
END


/////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -276,6 +347,10 @@ BEGIN
IDD_DLG_BUZZ, DIALOG
BEGIN
END

IDD_DLG_KEYBOARDMANIA, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED

Expand All @@ -295,6 +370,11 @@ BEGIN
0
END

IDD_DLG_KEYBOARDMANIA AFX_DIALOG_LAYOUT
BEGIN
0
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-pad/raw/raw-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ namespace usb_pad
HidP_GetCaps(pPreparsedData, &caps);

if (caps.UsagePage == HID_USAGE_PAGE_GENERIC &&
caps.Usage == HID_USAGE_GENERIC_JOYSTICK)
(caps.Usage == HID_USAGE_GENERIC_JOYSTICK || caps.Usage == HID_USAGE_GENERIC_GAMEPAD))
{
std::wstring strPath(didData->DevicePath);
std::transform(strPath.begin(), strPath.end(), strPath.begin(), ::toupper);
Expand Down
5 changes: 4 additions & 1 deletion pcsx2/USB/usb-pad/raw/usb-pad-raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ namespace usb_pad
mOLWrite.hEvent = CreateEvent(0, 0, 0, 0);

HidD_GetAttributes(mUsbHandle, &(attr));
if (attr.VendorID != PAD_VID || attr.ProductID == 0xC262)

bool isClassicLogitech = (attr.VendorID == PAD_VID) && (attr.ProductID != 0xC262);
bool isKeyboardmania = (attr.VendorID == 0x0507) && (attr.ProductID == 0x0010);
if (!isClassicLogitech && !isKeyboardmania)
{
Console.Warning("USB: Vendor is not Logitech or wheel is G920. Not sending force feedback commands for safety reasons.\n");
mDoPassthrough = 0;
Expand Down
Loading

0 comments on commit 09a239a

Please sign in to comment.