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: ASCII Trance Vib emulation #11616

Merged
merged 1 commit into from
Jul 27, 2024
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
14 changes: 14 additions & 0 deletions pcsx2-qt/Settings/ControllerBindingWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ui_USBBindingWidget_GTForce.h"
#include "ui_USBBindingWidget_GunCon2.h"
#include "ui_USBBindingWidget_RealPlay.h"
#include "ui_USBBindingWidget_TranceVibrator.h"

ControllerBindingWidget::ControllerBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, u32 port)
: QWidget(parent)
Expand Down Expand Up @@ -965,6 +966,7 @@ QIcon USBDeviceWidget::getIcon() const
{"hidmouse", "mouse-line"}, // HID Mouse
{"RBDrumKit", "drum-line"}, // Rock Band Drum Kit
{"BuzzDevice", "buzz-controller-line"}, // Buzz Controller
{"TranceVibrator", "trance-vibrator-line"}, // Trance Vibrator
{"webcam", "eyetoy-line"}, // EyeToy
{"beatmania", "keyboard-2-line"}, // BeatMania Da Da Da!! (Konami Keyboard)
{"seamic", "seamic-line"}, // SEGA Seamic
Expand Down Expand Up @@ -1302,6 +1304,13 @@ void USBBindingWidget::bindWidgets(std::span<const InputBindingInfo> bindings)

widget->initialize(sif, bi.bind_type, getConfigSection(), getBindingKey(bi.name));
}

if (bi.bind_type == InputBindingInfo::Type::Motor)
{
InputVibrationBindingWidget* widget = findChild<InputVibrationBindingWidget*>(QString::fromUtf8(bi.name));
if (widget)
widget->setKey(getDialog(), getConfigSection(), getBindingKey(bi.name));
}
}
}

Expand Down Expand Up @@ -1339,6 +1348,11 @@ USBBindingWidget* USBBindingWidget::createInstance(
Ui::USBBindingWidget_RealPlay().setupUi(widget);
has_template = true;
}
else if (type == "TranceVibrator")
{
Ui::USBBindingWidget_TranceVibrator().setupUi(widget);
has_template = true;
}

if (has_template)
widget->bindWidgets(bindings);
Expand Down
116 changes: 116 additions & 0 deletions pcsx2-qt/Settings/USBBindingWidget_TranceVibrator.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>USBBindingWidget_TranceVibrator</class>
<widget class="QWidget" name="USBBindingWidget_TranceVibrator">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1100</width>
<height>500</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1100</width>
<height>500</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer0">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Motor</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="InputVibrationBindingWidget" name="Motor">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>InputVibrationBindingWidget</class>
<extends>QPushButton</extends>
<header>Settings/InputBindingWidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/resources.qrc"/>
</resources>
<connections/>
</ui>
3 changes: 3 additions & 0 deletions pcsx2-qt/pcsx2-qt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@
<QtUi Include="Settings\USBBindingWidget_RealPlay.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="Settings\USBBindingWidget_TranceVibrator.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="Settings\USBDeviceWidget.ui">
<FileType>Document</FileType>
</QtUi>
Expand Down
3 changes: 3 additions & 0 deletions pcsx2-qt/pcsx2-qt.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@
<QtUi Include="Settings\USBBindingWidget_RealPlay.ui">
<Filter>Settings</Filter>
</QtUi>
<QtUi Include="Settings\USBBindingWidget_TranceVibrator.ui">
<Filter>Settings</Filter>
</QtUi>
<QtUi Include="Settings\AudioExpansionSettingsDialog.ui">
<Filter>Settings</Filter>
</QtUi>
Expand Down
19 changes: 19 additions & 0 deletions pcsx2-qt/resources/icons/black/svg/trance-vibrator-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions pcsx2-qt/resources/icons/white/svg/trance-vibrator-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pcsx2-qt/resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<file>icons/black/svg/shut-down-line.svg</file>
<file>icons/black/svg/singstar-line.svg</file>
<file>icons/black/svg/tools-line.svg</file>
<file>icons/black/svg/trance-vibrator-line.svg</file>
<file>icons/black/svg/trash-fill.svg</file>
<file>icons/black/svg/trophy-line.svg</file>
<file>icons/black/svg/tv-2-line.svg</file>
Expand Down Expand Up @@ -180,6 +181,7 @@
<file>icons/white/svg/shut-down-line.svg</file>
<file>icons/white/svg/singstar-line.svg</file>
<file>icons/white/svg/tools-line.svg</file>
<file>icons/white/svg/trance-vibrator-line.svg</file>
<file>icons/white/svg/trash-fill.svg</file>
<file>icons/white/svg/trophy-line.svg</file>
<file>icons/white/svg/tv-2-line.svg</file>
Expand Down
2 changes: 2 additions & 0 deletions pcsx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ set(pcsx2USBSources
USB/usb-pad/usb-pad-sdl-ff.cpp
USB/usb-pad/usb-pad.cpp
USB/usb-pad/usb-seamic.cpp
USB/usb-pad/usb-trance-vibrator.cpp
USB/usb-pad/usb-turntable.cpp
USB/usb-printer/usb-printer.cpp
)
Expand Down Expand Up @@ -423,6 +424,7 @@ set(pcsx2USBHeaders
USB/usb-pad/usb-realplay.h
USB/usb-pad/usb-pad-sdl-ff.h
USB/usb-pad/usb-pad.h
USB/usb-pad/usb-trance-vibrator.h
USB/usb-printer/usb-printer.h
)

Expand Down
18 changes: 18 additions & 0 deletions pcsx2/Input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,19 @@ void InputManager::AddUSBBindings(SettingsInterface& si, u32 port)
}
break;

case InputBindingInfo::Type::Motor:
{
const std::vector<std::string> bindings(si.GetStringList(section.c_str(), bind_name.c_str()));
for (const std::string& binding : bindings)
{
PadVibrationBinding vib;
vib.pad_index = Pad::NUM_CONTROLLER_PORTS + port;
ParseBindingAndGetSource(binding, &vib.motors[0].binding, &vib.motors[0].source);
s_pad_vibration_array.push_back(std::move(vib));
}
}
break;

default:
break;
}
Expand Down Expand Up @@ -1219,6 +1232,11 @@ void InputManager::OnInputDeviceDisconnected(const InputBindingKey key, const st
// Vibration
// ------------------------------------------------------------------------

void InputManager::SetUSBVibrationIntensity(u32 port, float large_or_single_motor_intensity, float small_motor_intensity)
{
SetPadVibrationIntensity(Pad::NUM_CONTROLLER_PORTS + port, large_or_single_motor_intensity, small_motor_intensity);
}

void InputManager::SetPadVibrationIntensity(u32 pad_index, float large_or_single_motor_intensity, float small_motor_intensity)
{
for (PadVibrationBinding& pad : s_pad_vibration_array)
Expand Down
1 change: 1 addition & 0 deletions pcsx2/Input/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ namespace InputManager

/// Internal method used by pads to dispatch vibration updates to input sources.
/// Intensity is normalized from 0 to 1.
void SetUSBVibrationIntensity(u32 port, float large_or_single_motor_intensity, float small_motor_intensity);
void SetPadVibrationIntensity(u32 pad_index, float large_or_single_motor_intensity, float small_motor_intensity);

/// Zeros all vibration intensities. Call when pausing.
Expand Down
2 changes: 2 additions & 0 deletions pcsx2/USB/deviceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "usb-mic/usb-mic-singstar.h"
#include "usb-msd/usb-msd.h"
#include "usb-pad/usb-pad.h"
#include "usb-pad/usb-trance-vibrator.h"
#include "usb-pad/usb-turntable.h"
#include "usb-printer/usb-printer.h"
#include "usb-lightgun/guncon2.h"
Expand Down Expand Up @@ -76,6 +77,7 @@ void RegisterDevice::Register()
inst.Add(DEVTYPE_BUZZ, new usb_pad::BuzzDevice());
inst.Add(DEVTYPE_EYETOY, new usb_eyetoy::EyeToyWebCamDevice());
inst.Add(DEVTYPE_BEATMANIA_DADADA, new usb_hid::BeatManiaDevice());
inst.Add(DEVTYPE_TRANCE_VIBRATOR, new usb_pad::TranceVibratorDevice());
inst.Add(DEVTYPE_SEGA_SEAMIC, new usb_pad::SeamicDevice());
inst.Add(DEVTYPE_PRINTER, new usb_printer::PrinterDevice());
inst.Add(DEVTYPE_KEYBOARDMANIA, new usb_pad::KeyboardmaniaDevice());
Expand Down
1 change: 1 addition & 0 deletions pcsx2/USB/deviceproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum DeviceType : s32
DEVTYPE_BUZZ,
DEVTYPE_EYETOY,
DEVTYPE_BEATMANIA_DADADA,
DEVTYPE_TRANCE_VIBRATOR,
DEVTYPE_SEGA_SEAMIC,
DEVTYPE_PRINTER,
DEVTYPE_KEYBOARDMANIA,
Expand Down
Loading