aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/debugger/controller.cpp
diff options
context:
space:
mode:
authorMonsterDruide1 <5958456@gmail.com>2021-06-18 16:15:42 +0200
committerMonsterDruide1 <5958456@gmail.com>2021-09-18 23:22:00 +0200
commit31068a63a91a50d56449520312a098687537ef29 (patch)
treec5ccf9e311d2a675b0e2afff3d85ed4654047b5e /src/yuzu/debugger/controller.cpp
parent4fde9d058bf71e3f103eb53b01c03d215fdfebcb (diff)
input_common/tas: Base playback & recording system
The base playback system supports up to 8 controllers (specified by `PLAYER_NUMBER` in `tas_input.h`), which all change their inputs simulataneously when `TAS::UpdateThread` is called. The recording system uses the controller debugger to read the state of the first controller and forwards that data to the TASing system for recording. Currently, this process sadly is not frame-perfect and pixel-accurate. Co-authored-by: Naii-the-Baf <sfabian200@gmail.com> Co-authored-by: Narr-the-Reg <juangerman-13@hotmail.com>
Diffstat (limited to 'src/yuzu/debugger/controller.cpp')
-rw-r--r--src/yuzu/debugger/controller.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index c1fc695782..822d033d1e 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -6,10 +6,13 @@
#include <QLayout>
#include <QString>
#include "common/settings.h"
+#include "input_common/main.h"
+#include "input_common/tas/tas_input.h"
#include "yuzu/configuration/configure_input_player_widget.h"
#include "yuzu/debugger/controller.h"
-ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) {
+ControllerDialog::ControllerDialog(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_)
+ : QWidget(parent, Qt::Dialog), input_subsystem{input_subsystem_} {
setObjectName(QStringLiteral("Controller"));
setWindowTitle(tr("Controller P1"));
resize(500, 350);
@@ -38,6 +41,9 @@ void ControllerDialog::refreshConfiguration() {
constexpr std::size_t player = 0;
widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs);
widget->SetControllerType(players[player].controller_type);
+ ControllerCallback callback{[this](ControllerInput input) { InputController(input); }};
+ widget->SetCallBack(callback);
+ widget->repaint();
widget->SetConnectedStatus(players[player].connected);
}
@@ -67,3 +73,17 @@ void ControllerDialog::hideEvent(QHideEvent* ev) {
widget->SetConnectedStatus(false);
QWidget::hideEvent(ev);
}
+
+void ControllerDialog::RefreshTasFile() {
+ input_subsystem->GetTas()->RefreshTasFile();
+}
+
+void ControllerDialog::InputController(ControllerInput input) {
+ u32 buttons = 0;
+ int index = 0;
+ for (bool btn : input.button_values) {
+ buttons += (btn ? 1 : 0) << index;
+ index++;
+ }
+ input_subsystem->GetTas()->RecordInput(buttons, input.axis_values);
+} \ No newline at end of file