2018-01-31 04:35:09 -07:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2021-12-09 19:22:16 -07:00
|
|
|
#include "DolphinQt/TAS/WiiTASInputWindow.h"
|
|
|
|
|
2018-06-29 03:38:37 -06:00
|
|
|
#include <cmath>
|
|
|
|
|
2018-02-06 04:10:28 -07:00
|
|
|
#include <QCheckBox>
|
2019-03-25 18:18:11 -06:00
|
|
|
#include <QGridLayout>
|
2018-02-06 04:10:28 -07:00
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QHBoxLayout>
|
2019-03-25 18:18:11 -06:00
|
|
|
#include <QSpacerItem>
|
2018-02-06 04:10:28 -07:00
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2018-01-31 04:35:09 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/FileUtil.h"
|
2021-03-21 15:42:33 -06:00
|
|
|
#include "Common/MathUtil.h"
|
2018-05-27 19:48:04 -06:00
|
|
|
|
2018-01-31 04:35:09 -07:00
|
|
|
#include "Core/Core.h"
|
2021-03-21 15:42:33 -06:00
|
|
|
#include "Core/HW/Wiimote.h"
|
2019-01-01 07:32:39 -07:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Classic.h"
|
2021-03-21 15:42:33 -06:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Extension.h"
|
2019-01-01 07:32:39 -07:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
2022-10-04 13:24:33 -06:00
|
|
|
#include "Core/HW/WiimoteEmu/MotionPlus.h"
|
2018-02-06 04:10:28 -07:00
|
|
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
2018-01-31 04:35:09 -07:00
|
|
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
2018-05-27 19:48:04 -06:00
|
|
|
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/AspectRatioWidget.h"
|
2018-07-06 23:51:34 -06:00
|
|
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
2023-07-30 16:42:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/TAS/IRWidget.h"
|
2019-03-30 20:49:57 -06:00
|
|
|
#include "DolphinQt/TAS/TASCheckBox.h"
|
2023-03-07 11:22:09 -07:00
|
|
|
#include "DolphinQt/TAS/TASSpinBox.h"
|
2018-05-27 19:48:04 -06:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
|
|
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
|
|
|
#include "InputCommon/ControllerEmu/StickGate.h"
|
2018-01-31 04:35:09 -07:00
|
|
|
#include "InputCommon/InputConfig.h"
|
|
|
|
|
2019-01-01 07:32:39 -07:00
|
|
|
using namespace WiimoteCommon;
|
|
|
|
|
2018-07-06 23:51:34 -06:00
|
|
|
WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(parent), m_num(num)
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2022-10-04 13:24:33 -06:00
|
|
|
const QKeySequence ir_x_shortcut_key_sequence = QKeySequence(Qt::ALT | Qt::Key_X);
|
|
|
|
const QKeySequence ir_y_shortcut_key_sequence = QKeySequence(Qt::ALT | Qt::Key_C);
|
2018-03-04 11:25:24 -07:00
|
|
|
|
|
|
|
m_ir_box = new QGroupBox(QStringLiteral("%1 (%2/%3)")
|
|
|
|
.arg(tr("IR"),
|
|
|
|
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
|
|
|
|
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
|
2018-02-06 04:10:28 -07:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
const int ir_x_center = static_cast<int>(std::round(ir_max_x / 2.));
|
|
|
|
const int ir_y_center = static_cast<int>(std::round(ir_max_y / 2.));
|
2020-10-18 05:47:00 -06:00
|
|
|
|
2018-02-06 04:10:28 -07:00
|
|
|
auto* x_layout = new QHBoxLayout;
|
2021-03-21 15:42:33 -06:00
|
|
|
m_ir_x_value = CreateSliderValuePair(
|
|
|
|
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
|
|
|
|
&m_wiimote_overrider, x_layout, ir_x_center, ir_x_center, ir_min_x, ir_max_x,
|
|
|
|
ir_x_shortcut_key_sequence, Qt::Horizontal, m_ir_box);
|
2018-02-06 04:10:28 -07:00
|
|
|
|
|
|
|
auto* y_layout = new QVBoxLayout;
|
2021-03-21 15:42:33 -06:00
|
|
|
m_ir_y_value = CreateSliderValuePair(
|
|
|
|
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
|
|
|
|
&m_wiimote_overrider, y_layout, ir_y_center, ir_y_center, ir_min_y, ir_max_y,
|
|
|
|
ir_y_shortcut_key_sequence, Qt::Vertical, m_ir_box);
|
2018-02-06 04:10:28 -07:00
|
|
|
m_ir_y_value->setMaximumWidth(60);
|
|
|
|
|
|
|
|
auto* visual = new IRWidget(this);
|
2021-03-21 15:42:33 -06:00
|
|
|
visual->SetX(ir_x_center);
|
|
|
|
visual->SetY(ir_y_center);
|
2020-10-18 05:47:00 -06:00
|
|
|
|
2019-07-30 07:35:46 -06:00
|
|
|
connect(m_ir_x_value, qOverload<int>(&QSpinBox::valueChanged), visual, &IRWidget::SetX);
|
|
|
|
connect(m_ir_y_value, qOverload<int>(&QSpinBox::valueChanged), visual, &IRWidget::SetY);
|
2018-02-06 04:10:28 -07:00
|
|
|
connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue);
|
|
|
|
connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue);
|
|
|
|
|
2018-02-12 13:31:40 -07:00
|
|
|
auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y);
|
2018-02-06 04:10:28 -07:00
|
|
|
|
|
|
|
auto* visual_layout = new QHBoxLayout;
|
|
|
|
visual_layout->addWidget(visual_ar);
|
|
|
|
visual_layout->addLayout(y_layout);
|
|
|
|
|
|
|
|
auto* ir_layout = new QVBoxLayout;
|
|
|
|
ir_layout->addLayout(x_layout);
|
|
|
|
ir_layout->addLayout(visual_layout);
|
|
|
|
m_ir_box->setLayout(ir_layout);
|
|
|
|
|
2023-03-07 11:30:21 -07:00
|
|
|
m_nunchuk_stick_box =
|
|
|
|
CreateStickInputs(tr("Nunchuk Stick"), WiimoteEmu::Nunchuk::STICK_GROUP, &m_nunchuk_overrider,
|
2022-10-04 13:24:33 -06:00
|
|
|
0, 0, 255, 255, Qt::Key_F, Qt::Key_G);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2018-03-04 11:25:24 -07:00
|
|
|
m_classic_left_stick_box =
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateStickInputs(tr("Left Stick"), WiimoteEmu::Classic::LEFT_STICK_GROUP,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_classic_overrider, 0, 0, 63, 63, Qt::Key_F, Qt::Key_G);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2018-03-04 11:25:24 -07:00
|
|
|
m_classic_right_stick_box =
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateStickInputs(tr("Right Stick"), WiimoteEmu::Classic::RIGHT_STICK_GROUP,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_classic_overrider, 0, 0, 31, 31, Qt::Key_Q, Qt::Key_W);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
// Need to enforce the same minimum width because otherwise the different lengths in the labels
|
|
|
|
// used on the QGroupBox will cause the StickWidgets to have different sizes.
|
|
|
|
m_ir_box->setMinimumWidth(20);
|
|
|
|
m_nunchuk_stick_box->setMinimumWidth(20);
|
|
|
|
|
|
|
|
auto* top_layout = new QHBoxLayout;
|
|
|
|
top_layout->addWidget(m_ir_box);
|
|
|
|
top_layout->addWidget(m_nunchuk_stick_box);
|
|
|
|
top_layout->addWidget(m_classic_left_stick_box);
|
|
|
|
top_layout->addWidget(m_classic_right_stick_box);
|
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
m_remote_accelerometer_box = new QGroupBox(tr("Wii Remote Accelerometer"));
|
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
constexpr u16 ACCEL_ZERO_G = WiimoteEmu::Wiimote::ACCEL_ZERO_G << 2;
|
|
|
|
constexpr u16 ACCEL_ONE_G = WiimoteEmu::Wiimote::ACCEL_ONE_G << 2;
|
|
|
|
constexpr u16 ACCEL_MIN = 0;
|
|
|
|
constexpr u16 ACCEL_MAX = (1 << 10) - 1;
|
|
|
|
constexpr double ACCEL_SCALE = (ACCEL_ONE_G - ACCEL_ZERO_G) / MathUtil::GRAVITY_ACCELERATION;
|
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
auto* remote_accelerometer_x_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("X"), WiimoteEmu::Wiimote::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_wiimote_overrider, ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_Q, m_remote_accelerometer_box, ACCEL_SCALE);
|
|
|
|
auto* remote_accelerometer_y_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("Y"), WiimoteEmu::Wiimote::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_wiimote_overrider, ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_W, m_remote_accelerometer_box, ACCEL_SCALE);
|
|
|
|
auto* remote_accelerometer_z_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("Z"), WiimoteEmu::Wiimote::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Z_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_wiimote_overrider, ACCEL_ZERO_G, ACCEL_ONE_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_E, m_remote_accelerometer_box, ACCEL_SCALE);
|
|
|
|
|
|
|
|
auto* remote_accelerometer_layout = new QVBoxLayout;
|
|
|
|
remote_accelerometer_layout->addLayout(remote_accelerometer_x_layout);
|
|
|
|
remote_accelerometer_layout->addLayout(remote_accelerometer_y_layout);
|
|
|
|
remote_accelerometer_layout->addLayout(remote_accelerometer_z_layout);
|
|
|
|
m_remote_accelerometer_box->setLayout(remote_accelerometer_layout);
|
|
|
|
|
|
|
|
m_remote_gyroscope_box = new QGroupBox(tr("Wii Remote Gyroscope"));
|
|
|
|
|
|
|
|
// MotionPlus can report values using either a slow scale (greater precision) or a fast scale
|
|
|
|
// (greater range). To ensure the user can select every possible value, TAS input uses the
|
|
|
|
// precision of the slow scale and the range of the fast scale. This does mean TAS input has more
|
|
|
|
// selectable values than MotionPlus has reportable values, but that's not too big of a problem.
|
|
|
|
constexpr double GYRO_STRETCH =
|
|
|
|
static_cast<double>(WiimoteEmu::MotionPlus::CALIBRATION_FAST_SCALE_DEGREES) /
|
|
|
|
WiimoteEmu::MotionPlus::CALIBRATION_SLOW_SCALE_DEGREES;
|
|
|
|
|
|
|
|
constexpr u32 GYRO_MIN = 0;
|
|
|
|
constexpr u32 GYRO_MAX = WiimoteEmu::MotionPlus::MAX_VALUE * GYRO_STRETCH;
|
|
|
|
constexpr u32 GYRO_ZERO = WiimoteEmu::MotionPlus::ZERO_VALUE * GYRO_STRETCH;
|
|
|
|
constexpr double GYRO_SCALE = GYRO_MAX / 2 / WiimoteEmu::MotionPlus::FAST_MAX_RAD_PER_SEC;
|
|
|
|
|
|
|
|
auto* remote_gyroscope_x_layout =
|
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
|
|
|
CreateSliderValuePairLayout(tr("X"), WiimoteEmu::Wiimote::GYROSCOPE_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
|
|
|
|
&m_wiimote_overrider, GYRO_ZERO, GYRO_ZERO, GYRO_MIN, GYRO_MAX,
|
|
|
|
Qt::Key_R, m_remote_gyroscope_box, GYRO_SCALE);
|
|
|
|
auto* remote_gyroscope_y_layout =
|
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
|
|
|
CreateSliderValuePairLayout(tr("Y"), WiimoteEmu::Wiimote::GYROSCOPE_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
|
|
|
|
&m_wiimote_overrider, GYRO_ZERO, GYRO_ZERO, GYRO_MIN, GYRO_MAX,
|
|
|
|
Qt::Key_T, m_remote_gyroscope_box, GYRO_SCALE);
|
|
|
|
auto* remote_gyroscope_z_layout =
|
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
|
|
|
CreateSliderValuePairLayout(tr("Z"), WiimoteEmu::Wiimote::GYROSCOPE_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Z_INPUT_OVERRIDE,
|
|
|
|
&m_wiimote_overrider, GYRO_ZERO, GYRO_ZERO, GYRO_MIN, GYRO_MAX,
|
|
|
|
Qt::Key_Y, m_remote_gyroscope_box, GYRO_SCALE);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
auto* remote_gyroscope_layout = new QVBoxLayout;
|
|
|
|
remote_gyroscope_layout->addLayout(remote_gyroscope_x_layout);
|
|
|
|
remote_gyroscope_layout->addLayout(remote_gyroscope_y_layout);
|
|
|
|
remote_gyroscope_layout->addLayout(remote_gyroscope_z_layout);
|
|
|
|
m_remote_gyroscope_box->setLayout(remote_gyroscope_layout);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
m_nunchuk_accelerometer_box = new QGroupBox(tr("Nunchuk Accelerometer"));
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
auto* nunchuk_accelerometer_x_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("X"), WiimoteEmu::Nunchuk::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_nunchuk_overrider, ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_I, m_nunchuk_accelerometer_box);
|
|
|
|
auto* nunchuk_accelerometer_y_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("Y"), WiimoteEmu::Nunchuk::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_nunchuk_overrider, ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_O, m_nunchuk_accelerometer_box);
|
|
|
|
auto* nunchuk_accelerometer_z_layout =
|
2018-03-04 11:08:57 -07:00
|
|
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
2021-03-21 15:42:33 -06:00
|
|
|
CreateSliderValuePairLayout(tr("Z"), WiimoteEmu::Nunchuk::ACCELEROMETER_GROUP,
|
|
|
|
ControllerEmu::ReshapableInput::Z_INPUT_OVERRIDE,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_nunchuk_overrider, ACCEL_ZERO_G, ACCEL_ONE_G, ACCEL_MIN,
|
2022-10-04 13:24:33 -06:00
|
|
|
ACCEL_MAX, Qt::Key_P, m_nunchuk_accelerometer_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2022-10-04 13:24:33 -06:00
|
|
|
auto* nunchuk_accelerometer_layout = new QVBoxLayout;
|
|
|
|
nunchuk_accelerometer_layout->addLayout(nunchuk_accelerometer_x_layout);
|
|
|
|
nunchuk_accelerometer_layout->addLayout(nunchuk_accelerometer_y_layout);
|
|
|
|
nunchuk_accelerometer_layout->addLayout(nunchuk_accelerometer_z_layout);
|
|
|
|
m_nunchuk_accelerometer_box->setLayout(nunchuk_accelerometer_layout);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
m_triggers_box = new QGroupBox(tr("Triggers"));
|
2021-03-21 15:42:33 -06:00
|
|
|
auto* l_trigger_layout = CreateSliderValuePairLayout(
|
|
|
|
tr("Left"), WiimoteEmu::Classic::TRIGGERS_GROUP, WiimoteEmu::Classic::L_ANALOG,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_classic_overrider, 0, 0, 0, 31, Qt::Key_N, m_triggers_box);
|
2021-03-21 15:42:33 -06:00
|
|
|
auto* r_trigger_layout = CreateSliderValuePairLayout(
|
|
|
|
tr("Right"), WiimoteEmu::Classic::TRIGGERS_GROUP, WiimoteEmu::Classic::R_ANALOG,
|
2023-03-07 11:30:21 -07:00
|
|
|
&m_classic_overrider, 0, 0, 0, 31, Qt::Key_M, m_triggers_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
auto* triggers_layout = new QVBoxLayout;
|
|
|
|
triggers_layout->addLayout(l_trigger_layout);
|
|
|
|
triggers_layout->addLayout(r_trigger_layout);
|
|
|
|
m_triggers_box->setLayout(triggers_layout);
|
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
m_a_button = CreateButton(QStringLiteral("&A"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::A_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_b_button = CreateButton(QStringLiteral("&B"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::B_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_1_button = CreateButton(QStringLiteral("&1"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::ONE_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_2_button = CreateButton(QStringLiteral("&2"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::TWO_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_plus_button = CreateButton(QStringLiteral("&+"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::PLUS_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_minus_button = CreateButton(QStringLiteral("&-"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::MINUS_BUTTON, &m_wiimote_overrider);
|
|
|
|
m_home_button = CreateButton(QStringLiteral("&HOME"), WiimoteEmu::Wiimote::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Wiimote::HOME_BUTTON, &m_wiimote_overrider);
|
|
|
|
|
|
|
|
m_left_button = CreateButton(QStringLiteral("&Left"), WiimoteEmu::Wiimote::DPAD_GROUP,
|
|
|
|
DIRECTION_LEFT, &m_wiimote_overrider);
|
|
|
|
m_up_button = CreateButton(QStringLiteral("&Up"), WiimoteEmu::Wiimote::DPAD_GROUP, DIRECTION_UP,
|
|
|
|
&m_wiimote_overrider);
|
|
|
|
m_down_button = CreateButton(QStringLiteral("&Down"), WiimoteEmu::Wiimote::DPAD_GROUP,
|
|
|
|
DIRECTION_DOWN, &m_wiimote_overrider);
|
|
|
|
m_right_button = CreateButton(QStringLiteral("&Right"), WiimoteEmu::Wiimote::DPAD_GROUP,
|
|
|
|
DIRECTION_RIGHT, &m_wiimote_overrider);
|
|
|
|
|
|
|
|
m_c_button = CreateButton(QStringLiteral("&C"), WiimoteEmu::Nunchuk::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Nunchuk::C_BUTTON, &m_nunchuk_overrider);
|
|
|
|
m_z_button = CreateButton(QStringLiteral("&Z"), WiimoteEmu::Nunchuk::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Nunchuk::Z_BUTTON, &m_nunchuk_overrider);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2019-03-25 18:18:11 -06:00
|
|
|
auto* buttons_layout = new QGridLayout;
|
|
|
|
buttons_layout->addWidget(m_a_button, 0, 0);
|
|
|
|
buttons_layout->addWidget(m_b_button, 0, 1);
|
|
|
|
buttons_layout->addWidget(m_1_button, 0, 2);
|
|
|
|
buttons_layout->addWidget(m_2_button, 0, 3);
|
|
|
|
buttons_layout->addWidget(m_plus_button, 0, 4);
|
|
|
|
buttons_layout->addWidget(m_minus_button, 0, 5);
|
|
|
|
|
|
|
|
buttons_layout->addWidget(m_home_button, 1, 0);
|
|
|
|
buttons_layout->addWidget(m_left_button, 1, 1);
|
|
|
|
buttons_layout->addWidget(m_up_button, 1, 2);
|
|
|
|
buttons_layout->addWidget(m_down_button, 1, 3);
|
|
|
|
buttons_layout->addWidget(m_right_button, 1, 4);
|
|
|
|
|
|
|
|
buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 0, 7);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2018-03-04 11:08:57 -07:00
|
|
|
m_remote_buttons_box = new QGroupBox(tr("Wii Remote Buttons"));
|
2019-03-25 18:18:11 -06:00
|
|
|
m_remote_buttons_box->setLayout(buttons_layout);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
auto* nunchuk_buttons_layout = new QHBoxLayout;
|
|
|
|
nunchuk_buttons_layout->addWidget(m_c_button);
|
|
|
|
nunchuk_buttons_layout->addWidget(m_z_button);
|
2019-03-25 18:18:11 -06:00
|
|
|
nunchuk_buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding));
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
m_nunchuk_buttons_box = new QGroupBox(tr("Nunchuk Buttons"));
|
|
|
|
m_nunchuk_buttons_box->setLayout(nunchuk_buttons_layout);
|
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
m_classic_a_button = CreateButton(QStringLiteral("&A"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::A_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_b_button = CreateButton(QStringLiteral("&B"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::B_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_x_button = CreateButton(QStringLiteral("&X"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::X_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_y_button = CreateButton(QStringLiteral("&Y"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::Y_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_zl_button = CreateButton(QStringLiteral("&ZL"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::ZL_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_zr_button = CreateButton(QStringLiteral("ZR"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::ZR_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_plus_button = CreateButton(QStringLiteral("&+"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::PLUS_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_minus_button = CreateButton(QStringLiteral("&-"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::MINUS_BUTTON, &m_classic_overrider);
|
|
|
|
m_classic_home_button = CreateButton(QStringLiteral("&HOME"), WiimoteEmu::Classic::BUTTONS_GROUP,
|
|
|
|
WiimoteEmu::Classic::HOME_BUTTON, &m_classic_overrider);
|
|
|
|
|
|
|
|
m_classic_l_button = CreateButton(QStringLiteral("&L"), WiimoteEmu::Classic::TRIGGERS_GROUP,
|
|
|
|
WiimoteEmu::Classic::L_DIGITAL, &m_classic_overrider);
|
|
|
|
m_classic_r_button = CreateButton(QStringLiteral("&R"), WiimoteEmu::Classic::TRIGGERS_GROUP,
|
|
|
|
WiimoteEmu::Classic::R_DIGITAL, &m_classic_overrider);
|
|
|
|
|
|
|
|
m_classic_left_button = CreateButton(QStringLiteral("L&eft"), WiimoteEmu::Classic::DPAD_GROUP,
|
|
|
|
DIRECTION_LEFT, &m_classic_overrider);
|
|
|
|
m_classic_up_button = CreateButton(QStringLiteral("&Up"), WiimoteEmu::Classic::DPAD_GROUP,
|
|
|
|
DIRECTION_UP, &m_classic_overrider);
|
|
|
|
m_classic_down_button = CreateButton(QStringLiteral("&Down"), WiimoteEmu::Classic::DPAD_GROUP,
|
|
|
|
DIRECTION_DOWN, &m_classic_overrider);
|
|
|
|
m_classic_right_button = CreateButton(QStringLiteral("R&ight"), WiimoteEmu::Classic::DPAD_GROUP,
|
|
|
|
DIRECTION_RIGHT, &m_classic_overrider);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2019-03-25 18:18:11 -06:00
|
|
|
auto* classic_buttons_layout = new QGridLayout;
|
|
|
|
classic_buttons_layout->addWidget(m_classic_a_button, 0, 0);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_b_button, 0, 1);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_x_button, 0, 2);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_y_button, 0, 3);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_l_button, 0, 4);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_r_button, 0, 5);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_zl_button, 0, 6);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_zr_button, 0, 7);
|
|
|
|
|
|
|
|
classic_buttons_layout->addWidget(m_classic_plus_button, 1, 0);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_minus_button, 1, 1);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_home_button, 1, 2);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_left_button, 1, 3);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_up_button, 1, 4);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_down_button, 1, 5);
|
|
|
|
classic_buttons_layout->addWidget(m_classic_right_button, 1, 6);
|
|
|
|
|
|
|
|
classic_buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 0, 8);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
m_classic_buttons_box = new QGroupBox(tr("Classic Buttons"));
|
|
|
|
m_classic_buttons_box->setLayout(classic_buttons_layout);
|
|
|
|
|
|
|
|
auto* layout = new QVBoxLayout;
|
|
|
|
layout->addLayout(top_layout);
|
2022-10-04 13:24:33 -06:00
|
|
|
layout->addWidget(m_remote_accelerometer_box);
|
|
|
|
layout->addWidget(m_remote_gyroscope_box);
|
|
|
|
layout->addWidget(m_nunchuk_accelerometer_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
layout->addWidget(m_triggers_box);
|
|
|
|
layout->addWidget(m_remote_buttons_box);
|
|
|
|
layout->addWidget(m_nunchuk_buttons_box);
|
|
|
|
layout->addWidget(m_classic_buttons_box);
|
2020-06-30 13:07:25 -06:00
|
|
|
layout->addWidget(m_settings_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
if (Core::IsRunning())
|
|
|
|
{
|
2021-03-21 15:42:33 -06:00
|
|
|
m_active_extension = GetWiimote()->GetActiveExtensionNumber();
|
2022-10-04 13:24:33 -06:00
|
|
|
m_is_motion_plus_attached = GetWiimote()->IsMotionPlusAttached();
|
2018-01-31 04:35:09 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-04-13 07:38:09 -06:00
|
|
|
Common::IniFile ini;
|
2018-01-31 04:35:09 -07:00
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + "WiimoteNew.ini");
|
2022-10-04 13:24:33 -06:00
|
|
|
const std::string section_name = "Wiimote" + std::to_string(num + 1);
|
|
|
|
|
2018-01-31 04:35:09 -07:00
|
|
|
std::string extension;
|
2022-10-04 13:24:33 -06:00
|
|
|
ini.GetIfExists(section_name, "Extension", &extension);
|
2018-01-31 04:35:09 -07:00
|
|
|
|
|
|
|
if (extension == "Nunchuk")
|
2021-03-21 15:42:33 -06:00
|
|
|
m_active_extension = WiimoteEmu::ExtensionNumber::NUNCHUK;
|
|
|
|
else if (extension == "Classic")
|
|
|
|
m_active_extension = WiimoteEmu::ExtensionNumber::CLASSIC;
|
|
|
|
else
|
|
|
|
m_active_extension = WiimoteEmu::ExtensionNumber::NONE;
|
2022-10-04 13:24:33 -06:00
|
|
|
|
|
|
|
m_is_motion_plus_attached = true;
|
|
|
|
ini.GetIfExists(section_name, "Extension/Attach MotionPlus", &m_is_motion_plus_attached);
|
2018-01-31 04:35:09 -07:00
|
|
|
}
|
2021-03-21 15:42:33 -06:00
|
|
|
UpdateExt();
|
2018-01-31 04:35:09 -07:00
|
|
|
}
|
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
WiimoteEmu::Wiimote* WiiTASInputWindow::GetWiimote()
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2021-03-21 15:42:33 -06:00
|
|
|
return static_cast<WiimoteEmu::Wiimote*>(Wiimote::GetConfig()->GetController(m_num));
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerEmu::Attachments* WiiTASInputWindow::GetAttachments()
|
|
|
|
{
|
|
|
|
return static_cast<ControllerEmu::Attachments*>(
|
|
|
|
GetWiimote()->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Attachments));
|
|
|
|
}
|
|
|
|
|
|
|
|
WiimoteEmu::Extension* WiiTASInputWindow::GetExtension()
|
|
|
|
{
|
|
|
|
return static_cast<WiimoteEmu::Extension*>(
|
|
|
|
GetAttachments()->GetAttachmentList()[m_active_extension].get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiiTASInputWindow::UpdateExt()
|
|
|
|
{
|
|
|
|
if (m_active_extension == WiimoteEmu::ExtensionNumber::NUNCHUK)
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2018-03-04 11:08:57 -07:00
|
|
|
setWindowTitle(tr("Wii TAS Input %1 - Wii Remote + Nunchuk").arg(m_num + 1));
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_ir_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_ir_box->show();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_nunchuk_stick_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_nunchuk_stick_box->show();
|
|
|
|
m_classic_right_stick_box->hide();
|
|
|
|
m_classic_left_stick_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_remote_accelerometer_box);
|
2022-10-04 13:24:33 -06:00
|
|
|
m_remote_accelerometer_box->show();
|
|
|
|
m_remote_gyroscope_box->setVisible(m_is_motion_plus_attached);
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_nunchuk_accelerometer_box);
|
2022-10-04 13:24:33 -06:00
|
|
|
m_nunchuk_accelerometer_box->show();
|
2018-01-31 04:35:09 -07:00
|
|
|
m_triggers_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_nunchuk_buttons_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_nunchuk_buttons_box->show();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_remote_buttons_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_remote_buttons_box->show();
|
|
|
|
m_classic_buttons_box->hide();
|
|
|
|
}
|
2021-03-21 15:42:33 -06:00
|
|
|
else if (m_active_extension == WiimoteEmu::ExtensionNumber::CLASSIC)
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
|
|
|
setWindowTitle(tr("Wii TAS Input %1 - Classic Controller").arg(m_num + 1));
|
|
|
|
m_ir_box->hide();
|
|
|
|
m_nunchuk_stick_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_classic_right_stick_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_classic_right_stick_box->show();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_classic_left_stick_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_classic_left_stick_box->show();
|
2022-10-04 13:24:33 -06:00
|
|
|
m_remote_accelerometer_box->hide();
|
|
|
|
m_remote_gyroscope_box->hide();
|
|
|
|
m_nunchuk_accelerometer_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_triggers_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_triggers_box->show();
|
|
|
|
m_remote_buttons_box->hide();
|
|
|
|
m_nunchuk_buttons_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_classic_buttons_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_classic_buttons_box->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-04 11:08:57 -07:00
|
|
|
setWindowTitle(tr("Wii TAS Input %1 - Wii Remote").arg(m_num + 1));
|
2018-01-31 04:35:09 -07:00
|
|
|
m_ir_box->show();
|
|
|
|
m_nunchuk_stick_box->hide();
|
|
|
|
m_classic_right_stick_box->hide();
|
|
|
|
m_classic_left_stick_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_remote_accelerometer_box);
|
2022-10-04 13:24:33 -06:00
|
|
|
m_remote_accelerometer_box->show();
|
|
|
|
m_remote_gyroscope_box->setVisible(m_is_motion_plus_attached);
|
|
|
|
m_nunchuk_accelerometer_box->hide();
|
2018-01-31 04:35:09 -07:00
|
|
|
m_triggers_box->hide();
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_remote_buttons_box);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_remote_buttons_box->show();
|
|
|
|
m_nunchuk_buttons_box->hide();
|
|
|
|
m_classic_buttons_box->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
void WiiTASInputWindow::hideEvent(QHideEvent* event)
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2021-03-21 15:42:33 -06:00
|
|
|
GetWiimote()->ClearInputOverrideFunction();
|
|
|
|
GetExtension()->ClearInputOverrideFunction();
|
|
|
|
}
|
2018-07-06 23:51:34 -06:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
void WiiTASInputWindow::showEvent(QShowEvent* event)
|
|
|
|
{
|
|
|
|
WiimoteEmu::Wiimote* wiimote = GetWiimote();
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
if (m_active_extension != WiimoteEmu::ExtensionNumber::CLASSIC)
|
|
|
|
wiimote->SetInputOverrideFunction(m_wiimote_overrider.GetInputOverrideFunction());
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
if (m_active_extension == WiimoteEmu::ExtensionNumber::NUNCHUK)
|
|
|
|
GetExtension()->SetInputOverrideFunction(m_nunchuk_overrider.GetInputOverrideFunction());
|
2018-01-31 04:35:09 -07:00
|
|
|
|
2021-03-21 15:42:33 -06:00
|
|
|
if (m_active_extension == WiimoteEmu::ExtensionNumber::CLASSIC)
|
|
|
|
GetExtension()->SetInputOverrideFunction(m_classic_overrider.GetInputOverrideFunction());
|
2018-01-31 04:35:09 -07:00
|
|
|
}
|