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

USB: Add keyboardmania #3944

Merged
merged 4 commits into from
Jul 12, 2021
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
3 changes: 0 additions & 3 deletions pcsx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ set(pcsx2USBSources
USB/shared/ringbuffer.cpp
USB/icon_buzz_24.cpp
USB/usb-msd/usb-msd-gtk.cpp
USB/usb-pad/joydev/joydev.cpp
USB/usb-pad/joydev/joydev-gtk.cpp
USB/usb-pad/evdev/shared-gtk.cpp
USB/usb-pad/evdev/evdev-ff.cpp
USB/usb-pad/evdev/evdev.cpp
Expand Down Expand Up @@ -468,7 +466,6 @@ set(pcsx2USBHeaders
USB/linux/util.h
USB/gtk.h
USB/icon_buzz_24.h
USB/usb-pad/joydev/joydev.h
USB/usb-pad/evdev/shared.h
USB/usb-pad/evdev/evdev.h
USB/usb-pad/evdev/evdev-ff.h
Expand Down
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
4 changes: 3 additions & 1 deletion pcsx2/USB/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <gtk/gtk.h>

GtkWidget* new_combobox(const char* label, GtkWidget* vbox, bool scrollable = false); // linux/config-gtk.cpp
13 changes: 9 additions & 4 deletions pcsx2/USB/linux/config-gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static void configureApi(GtkWidget* widget, gpointer data)
}
}

GtkWidget* new_combobox(const char* label, GtkWidget* vbox)
GtkWidget* new_combobox(const char* label, GtkWidget* vbox, bool scrollable)
{
GtkWidget *rs_hbox, *rs_label, *rs_cb;

Expand All @@ -199,10 +199,16 @@ GtkWidget* new_combobox(const char* label, GtkWidget* vbox)
rs_label = gtk_label_new(label);
gtk_box_pack_start(GTK_BOX(rs_hbox), rs_label, FALSE, TRUE, 5);
gtk_label_set_justify(GTK_LABEL(rs_label), GTK_JUSTIFY_RIGHT);
gtk_misc_set_alignment(GTK_MISC(rs_label), 1, 0.5);

rs_cb = gtk_combo_box_text_new();
gtk_box_pack_start(GTK_BOX(rs_hbox), rs_cb, TRUE, TRUE, 5);
if (!scrollable)
gtk_box_pack_start(GTK_BOX(rs_hbox), rs_cb, TRUE, TRUE, 5);
else
{
GtkWidget* sw = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(sw), rs_cb);
gtk_box_pack_start(GTK_BOX(rs_hbox), sw, TRUE, TRUE, 5);
}
return rs_cb;
}

Expand Down Expand Up @@ -235,7 +241,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
2 changes: 0 additions & 2 deletions pcsx2/USB/usb-eyetoy/cam-linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

#include <linux/videodev2.h>

GtkWidget* new_combobox(const char* label, GtkWidget* vbox); // src/linux/config-gtk.cpp

#define CLEAR(x) memset(&(x), 0, sizeof(x))

namespace usb_eyetoy
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <cstdio>
#include <sstream>

GtkWidget* new_combobox(const char* label, GtkWidget* vbox); // src/linux/config-gtk.cpp

namespace usb_hid
{
namespace evdev
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/USB/usb-mic/audiodev-pulse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "USB/dynlink/pulse.h"
#endif

GtkWidget* new_combobox(const char* label, GtkWidget* vbox); // src/linux/config-gtk.cpp

namespace usb_mic
{
namespace audiodev_pulse
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/USB/usb-pad/api_init_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

#include "padproxy.h"
#include "evdev/evdev.h"
#include "joydev/joydev.h"

void usb_pad::RegisterPad::Register()
{
auto& inst = RegisterPad::instance();
inst.Add("evdev", new PadProxy<evdev::EvDevPad>());
inst.Add("joydev", new PadProxy<joydev::JoyDevPad>());
}
82 changes: 80 additions & 2 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 @@ -1242,7 +1316,7 @@ namespace usb_pad
INVERTFORCES[port] = SendDlgItemMessage(hWnd, IDC_CHECK1, BM_GETCHECK, 0, 0);
useRamp = !!SendDlgItemMessage(hWnd, IDC_CHECK3, BM_GETCHECK, 0, 0);
GAINZ[port][0] = SendMessage(GetDlgItem(hWnd, IDC_SLIDER4), TBM_GETPOS, 0, 0);
FFMULTI[port][0] = SendMessage(GetDlgItem(hWnd, IDC_SLIDER5), TBM_GETPOS, 0, 0);
FFMULTI[port][0] = SendMessage(GetDlgItem(hWnd, IDC_SLIDER5), TBM_GETPOS, 0, 0);
}

void SaveDInputConfig(int port, const char* dev_type)
Expand Down Expand Up @@ -1386,10 +1460,14 @@ namespace usb_pad
struct DXDlgSettings s;
s.port = port;
s.dev_type = dev_type;
if (strcmp(dev_type, "buzz_device") == 0)
if (strcmp(dev_type, BuzzDevice::TypeName()) == 0)
{
return DialogBoxParam(h.hInst, MAKEINTRESOURCE(IDD_DLG_BUZZ), h.hWnd, DxDialogProc, (LPARAM)&s);
}
if (strcmp(dev_type, KeyboardmaniaDevice::TypeName()) == 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
Loading