1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <QDialogButtonBox>
#include "controller_config.hxx"
#include "controller_config_util.hxx"
/* TODO(bunnei): ImplementMe
using common::Config;
GControllerConfig::GControllerConfig(common::Config::ControllerPort* initial_config, QWidget* parent) : QWidget(parent)
{
ui.setupUi(this);
((QGridLayout*)ui.mainStickTab->layout())->addWidget(new GStickConfig(Config::ANALOG_LEFT, Config::ANALOG_RIGHT, Config::ANALOG_UP, Config::ANALOG_DOWN, this, this), 1, 1);
((QGridLayout*)ui.cStickTab->layout())->addWidget(new GStickConfig(Config::C_LEFT, Config::C_RIGHT, Config::C_UP, Config::C_DOWN, this, this), 1, 1);
((QGridLayout*)ui.dPadTab->layout())->addWidget(new GStickConfig(Config::DPAD_LEFT, Config::DPAD_RIGHT, Config::DPAD_UP, Config::DPAD_DOWN, this, this), 1, 1);
// TODO: Arrange these more compactly?
QVBoxLayout* layout = (QVBoxLayout*)ui.buttonsTab->layout();
layout->addWidget(new GButtonConfigGroup("A Button", Config::BUTTON_A, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("B Button", Config::BUTTON_B, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("X Button", Config::BUTTON_X, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("Y Button", Config::BUTTON_Y, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("Z Button", Config::BUTTON_Z, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("L Trigger", Config::TRIGGER_L, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("R Trigger", Config::TRIGGER_R, this, ui.buttonsTab));
layout->addWidget(new GButtonConfigGroup("Start Button", Config::BUTTON_START, this, ui.buttonsTab));
memcpy(config, initial_config, sizeof(config));
emit ActivePortChanged(config[0]);
}
void GControllerConfig::OnKeyConfigChanged(common::Config::Control id, int key, const QString& name)
{
if (InputSourceJoypad())
{
config[GetActiveController()].pads.key_code[id] = key;
}
else
{
config[GetActiveController()].keys.key_code[id] = key;
}
emit ActivePortChanged(config[GetActiveController()]);
}
int GControllerConfig::GetActiveController()
{
return ui.activeControllerCB->currentIndex();
}
bool GControllerConfig::InputSourceJoypad()
{
return ui.inputSourceCB->currentIndex() == 1;
}
GControllerConfigDialog::GControllerConfigDialog(common::Config::ControllerPort* controller_ports, QWidget* parent) : QDialog(parent), config_ptr(controller_ports)
{
setWindowTitle(tr("Input configuration"));
QVBoxLayout* layout = new QVBoxLayout(this);
config_widget = new GControllerConfig(controller_ports, this);
layout->addWidget(config_widget);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
layout->addWidget(buttons);
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
connect(this, SIGNAL(accepted()), this, SLOT(EnableChanges()));
layout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(layout);
setModal(true);
show();
}
void GControllerConfigDialog::EnableChanges()
{
for (unsigned int i = 0; i < 4; ++i)
{
memcpy(&config_ptr[i], &config_widget->GetControllerConfig(i), sizeof(common::Config::ControllerPort));
if (common::g_config) {
// Apply changes if running a game
memcpy(&common::g_config->controller_ports(i), &config_widget->GetControllerConfig(i), sizeof(common::Config::ControllerPort));
}
}
}
*/
|