Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboardmania support #60

Merged
merged 6 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/device_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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
1 change: 1 addition & 0 deletions src/deviceproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum DeviceType
DEVTYPE_EYETOY,
DEVTYPE_BEATMANIA_DADADA,
DEVTYPE_SEGA_SEAMIC,
DEVTYPE_KEYBOARDMANIA,
};

struct SelectDeviceName {
Expand Down
32 changes: 32 additions & 0 deletions src/usb-pad/dx/dinput-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ DWORD LABELS[CID_COUNT] = {
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 @@ -944,6 +955,13 @@ INT_PTR CALLBACK DxDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
TestForce(s->port);
}
break;
case IDC_DELALL:
{
for (int i = 0; i < CID_COUNT; i++) {
DeleteControl(s->port, (ControlID)i);
}
}
break;

case IDC_ASS0: { StartListen(CID_STEERING); break; }
case IDC_ASS1: { StartListen(CID_STEERING_R); break; }
Expand All @@ -965,6 +983,17 @@ INT_PTR CALLBACK DxDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
case IDC_ASS17: { StartListen(CID_R3); break; }
case IDC_ASS18: { StartListen(CID_SELECT); break; }
case IDC_ASS19: { 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); break; }
case IDC_DEL1: { DeleteControl(s->port, CID_STEERING_R); break; }
case IDC_DEL2: { DeleteControl(s->port, CID_THROTTLE); break; }
Expand Down Expand Up @@ -1148,6 +1177,9 @@ int DInputPad::Configure(int port, const char* dev_type, void *data)
if (strcmp(dev_type, "buzz_device") == 0) {
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 src/usb-pad/dx/dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ enum ControlID
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
10 changes: 10 additions & 0 deletions src/usb-pad/dx/usb-pad-dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ int DInputPad::TokenIn(uint8_t *buf, int len)
pad_copy_data(mType, buf, mWheelData);
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){
Expand Down
24 changes: 24 additions & 0 deletions src/usb-pad/dx/versionproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define IDB_BITMAP2 112
#define IDB_BITMAP3 113
#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 @@ -169,6 +170,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 src/usb-pad/dx/versionproxy.rc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,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 @@ -317,6 +388,10 @@ BEGIN
IDD_DLG_BUZZ, DIALOG
BEGIN
END

IDD_DLG_KEYBOARDMANIA, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED

Expand Down Expand Up @@ -345,6 +420,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 src/usb-pad/raw/raw-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void populate(HWND hW, RawDlgConfig *cfg)
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))
{
OSDebugOut(TEXT("Joystick found %04X:%04X\n"), attr.VendorID, attr.ProductID);
std::wstring strPath(didData->DevicePath);
Expand Down
5 changes: 4 additions & 1 deletion src/usb-pad/raw/usb-pad-raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ int RawInputPad::Open()
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) {
fwprintf(stderr, TEXT("USBqemu: Vendor is not Logitech or wheel is G920. Not sending force feedback commands for safety reasons.\n"));
mDoPassthrough = 0;
Close();
Expand Down
Loading