Compare commits
1 Commits
controller
...
burning-pr
Author | SHA1 | Date | |
---|---|---|---|
66ccd77115 |
@ -111,16 +111,25 @@ void EmulatedController::ReloadFromSettings() {
|
|||||||
|
|
||||||
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
||||||
|
|
||||||
// Other or debug controller should always be a pro controller
|
// Player 1 shares config with handheld. Disable controller when handheld is selected
|
||||||
if (npad_id_type != NpadIdType::Other) {
|
// if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) {
|
||||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
// Disconnect();
|
||||||
original_npad_type = npad_type;
|
// ReloadInput();
|
||||||
} else {
|
// return;
|
||||||
SetNpadStyleIndex(NpadStyleIndex::ProController);
|
//}
|
||||||
original_npad_type = npad_type;
|
|
||||||
|
// Handheld shares config with player 1. Disable controller when handheld isn't selected
|
||||||
|
if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
|
||||||
|
Disconnect();
|
||||||
|
ReloadInput();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
|
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||||
|
original_npad_type = npad_type;
|
||||||
|
|
||||||
if (player.connected) {
|
if (player.connected) {
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -593,8 +602,14 @@ bool EmulatedController::IsConfiguring() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SaveCurrentConfig() {
|
void EmulatedController::SaveCurrentConfig() {
|
||||||
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
// Other and Handheld can't alter the config from here
|
||||||
|
if (npad_id_type == NpadIdType::Other || npad_id_type == NpadIdType::Handheld) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
|
||||||
auto& player = Settings::values.players.GetValue()[player_index];
|
auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
|
|
||||||
player.connected = is_connected;
|
player.connected = is_connected;
|
||||||
player.controller_type = MapNPadToSettingsType(npad_type);
|
player.controller_type = MapNPadToSettingsType(npad_type);
|
||||||
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
|
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
|
||||||
|
@ -199,14 +199,6 @@ add_executable(yuzu
|
|||||||
util/clickable_label.h
|
util/clickable_label.h
|
||||||
util/controller_navigation.cpp
|
util/controller_navigation.cpp
|
||||||
util/controller_navigation.h
|
util/controller_navigation.h
|
||||||
util/controller_viewer/common_shapes.cpp
|
|
||||||
util/controller_viewer/common_shapes.h
|
|
||||||
util/controller_viewer/controller_base.cpp
|
|
||||||
util/controller_viewer/controller_base.h
|
|
||||||
util/controller_viewer/controller_viewer.cpp
|
|
||||||
util/controller_viewer/controller_viewer.h
|
|
||||||
util/controller_viewer/pro_controller.cpp
|
|
||||||
util/controller_viewer/pro_controller.h
|
|
||||||
util/limitable_input_dialog.cpp
|
util/limitable_input_dialog.cpp
|
||||||
util/limitable_input_dialog.h
|
util/limitable_input_dialog.h
|
||||||
util/overlay_dialog.cpp
|
util/overlay_dialog.cpp
|
||||||
|
@ -196,6 +196,7 @@ void ConfigureInput::ApplyConfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
advanced->ApplyConfiguration();
|
advanced->ApplyConfiguration();
|
||||||
|
system.HIDCore().ReloadInputDevices();
|
||||||
|
|
||||||
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
||||||
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());
|
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());
|
||||||
|
@ -89,17 +89,12 @@ void ConfigureInputPerGame::LoadConfiguration() {
|
|||||||
|
|
||||||
emulated_controller->ReloadFromSettings();
|
emulated_controller->ReloadFromSettings();
|
||||||
|
|
||||||
if (player_index > 0) {
|
if (player_index != HANDHELD_INDEX) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Handheld cases
|
// Handle Handheld cases
|
||||||
auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX];
|
auto handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
if (player.controller_type == Settings::ControllerType::Handheld) {
|
|
||||||
handheld_player = player;
|
|
||||||
} else {
|
|
||||||
handheld_player = {};
|
|
||||||
}
|
|
||||||
handheld_controller->ReloadFromSettings();
|
handheld_controller->ReloadFromSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,26 +296,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
|
is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
|
||||||
timeout_timer(std::make_unique<QTimer>()),
|
timeout_timer(std::make_unique<QTimer>()),
|
||||||
poll_timer(std::make_unique<QTimer>()), bottom_row{bottom_row_}, hid_core{hid_core_} {
|
poll_timer(std::make_unique<QTimer>()), bottom_row{bottom_row_}, hid_core{hid_core_} {
|
||||||
if (player_index == 0) {
|
|
||||||
auto* emulated_controller_p1 =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
|
||||||
auto* emulated_controller_handheld =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
emulated_controller_p1->SaveCurrentConfig();
|
|
||||||
emulated_controller_p1->EnableConfiguration();
|
|
||||||
emulated_controller_handheld->SaveCurrentConfig();
|
|
||||||
emulated_controller_handheld->EnableConfiguration();
|
|
||||||
if (emulated_controller_handheld->IsConnected(true)) {
|
|
||||||
emulated_controller_p1->Disconnect();
|
|
||||||
emulated_controller = emulated_controller_handheld;
|
|
||||||
} else {
|
|
||||||
emulated_controller = emulated_controller_p1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
||||||
emulated_controller->SaveCurrentConfig();
|
emulated_controller->SaveCurrentConfig();
|
||||||
emulated_controller->EnableConfiguration();
|
emulated_controller->EnableConfiguration();
|
||||||
}
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
@ -747,29 +732,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
UpdateMotionButtons();
|
UpdateMotionButtons();
|
||||||
const Core::HID::NpadStyleIndex type =
|
const Core::HID::NpadStyleIndex type =
|
||||||
GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
||||||
|
|
||||||
if (player_index == 0) {
|
|
||||||
auto* emulated_controller_p1 =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
|
||||||
auto* emulated_controller_handheld =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
bool is_connected = emulated_controller->IsConnected(true);
|
|
||||||
|
|
||||||
emulated_controller_p1->SetNpadStyleIndex(type);
|
|
||||||
emulated_controller_handheld->SetNpadStyleIndex(type);
|
|
||||||
if (is_connected) {
|
|
||||||
if (type == Core::HID::NpadStyleIndex::Handheld) {
|
|
||||||
emulated_controller_p1->Disconnect();
|
|
||||||
emulated_controller_handheld->Connect(true);
|
|
||||||
emulated_controller = emulated_controller_handheld;
|
|
||||||
} else {
|
|
||||||
emulated_controller_handheld->Disconnect();
|
|
||||||
emulated_controller_p1->Connect(true);
|
|
||||||
emulated_controller = emulated_controller_p1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->controllerFrame->SetController(emulated_controller);
|
|
||||||
}
|
|
||||||
emulated_controller->SetNpadStyleIndex(type);
|
emulated_controller->SetNpadStyleIndex(type);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -805,32 +767,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigureInputPlayer::~ConfigureInputPlayer() {
|
ConfigureInputPlayer::~ConfigureInputPlayer() {
|
||||||
if (player_index == 0) {
|
|
||||||
auto* emulated_controller_p1 =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
|
||||||
auto* emulated_controller_handheld =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
emulated_controller_p1->DisableConfiguration();
|
|
||||||
emulated_controller_handheld->DisableConfiguration();
|
|
||||||
} else {
|
|
||||||
emulated_controller->DisableConfiguration();
|
emulated_controller->DisableConfiguration();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureInputPlayer::ApplyConfiguration() {
|
void ConfigureInputPlayer::ApplyConfiguration() {
|
||||||
if (player_index == 0) {
|
|
||||||
auto* emulated_controller_p1 =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
|
||||||
auto* emulated_controller_handheld =
|
|
||||||
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
|
||||||
emulated_controller_p1->DisableConfiguration();
|
|
||||||
emulated_controller_p1->SaveCurrentConfig();
|
|
||||||
emulated_controller_p1->EnableConfiguration();
|
|
||||||
emulated_controller_handheld->DisableConfiguration();
|
|
||||||
emulated_controller_handheld->SaveCurrentConfig();
|
|
||||||
emulated_controller_handheld->EnableConfiguration();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emulated_controller->DisableConfiguration();
|
emulated_controller->DisableConfiguration();
|
||||||
emulated_controller->SaveCurrentConfig();
|
emulated_controller->SaveCurrentConfig();
|
||||||
emulated_controller->EnableConfiguration();
|
emulated_controller->EnableConfiguration();
|
||||||
|
@ -1,407 +0,0 @@
|
|||||||
// Copyright 2020 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "common/input.h"
|
|
||||||
#include "yuzu/util/controller_viewer/common_shapes.h"
|
|
||||||
|
|
||||||
namespace ControllerViewer {
|
|
||||||
|
|
||||||
void CommonShapes::DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery,
|
|
||||||
QColor outline, QColor battery_color, QColor charging_outline,
|
|
||||||
QColor charging_color) {
|
|
||||||
if (battery == Common::Input::BatteryLevel::None) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Draw outline
|
|
||||||
p.setPen(QPen(outline, 5));
|
|
||||||
p.setBrush(Qt::transparent);
|
|
||||||
p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2);
|
|
||||||
|
|
||||||
p.setPen(QPen(outline, 3));
|
|
||||||
p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7);
|
|
||||||
|
|
||||||
// Draw Battery shape
|
|
||||||
p.setPen(QPen(battery_color, 3));
|
|
||||||
p.setBrush(Qt::transparent);
|
|
||||||
p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2);
|
|
||||||
|
|
||||||
p.setPen(QPen(battery_color, 1));
|
|
||||||
p.setBrush(battery_color);
|
|
||||||
p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7);
|
|
||||||
switch (battery) {
|
|
||||||
case Common::Input::BatteryLevel::Charging:
|
|
||||||
p.drawRect(center.x(), center.y(), 34, 16);
|
|
||||||
p.setPen(charging_outline);
|
|
||||||
p.setBrush(charging_color);
|
|
||||||
DrawSymbol(p, center + QPointF(17.0f, 8.0f), Symbol::Charging, 2.1f);
|
|
||||||
break;
|
|
||||||
case Common::Input::BatteryLevel::Full:
|
|
||||||
p.drawRect(center.x(), center.y(), 34, 16);
|
|
||||||
break;
|
|
||||||
case Common::Input::BatteryLevel::Medium:
|
|
||||||
p.drawRect(center.x(), center.y(), 25, 16);
|
|
||||||
break;
|
|
||||||
case Common::Input::BatteryLevel::Low:
|
|
||||||
p.drawRect(center.x(), center.y(), 17, 16);
|
|
||||||
break;
|
|
||||||
case Common::Input::BatteryLevel::Critical:
|
|
||||||
p.drawRect(center.x(), center.y(), 6, 16);
|
|
||||||
break;
|
|
||||||
case Common::Input::BatteryLevel::Empty:
|
|
||||||
p.drawRect(center.x(), center.y(), 3, 16);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::DrawSymbol(QPainter& p, const QPointF center, Symbol symbol, float icon_size) {
|
|
||||||
std::array<QPointF, house.size() / 2> house_icon;
|
|
||||||
std::array<QPointF, symbol_a.size() / 2> a_icon;
|
|
||||||
std::array<QPointF, symbol_b.size() / 2> b_icon;
|
|
||||||
std::array<QPointF, symbol_x.size() / 2> x_icon;
|
|
||||||
std::array<QPointF, symbol_y.size() / 2> y_icon;
|
|
||||||
std::array<QPointF, symbol_l.size() / 2> l_icon;
|
|
||||||
std::array<QPointF, symbol_r.size() / 2> r_icon;
|
|
||||||
std::array<QPointF, symbol_c.size() / 2> c_icon;
|
|
||||||
std::array<QPointF, symbol_zl.size() / 2> zl_icon;
|
|
||||||
std::array<QPointF, symbol_sl.size() / 2> sl_icon;
|
|
||||||
std::array<QPointF, symbol_zr.size() / 2> zr_icon;
|
|
||||||
std::array<QPointF, symbol_sr.size() / 2> sr_icon;
|
|
||||||
std::array<QPointF, symbol_charging.size() / 2> charging_icon;
|
|
||||||
switch (symbol) {
|
|
||||||
case Symbol::House:
|
|
||||||
for (std::size_t point = 0; point < house.size() / 2; ++point) {
|
|
||||||
house_icon[point] = center + QPointF(house[point * 2] * icon_size,
|
|
||||||
(house[point * 2 + 1] - 0.025f) * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(house_icon.data(), static_cast<int>(house_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::A:
|
|
||||||
for (std::size_t point = 0; point < symbol_a.size() / 2; ++point) {
|
|
||||||
a_icon[point] = center + QPointF(symbol_a[point * 2] * icon_size,
|
|
||||||
symbol_a[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(a_icon.data(), static_cast<int>(a_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::B:
|
|
||||||
for (std::size_t point = 0; point < symbol_b.size() / 2; ++point) {
|
|
||||||
b_icon[point] = center + QPointF(symbol_b[point * 2] * icon_size,
|
|
||||||
symbol_b[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(b_icon.data(), static_cast<int>(b_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::X:
|
|
||||||
for (std::size_t point = 0; point < symbol_x.size() / 2; ++point) {
|
|
||||||
x_icon[point] = center + QPointF(symbol_x[point * 2] * icon_size,
|
|
||||||
symbol_x[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(x_icon.data(), static_cast<int>(x_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::Y:
|
|
||||||
for (std::size_t point = 0; point < symbol_y.size() / 2; ++point) {
|
|
||||||
y_icon[point] = center + QPointF(symbol_y[point * 2] * icon_size,
|
|
||||||
(symbol_y[point * 2 + 1] - 1.0f) * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(y_icon.data(), static_cast<int>(y_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::L:
|
|
||||||
for (std::size_t point = 0; point < symbol_l.size() / 2; ++point) {
|
|
||||||
l_icon[point] = center + QPointF(symbol_l[point * 2] * icon_size,
|
|
||||||
(symbol_l[point * 2 + 1] - 1.0f) * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(l_icon.data(), static_cast<int>(l_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::R:
|
|
||||||
for (std::size_t point = 0; point < symbol_r.size() / 2; ++point) {
|
|
||||||
r_icon[point] = center + QPointF(symbol_r[point * 2] * icon_size,
|
|
||||||
(symbol_r[point * 2 + 1] - 1.0f) * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(r_icon.data(), static_cast<int>(r_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::C:
|
|
||||||
for (std::size_t point = 0; point < symbol_c.size() / 2; ++point) {
|
|
||||||
c_icon[point] = center + QPointF(symbol_c[point * 2] * icon_size,
|
|
||||||
(symbol_c[point * 2 + 1] - 1.0f) * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(c_icon.data(), static_cast<int>(c_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::ZL:
|
|
||||||
for (std::size_t point = 0; point < symbol_zl.size() / 2; ++point) {
|
|
||||||
zl_icon[point] = center + QPointF(symbol_zl[point * 2] * icon_size,
|
|
||||||
symbol_zl[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(zl_icon.data(), static_cast<int>(zl_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::SL:
|
|
||||||
for (std::size_t point = 0; point < symbol_sl.size() / 2; ++point) {
|
|
||||||
sl_icon[point] = center + QPointF(symbol_sl[point * 2] * icon_size,
|
|
||||||
symbol_sl[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(sl_icon.data(), static_cast<int>(sl_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::ZR:
|
|
||||||
for (std::size_t point = 0; point < symbol_zr.size() / 2; ++point) {
|
|
||||||
zr_icon[point] = center + QPointF(symbol_zr[point * 2] * icon_size,
|
|
||||||
symbol_zr[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(zr_icon.data(), static_cast<int>(zr_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::SR:
|
|
||||||
for (std::size_t point = 0; point < symbol_sr.size() / 2; ++point) {
|
|
||||||
sr_icon[point] = center + QPointF(symbol_sr[point * 2] * icon_size,
|
|
||||||
symbol_sr[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(sr_icon.data(), static_cast<int>(sr_icon.size()));
|
|
||||||
break;
|
|
||||||
case Symbol::Charging:
|
|
||||||
for (std::size_t point = 0; point < symbol_charging.size() / 2; ++point) {
|
|
||||||
charging_icon[point] = center + QPointF(symbol_charging[point * 2] * icon_size,
|
|
||||||
symbol_charging[point * 2 + 1] * icon_size);
|
|
||||||
}
|
|
||||||
p.drawPolygon(charging_icon.data(), static_cast<int>(charging_icon.size()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::DrawArrow(QPainter& p, const QPointF center, const Direction direction,
|
|
||||||
float size) {
|
|
||||||
|
|
||||||
std::array<QPointF, up_arrow_symbol.size() / 2> arrow_symbol;
|
|
||||||
|
|
||||||
for (std::size_t point = 0; point < up_arrow_symbol.size() / 2; ++point) {
|
|
||||||
const float up_arrow_x = up_arrow_symbol[point * 2 + 0];
|
|
||||||
const float up_arrow_y = up_arrow_symbol[point * 2 + 1];
|
|
||||||
|
|
||||||
switch (direction) {
|
|
||||||
case Direction::Up:
|
|
||||||
arrow_symbol[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
|
|
||||||
break;
|
|
||||||
case Direction::Left:
|
|
||||||
arrow_symbol[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
|
|
||||||
break;
|
|
||||||
case Direction::Right:
|
|
||||||
arrow_symbol[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size);
|
|
||||||
break;
|
|
||||||
case Direction::Down:
|
|
||||||
arrow_symbol[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
|
|
||||||
break;
|
|
||||||
case Direction::None:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawPolygon(p, arrow_symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
void CommonShapes::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) {
|
|
||||||
p.drawPolygon(polygon.data(), static_cast<int>(polygon.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::DrawCircle(QPainter& p, const QPointF center, float size) {
|
|
||||||
p.drawEllipse(center, size, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::DrawRectangle(QPainter& p, const QPointF center, float width, float height) {
|
|
||||||
const QRectF rect = QRectF(center.x() - (width / 2), center.y() - (height / 2), width, height);
|
|
||||||
p.drawRect(rect);
|
|
||||||
}
|
|
||||||
void CommonShapes::DrawRoundRectangle(QPainter& p, const QPointF center, float width, float height,
|
|
||||||
float round) {
|
|
||||||
const QRectF rect = QRectF(center.x() - (width / 2), center.y() - (height / 2), width, height);
|
|
||||||
p.drawRoundedRect(rect, round, round);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::DrawText(QPainter& p, const QPointF center, float text_size,
|
|
||||||
const QString& text) {
|
|
||||||
SetTextFont(p, text_size);
|
|
||||||
const QFontMetrics fm(p.font());
|
|
||||||
const QPointF offset = {fm.horizontalAdvance(text) / 2.0f, -text_size / 2.0f};
|
|
||||||
p.drawText(center - offset, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommonShapes::SetTextFont(QPainter& p, float text_size, const QString& font_family) {
|
|
||||||
QFont font = p.font();
|
|
||||||
font.setPointSizeF(text_size);
|
|
||||||
font.setFamily(font_family);
|
|
||||||
p.setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr std::array<float, 13 * 2> symbol_a = {
|
|
||||||
-1.085f, -5.2f, 1.085f, -5.2f, 5.085f, 5.0f, 2.785f, 5.0f, 1.785f,
|
|
||||||
2.65f, -1.785f, 2.65f, -2.785f, 5.0f, -5.085f, 5.0f, -1.4f, 1.0f,
|
|
||||||
0.0f, -2.8f, 1.4f, 1.0f, -1.4f, 1.0f, -5.085f, 5.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 134 * 2> symbol_b = {
|
|
||||||
-4.0f, 0.0f, -4.0f, 0.0f, -4.0f, -0.1f, -3.8f, -5.1f, 1.8f, -5.0f, 2.3f, -4.9f, 2.6f,
|
|
||||||
-4.8f, 2.8f, -4.7f, 2.9f, -4.6f, 3.1f, -4.5f, 3.2f, -4.4f, 3.4f, -4.3f, 3.4f, -4.2f,
|
|
||||||
3.5f, -4.1f, 3.7f, -4.0f, 3.7f, -3.9f, 3.8f, -3.8f, 3.8f, -3.7f, 3.9f, -3.6f, 3.9f,
|
|
||||||
-3.5f, 4.0f, -3.4f, 4.0f, -3.3f, 4.1f, -3.1f, 4.1f, -3.0f, 4.0f, -2.0f, 4.0f, -1.9f,
|
|
||||||
3.9f, -1.7f, 3.9f, -1.6f, 3.8f, -1.5f, 3.8f, -1.4f, 3.7f, -1.3f, 3.7f, -1.2f, 3.6f,
|
|
||||||
-1.1f, 3.6f, -1.0f, 3.5f, -0.9f, 3.3f, -0.8f, 3.3f, -0.7f, 3.2f, -0.6f, 3.0f, -0.5f,
|
|
||||||
2.9f, -0.4f, 2.7f, -0.3f, 2.9f, -0.2f, 3.2f, -0.1f, 3.3f, 0.0f, 3.5f, 0.1f, 3.6f,
|
|
||||||
0.2f, 3.8f, 0.3f, 3.9f, 0.4f, 4.0f, 0.6f, 4.1f, 0.7f, 4.3f, 0.8f, 4.3f, 0.9f,
|
|
||||||
4.4f, 1.0f, 4.4f, 1.1f, 4.5f, 1.3f, 4.5f, 1.4f, 4.6f, 1.6f, 4.6f, 1.7f, 4.5f,
|
|
||||||
2.8f, 4.5f, 2.9f, 4.4f, 3.1f, 4.4f, 3.2f, 4.3f, 3.4f, 4.3f, 3.5f, 4.2f, 3.6f,
|
|
||||||
4.2f, 3.7f, 4.1f, 3.8f, 4.1f, 3.9f, 4.0f, 4.0f, 3.9f, 4.2f, 3.8f, 4.3f, 3.6f,
|
|
||||||
4.4f, 3.6f, 4.5f, 3.4f, 4.6f, 3.3f, 4.7f, 3.1f, 4.8f, 2.8f, 4.9f, 2.6f, 5.0f,
|
|
||||||
2.1f, 5.1f, -4.0f, 5.0f, -4.0f, 4.9f,
|
|
||||||
|
|
||||||
-4.0f, 0.0f, 1.1f, 3.4f, 1.1f, 3.4f, 1.5f, 3.3f, 1.8f, 3.2f, 2.0f, 3.1f, 2.1f,
|
|
||||||
3.0f, 2.3f, 2.9f, 2.3f, 2.8f, 2.4f, 2.7f, 2.4f, 2.6f, 2.5f, 2.3f, 2.5f, 2.2f,
|
|
||||||
2.4f, 1.7f, 2.4f, 1.6f, 2.3f, 1.4f, 2.3f, 1.3f, 2.2f, 1.2f, 2.2f, 1.1f, 2.1f,
|
|
||||||
1.0f, 1.9f, 0.9f, 1.6f, 0.8f, 1.4f, 0.7f, -1.9f, 0.6f, -1.9f, 0.7f, -1.8f, 3.4f,
|
|
||||||
1.1f, 3.4f, -4.0f, 0.0f,
|
|
||||||
|
|
||||||
0.3f, -1.1f, 0.3f, -1.1f, 1.3f, -1.2f, 1.5f, -1.3f, 1.8f, -1.4f, 1.8f, -1.5f, 1.9f,
|
|
||||||
-1.6f, 2.0f, -1.8f, 2.0f, -1.9f, 2.1f, -2.0f, 2.1f, -2.1f, 2.0f, -2.7f, 2.0f, -2.8f,
|
|
||||||
1.9f, -2.9f, 1.9f, -3.0f, 1.8f, -3.1f, 1.6f, -3.2f, 1.6f, -3.3f, 1.3f, -3.4f, -1.9f,
|
|
||||||
-3.3f, -1.9f, -3.2f, -1.8f, -1.0f, 0.2f, -1.1f, 0.3f, -1.1f, -4.0f, 0.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 9 * 2> symbol_y = {
|
|
||||||
-4.79f, -4.9f, -2.44f, -4.9f, 0.0f, -0.9f, 2.44f, -4.9f, 4.79f,
|
|
||||||
-4.9f, 1.05f, 1.0f, 1.05f, 5.31f, -1.05f, 5.31f, -1.05f, 1.0f,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 12 * 2> symbol_x = {
|
|
||||||
-4.4f, -5.0f, -2.0f, -5.0f, 0.0f, -1.7f, 2.0f, -5.0f, 4.4f, -5.0f, 1.2f, 0.0f,
|
|
||||||
4.4f, 5.0f, 2.0f, 5.0f, 0.0f, 1.7f, -2.0f, 5.0f, -4.4f, 5.0f, -1.2f, 0.0f,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 7 * 2> symbol_l = {
|
|
||||||
2.4f, -3.23f, 2.4f, 2.1f, 5.43f, 2.1f, 5.43f, 3.22f, 0.98f, 3.22f, 0.98f, -3.23f, 2.4f, -3.23f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 98 * 2> symbol_r = {
|
|
||||||
1.0f, 0.0f, 1.0f, -0.1f, 1.1f, -3.3f, 4.3f, -3.2f, 5.1f, -3.1f, 5.4f, -3.0f, 5.6f, -2.9f,
|
|
||||||
5.7f, -2.8f, 5.9f, -2.7f, 5.9f, -2.6f, 6.0f, -2.5f, 6.1f, -2.3f, 6.2f, -2.2f, 6.2f, -2.1f,
|
|
||||||
6.3f, -2.0f, 6.3f, -1.9f, 6.2f, -0.8f, 6.2f, -0.7f, 6.1f, -0.6f, 6.1f, -0.5f, 6.0f, -0.4f,
|
|
||||||
6.0f, -0.3f, 5.9f, -0.2f, 5.7f, -0.1f, 5.7f, 0.0f, 5.6f, 0.1f, 5.4f, 0.2f, 5.1f, 0.3f,
|
|
||||||
4.7f, 0.4f, 4.7f, 0.5f, 4.9f, 0.6f, 5.0f, 0.7f, 5.2f, 0.8f, 5.2f, 0.9f, 5.3f, 1.0f,
|
|
||||||
5.5f, 1.1f, 5.5f, 1.2f, 5.6f, 1.3f, 5.7f, 1.5f, 5.8f, 1.6f, 5.9f, 1.8f, 6.0f, 1.9f,
|
|
||||||
6.1f, 2.1f, 6.2f, 2.2f, 6.2f, 2.3f, 6.3f, 2.4f, 6.4f, 2.6f, 6.5f, 2.7f, 6.6f, 2.9f,
|
|
||||||
6.7f, 3.0f, 6.7f, 3.1f, 6.8f, 3.2f, 6.8f, 3.3f, 5.3f, 3.2f, 5.2f, 3.1f, 5.2f, 3.0f,
|
|
||||||
5.1f, 2.9f, 5.0f, 2.7f, 4.9f, 2.6f, 4.8f, 2.4f, 4.7f, 2.3f, 4.6f, 2.1f, 4.5f, 2.0f,
|
|
||||||
4.4f, 1.8f, 4.3f, 1.7f, 4.1f, 1.4f, 4.0f, 1.3f, 3.9f, 1.1f, 3.8f, 1.0f, 3.6f, 0.9f,
|
|
||||||
3.6f, 0.8f, 3.5f, 0.7f, 3.3f, 0.6f, 2.9f, 0.5f, 2.3f, 0.6f, 2.3f, 0.7f, 2.2f, 3.3f,
|
|
||||||
1.0f, 3.2f, 1.0f, 3.1f, 1.0f, 0.0f,
|
|
||||||
|
|
||||||
4.2f, -0.5f, 4.4f, -0.6f, 4.7f, -0.7f, 4.8f, -0.8f, 4.9f, -1.0f, 5.0f, -1.1f, 5.0f, -1.2f,
|
|
||||||
4.9f, -1.7f, 4.9f, -1.8f, 4.8f, -1.9f, 4.8f, -2.0f, 4.6f, -2.1f, 4.3f, -2.2f, 2.3f, -2.1f,
|
|
||||||
2.3f, -2.0f, 2.4f, -0.5f, 4.2f, -0.5f, 1.0f, 0.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 18 * 2> symbol_zl = {
|
|
||||||
-2.6f, -2.13f, -5.6f, -2.13f, -5.6f, -3.23f, -0.8f, -3.23f, -0.8f, -2.13f, -4.4f, 2.12f,
|
|
||||||
-0.7f, 2.12f, -0.7f, 3.22f, -6.0f, 3.22f, -6.0f, 2.12f, 2.4f, -3.23f, 2.4f, 2.1f,
|
|
||||||
5.43f, 2.1f, 5.43f, 3.22f, 0.98f, 3.22f, 0.98f, -3.23f, 2.4f, -3.23f, -6.0f, 2.12f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 57 * 2> symbol_sl = {
|
|
||||||
-3.0f, -3.65f, -2.76f, -4.26f, -2.33f, -4.76f, -1.76f, -5.09f, -1.13f, -5.26f, -0.94f,
|
|
||||||
-4.77f, -0.87f, -4.11f, -1.46f, -3.88f, -1.91f, -3.41f, -2.05f, -2.78f, -1.98f, -2.13f,
|
|
||||||
-1.59f, -1.61f, -0.96f, -1.53f, -0.56f, -2.04f, -0.38f, -2.67f, -0.22f, -3.31f, 0.0f,
|
|
||||||
-3.93f, 0.34f, -4.49f, 0.86f, -4.89f, 1.49f, -5.05f, 2.14f, -4.95f, 2.69f, -4.6f,
|
|
||||||
3.07f, -4.07f, 3.25f, -3.44f, 3.31f, -2.78f, 3.25f, -2.12f, 3.07f, -1.49f, 2.7f,
|
|
||||||
-0.95f, 2.16f, -0.58f, 1.52f, -0.43f, 1.41f, -0.99f, 1.38f, -1.65f, 1.97f, -1.91f,
|
|
||||||
2.25f, -2.49f, 2.25f, -3.15f, 1.99f, -3.74f, 1.38f, -3.78f, 1.06f, -3.22f, 0.88f,
|
|
||||||
-2.58f, 0.71f, -1.94f, 0.49f, -1.32f, 0.13f, -0.77f, -0.4f, -0.4f, -1.04f, -0.25f,
|
|
||||||
-1.69f, -0.32f, -2.28f, -0.61f, -2.73f, -1.09f, -2.98f, -1.69f, -3.09f, -2.34f,
|
|
||||||
|
|
||||||
3.23f, 2.4f, -2.1f, 2.4f, -2.1f, 5.43f, -3.22f, 5.43f, -3.22f, 0.98f, 3.23f,
|
|
||||||
0.98f, 3.23f, 2.4f, -3.09f, -2.34f,
|
|
||||||
};
|
|
||||||
constexpr std::array<float, 109 * 2> symbol_zr = {
|
|
||||||
-2.6f, -2.13f, -5.6f, -2.13f, -5.6f, -3.23f, -0.8f, -3.23f, -0.8f, -2.13f, -4.4f, 2.12f, -0.7f,
|
|
||||||
2.12f, -0.7f, 3.22f, -6.0f, 3.22f, -6.0f, 2.12f,
|
|
||||||
|
|
||||||
1.0f, 0.0f, 1.0f, -0.1f, 1.1f, -3.3f, 4.3f, -3.2f, 5.1f, -3.1f, 5.4f, -3.0f, 5.6f,
|
|
||||||
-2.9f, 5.7f, -2.8f, 5.9f, -2.7f, 5.9f, -2.6f, 6.0f, -2.5f, 6.1f, -2.3f, 6.2f, -2.2f,
|
|
||||||
6.2f, -2.1f, 6.3f, -2.0f, 6.3f, -1.9f, 6.2f, -0.8f, 6.2f, -0.7f, 6.1f, -0.6f, 6.1f,
|
|
||||||
-0.5f, 6.0f, -0.4f, 6.0f, -0.3f, 5.9f, -0.2f, 5.7f, -0.1f, 5.7f, 0.0f, 5.6f, 0.1f,
|
|
||||||
5.4f, 0.2f, 5.1f, 0.3f, 4.7f, 0.4f, 4.7f, 0.5f, 4.9f, 0.6f, 5.0f, 0.7f, 5.2f,
|
|
||||||
0.8f, 5.2f, 0.9f, 5.3f, 1.0f, 5.5f, 1.1f, 5.5f, 1.2f, 5.6f, 1.3f, 5.7f, 1.5f,
|
|
||||||
5.8f, 1.6f, 5.9f, 1.8f, 6.0f, 1.9f, 6.1f, 2.1f, 6.2f, 2.2f, 6.2f, 2.3f, 6.3f,
|
|
||||||
2.4f, 6.4f, 2.6f, 6.5f, 2.7f, 6.6f, 2.9f, 6.7f, 3.0f, 6.7f, 3.1f, 6.8f, 3.2f,
|
|
||||||
6.8f, 3.3f, 5.3f, 3.2f, 5.2f, 3.1f, 5.2f, 3.0f, 5.1f, 2.9f, 5.0f, 2.7f, 4.9f,
|
|
||||||
2.6f, 4.8f, 2.4f, 4.7f, 2.3f, 4.6f, 2.1f, 4.5f, 2.0f, 4.4f, 1.8f, 4.3f, 1.7f,
|
|
||||||
4.1f, 1.4f, 4.0f, 1.3f, 3.9f, 1.1f, 3.8f, 1.0f, 3.6f, 0.9f, 3.6f, 0.8f, 3.5f,
|
|
||||||
0.7f, 3.3f, 0.6f, 2.9f, 0.5f, 2.3f, 0.6f, 2.3f, 0.7f, 2.2f, 3.3f, 1.0f, 3.2f,
|
|
||||||
1.0f, 3.1f, 1.0f, 0.0f,
|
|
||||||
|
|
||||||
4.2f, -0.5f, 4.4f, -0.6f, 4.7f, -0.7f, 4.8f, -0.8f, 4.9f, -1.0f, 5.0f, -1.1f, 5.0f,
|
|
||||||
-1.2f, 4.9f, -1.7f, 4.9f, -1.8f, 4.8f, -1.9f, 4.8f, -2.0f, 4.6f, -2.1f, 4.3f, -2.2f,
|
|
||||||
2.3f, -2.1f, 2.3f, -2.0f, 2.4f, -0.5f, 4.2f, -0.5f, 1.0f, 0.0f, -6.0f, 2.12f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 148 * 2> symbol_sr = {
|
|
||||||
-3.0f, -3.65f, -2.76f, -4.26f, -2.33f, -4.76f, -1.76f, -5.09f, -1.13f, -5.26f, -0.94f, -4.77f,
|
|
||||||
-0.87f, -4.11f, -1.46f, -3.88f, -1.91f, -3.41f, -2.05f, -2.78f, -1.98f, -2.13f, -1.59f, -1.61f,
|
|
||||||
-0.96f, -1.53f, -0.56f, -2.04f, -0.38f, -2.67f, -0.22f, -3.31f, 0.0f, -3.93f, 0.34f, -4.49f,
|
|
||||||
0.86f, -4.89f, 1.49f, -5.05f, 2.14f, -4.95f, 2.69f, -4.6f, 3.07f, -4.07f, 3.25f, -3.44f,
|
|
||||||
3.31f, -2.78f, 3.25f, -2.12f, 3.07f, -1.49f, 2.7f, -0.95f, 2.16f, -0.58f, 1.52f, -0.43f,
|
|
||||||
1.41f, -0.99f, 1.38f, -1.65f, 1.97f, -1.91f, 2.25f, -2.49f, 2.25f, -3.15f, 1.99f, -3.74f,
|
|
||||||
1.38f, -3.78f, 1.06f, -3.22f, 0.88f, -2.58f, 0.71f, -1.94f, 0.49f, -1.32f, 0.13f, -0.77f,
|
|
||||||
-0.4f, -0.4f, -1.04f, -0.25f, -1.69f, -0.32f, -2.28f, -0.61f, -2.73f, -1.09f, -2.98f, -1.69f,
|
|
||||||
-3.09f, -2.34f,
|
|
||||||
|
|
||||||
-1.0f, 0.0f, 0.1f, 1.0f, 3.3f, 1.1f, 3.2f, 4.3f, 3.1f, 5.1f, 3.0f, 5.4f,
|
|
||||||
2.9f, 5.6f, 2.8f, 5.7f, 2.7f, 5.9f, 2.6f, 5.9f, 2.5f, 6.0f, 2.3f, 6.1f,
|
|
||||||
2.2f, 6.2f, 2.1f, 6.2f, 2.0f, 6.3f, 1.9f, 6.3f, 0.8f, 6.2f, 0.7f, 6.2f,
|
|
||||||
0.6f, 6.1f, 0.5f, 6.1f, 0.4f, 6.0f, 0.3f, 6.0f, 0.2f, 5.9f, 0.1f, 5.7f,
|
|
||||||
0.0f, 5.7f, -0.1f, 5.6f, -0.2f, 5.4f, -0.3f, 5.1f, -0.4f, 4.7f, -0.5f, 4.7f,
|
|
||||||
-0.6f, 4.9f, -0.7f, 5.0f, -0.8f, 5.2f, -0.9f, 5.2f, -1.0f, 5.3f, -1.1f, 5.5f,
|
|
||||||
-1.2f, 5.5f, -1.3f, 5.6f, -1.5f, 5.7f, -1.6f, 5.8f, -1.8f, 5.9f, -1.9f, 6.0f,
|
|
||||||
-2.1f, 6.1f, -2.2f, 6.2f, -2.3f, 6.2f, -2.4f, 6.3f, -2.6f, 6.4f, -2.7f, 6.5f,
|
|
||||||
-2.9f, 6.6f, -3.0f, 6.7f, -3.1f, 6.7f, -3.2f, 6.8f, -3.3f, 6.8f, -3.2f, 5.3f,
|
|
||||||
-3.1f, 5.2f, -3.0f, 5.2f, -2.9f, 5.1f, -2.7f, 5.0f, -2.6f, 4.9f, -2.4f, 4.8f,
|
|
||||||
-2.3f, 4.7f, -2.1f, 4.6f, -2.0f, 4.5f, -1.8f, 4.4f, -1.7f, 4.3f, -1.4f, 4.1f,
|
|
||||||
-1.3f, 4.0f, -1.1f, 3.9f, -1.0f, 3.8f, -0.9f, 3.6f, -0.8f, 3.6f, -0.7f, 3.5f,
|
|
||||||
-0.6f, 3.3f, -0.5f, 2.9f, -0.6f, 2.3f, -0.7f, 2.3f, -3.3f, 2.2f, -3.2f, 1.0f,
|
|
||||||
-3.1f, 1.0f, 0.0f, 1.0f,
|
|
||||||
|
|
||||||
0.5f, 4.2f, 0.6f, 4.4f, 0.7f, 4.7f, 0.8f, 4.8f, 1.0f, 4.9f, 1.1f, 5.0f,
|
|
||||||
1.2f, 5.0f, 1.7f, 4.9f, 1.8f, 4.9f, 1.9f, 4.8f, 2.0f, 4.8f, 2.1f, 4.6f,
|
|
||||||
2.2f, 4.3f, 2.1f, 2.3f, 2.0f, 2.3f, 0.5f, 2.4f, 0.5f, 4.2f, -0.0f, 1.0f,
|
|
||||||
-3.09f, -2.34f,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 30 * 2> symbol_c = {
|
|
||||||
2.86f, 7.57f, 0.99f, 7.94f, -0.91f, 7.87f, -2.73f, 7.31f, -4.23f, 6.14f, -5.2f, 4.51f,
|
|
||||||
-5.65f, 2.66f, -5.68f, 0.75f, -5.31f, -1.12f, -4.43f, -2.81f, -3.01f, -4.08f, -1.24f, -4.78f,
|
|
||||||
0.66f, -4.94f, 2.54f, -4.67f, 4.33f, -4.0f, 4.63f, -2.27f, 3.37f, -2.7f, 1.6f, -3.4f,
|
|
||||||
-0.3f, -3.5f, -2.09f, -2.87f, -3.34f, -1.45f, -3.91f, 0.37f, -3.95f, 2.27f, -3.49f, 4.12f,
|
|
||||||
-2.37f, 5.64f, -0.65f, 6.44f, 1.25f, 6.47f, 3.06f, 5.89f, 4.63f, 4.92f, 4.63f, 6.83f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 6 * 2> symbol_charging = {
|
|
||||||
6.5f, -1.0f, 1.0f, -1.0f, 1.0f, -3.0f, -6.5f, 1.0f, -1.0f, 1.0f, -1.0f, 3.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 12 * 2> house = {
|
|
||||||
-1.3f, 0.0f, -0.93f, 0.0f, -0.93f, 1.15f, 0.93f, 1.15f, 0.93f, 0.0f, 1.3f, 0.0f,
|
|
||||||
0.0f, -1.2f, -1.3f, 0.0f, -0.43f, 0.0f, -0.43f, .73f, 0.43f, .73f, 0.43f, 0.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 11 * 2> up_arrow_button = {
|
|
||||||
9.1f, -9.1f, 9.1f, -30.0f, 8.1f, -30.1f, 7.7f, -30.1f, -8.6f, -30.0f, -9.0f,
|
|
||||||
-29.8f, -9.3f, -29.5f, -9.5f, -29.1f, -9.1f, -28.7f, -9.1f, -9.1f, 0.0f, 0.6f,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr std::array<float, 3 * 2> up_arrow_symbol = {
|
|
||||||
0.0f, -3.0f, -3.0f, 2.0f, 3.0f, 2.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ControllerViewer
|
|
@ -1,65 +0,0 @@
|
|||||||
// Copyright 2020 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "common\common_types.h"
|
|
||||||
|
|
||||||
namespace Common::Input {
|
|
||||||
enum class BatteryLevel : u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ControllerViewer {
|
|
||||||
|
|
||||||
// Widget for representing controller animations
|
|
||||||
class CommonShapes {
|
|
||||||
|
|
||||||
enum class Direction : std::size_t {
|
|
||||||
None,
|
|
||||||
Up,
|
|
||||||
Right,
|
|
||||||
Down,
|
|
||||||
Left,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class Symbol {
|
|
||||||
House,
|
|
||||||
A,
|
|
||||||
B,
|
|
||||||
X,
|
|
||||||
Y,
|
|
||||||
L,
|
|
||||||
R,
|
|
||||||
C,
|
|
||||||
SL,
|
|
||||||
ZL,
|
|
||||||
ZR,
|
|
||||||
SR,
|
|
||||||
Charging,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Draw battery functions
|
|
||||||
void DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery,
|
|
||||||
QColor outline, QColor battery_color, QColor charging_outline,
|
|
||||||
QColor charging_color);
|
|
||||||
|
|
||||||
// Draw icon functions
|
|
||||||
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
|
|
||||||
void DrawArrow(QPainter& p, QPointF center, Direction direction, float size);
|
|
||||||
|
|
||||||
// Draw primitive types
|
|
||||||
template <size_t N>
|
|
||||||
void DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon);
|
|
||||||
void DrawCircle(QPainter& p, QPointF center, float size);
|
|
||||||
void DrawRectangle(QPainter& p, QPointF center, float width, float height);
|
|
||||||
void DrawRoundRectangle(QPainter& p, QPointF center, float width, float height, float round);
|
|
||||||
void DrawText(QPainter& p, QPointF center, float text_size, const QString& text);
|
|
||||||
void SetTextFont(QPainter& p, float text_size,
|
|
||||||
const QString& font_family = QStringLiteral("sans-serif"));
|
|
||||||
};
|
|
||||||
} // namespace ControllerViewer
|
|
@ -1,77 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "common/input.h"
|
|
||||||
#include "common/settings_input.h"
|
|
||||||
#include "core/hid/emulated_controller.h"
|
|
||||||
#include "core/hid/hid_types.h"
|
|
||||||
|
|
||||||
namespace ControllerViewer {
|
|
||||||
|
|
||||||
using AnalogParam = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>;
|
|
||||||
using ButtonParam = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>;
|
|
||||||
|
|
||||||
enum class Theme {
|
|
||||||
White,
|
|
||||||
Dark,
|
|
||||||
Midnight,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Widget for representing controller animations
|
|
||||||
class ControllerBase {
|
|
||||||
struct ColorMapping {
|
|
||||||
QColor outline{};
|
|
||||||
QColor primary{};
|
|
||||||
QColor left{};
|
|
||||||
QColor right{};
|
|
||||||
QColor button{};
|
|
||||||
QColor button2{};
|
|
||||||
QColor font{};
|
|
||||||
QColor font2{};
|
|
||||||
QColor highlight{};
|
|
||||||
QColor highlight2{};
|
|
||||||
QColor transparent{};
|
|
||||||
QColor indicator{};
|
|
||||||
QColor indicator2{};
|
|
||||||
QColor led_on{};
|
|
||||||
QColor led_off{};
|
|
||||||
QColor slider{};
|
|
||||||
QColor slider_button{};
|
|
||||||
QColor slider_arrow{};
|
|
||||||
QColor deadzone{};
|
|
||||||
QColor charging{};
|
|
||||||
};
|
|
||||||
|
|
||||||
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
|
|
||||||
void DrawJoystickProperties(QPainter& p, QPointF center,
|
|
||||||
const Common::Input::AnalogProperties& properties);
|
|
||||||
|
|
||||||
bool is_controller_set{};
|
|
||||||
bool is_connected{};
|
|
||||||
bool needs_redraw{};
|
|
||||||
Core::HID::NpadStyleIndex controller_type;
|
|
||||||
|
|
||||||
bool mapping_active{};
|
|
||||||
int blink_counter{};
|
|
||||||
int callback_key;
|
|
||||||
QColor button_color{};
|
|
||||||
ColorMapping colors{};
|
|
||||||
Core::HID::LedPattern led_pattern{0, 0, 0, 0};
|
|
||||||
std::size_t player_index{};
|
|
||||||
Core::HID::EmulatedController* controller;
|
|
||||||
std::size_t button_mapping_index{Settings::NativeButton::NumButtons};
|
|
||||||
std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs};
|
|
||||||
Core::HID::ButtonValues button_values{};
|
|
||||||
Core::HID::SticksValues stick_values{};
|
|
||||||
Core::HID::TriggerValues trigger_values{};
|
|
||||||
Core::HID::BatteryValues battery_values{};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ControllerViewer
|
|
@ -1,112 +0,0 @@
|
|||||||
// Copyright 2022 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "core/hid/emulated_controller.h"
|
|
||||||
#include "yuzu/util/controller_viewer/controller_viewer.h"
|
|
||||||
|
|
||||||
namespace ControllerViewer {
|
|
||||||
ControllerViewer::ControllerViewer(QWidget* parent) : QFrame(parent) {
|
|
||||||
is_controller_set = false;
|
|
||||||
QTimer* timer = new QTimer(this);
|
|
||||||
connect(timer, &QTimer::timeout, this, QOverload<>::of(&ControllerViewer::UpdateInput));
|
|
||||||
|
|
||||||
// refresh at 60hz
|
|
||||||
timer->start(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
ControllerViewer::~ControllerViewer() {
|
|
||||||
UnloadController();
|
|
||||||
};
|
|
||||||
|
|
||||||
void ControllerViewer::SetController(Core::HID::EmulatedController* controller_) {
|
|
||||||
UnloadController();
|
|
||||||
is_controller_set = true;
|
|
||||||
controller = controller_;
|
|
||||||
Core::HID::ControllerUpdateCallback engine_callback{
|
|
||||||
.on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); },
|
|
||||||
.is_npad_service = false,
|
|
||||||
};
|
|
||||||
callback_key = controller->SetCallback(engine_callback);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::All);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::UnloadController() {
|
|
||||||
if (is_controller_set) {
|
|
||||||
controller->DeleteCallback(callback_key);
|
|
||||||
is_controller_set = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::BeginMappingButton(std::size_t button_id) {
|
|
||||||
controller_view.BeginMappingButton(button_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::BeginMappingAnalog(std::size_t stick_id) {
|
|
||||||
controller_view.BeginMappingAnalog(stick_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::EndMapping() {
|
|
||||||
controller_view.EndMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::UpdateColors() {
|
|
||||||
if (QIcon::themeName().contains(QStringLiteral("dark"))) {
|
|
||||||
controller_view.UpdateColors(Theme::Midnight);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QIcon::themeName().contains(QStringLiteral("midnight"))) {
|
|
||||||
controller_view.UpdateColors(Theme::Midnight);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controller_view.UpdateColors(Theme::White);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::ResetInputs() {
|
|
||||||
controller_view.ResetInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::ControllerUpdate(Core::HID::ControllerTriggerType type) {
|
|
||||||
if (type == Core::HID::ControllerTriggerType::All) {
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Color);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Type);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Connected);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Button);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Stick);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Trigger);
|
|
||||||
ControllerUpdate(Core::HID::ControllerTriggerType::Battery);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case Core::HID::ControllerTriggerType::Type:
|
|
||||||
controller_type = controller->GetNpadStyleIndex(true);
|
|
||||||
needs_redraw = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
controller_view.ControllerUpdate(type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::UpdateInput() {
|
|
||||||
controller_view.UpdateInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerViewer::paintEvent(QPaintEvent* event) {
|
|
||||||
QFrame::paintEvent(event);
|
|
||||||
QPainter p(this);
|
|
||||||
p.setRenderHint(QPainter::Antialiasing);
|
|
||||||
const QPointF center = rect().center();
|
|
||||||
|
|
||||||
controller_view.DrawController(p, center);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ControllerViewer
|
|
@ -1,64 +0,0 @@
|
|||||||
// Copyright 2022 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "common/input.h"
|
|
||||||
#include "common/settings_input.h"
|
|
||||||
#include "core/hid/emulated_controller.h"
|
|
||||||
#include "core/hid/hid_types.h"
|
|
||||||
#include "yuzu/util/controller_viewer/controller_base.h"
|
|
||||||
|
|
||||||
namespace ControllerViewer {
|
|
||||||
|
|
||||||
// Widget for representing controller animations
|
|
||||||
class ControllerViewer : public QFrame {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ControllerViewer(QWidget* parent);
|
|
||||||
~ControllerViewer() override;
|
|
||||||
|
|
||||||
// Sets the emulated controller to be displayed
|
|
||||||
void SetController(Core::HID::EmulatedController* controller);
|
|
||||||
|
|
||||||
// Disables events from the emulated controller
|
|
||||||
void UnloadController();
|
|
||||||
|
|
||||||
// Starts blinking animation at the button specified
|
|
||||||
void BeginMappingButton(std::size_t button_id);
|
|
||||||
|
|
||||||
// Starts moving animation at the stick specified
|
|
||||||
void BeginMappingAnalog(std::size_t stick_id);
|
|
||||||
|
|
||||||
// Stops any ongoing animation
|
|
||||||
void EndMapping();
|
|
||||||
|
|
||||||
// Handles emulated controller events
|
|
||||||
void ControllerUpdate(Core::HID::ControllerTriggerType type);
|
|
||||||
|
|
||||||
// Updates input on sheduled interval
|
|
||||||
void UpdateInput();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent* event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void UpdateColors();
|
|
||||||
void ResetInputs();
|
|
||||||
|
|
||||||
bool is_controller_set{};
|
|
||||||
bool is_connected{};
|
|
||||||
bool needs_redraw{};
|
|
||||||
|
|
||||||
int callback_key;
|
|
||||||
ControllerBase controller_view;
|
|
||||||
Core::HID::EmulatedController* controller;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ControllerViewer
|
|
File diff suppressed because it is too large
Load Diff
@ -1,28 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "util\controller_viewer\controller_base.h"
|
|
||||||
|
|
||||||
// Widget for representing controller animations
|
|
||||||
class ProController : public PlayerControllerBase {
|
|
||||||
void UpdateColors();
|
|
||||||
void ResetInputs();
|
|
||||||
|
|
||||||
void DrawProController(QPainter& p, QPointF center);
|
|
||||||
|
|
||||||
void DrawGCBody(QPainter& p, QPointF center);
|
|
||||||
|
|
||||||
// Draw triggers functions
|
|
||||||
void DrawProTriggers(QPainter& p, QPointF center,
|
|
||||||
const Common::Input::ButtonStatus& left_pressed,
|
|
||||||
const Common::Input::ButtonStatus& right_pressed);
|
|
||||||
|
|
||||||
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar,
|
|
||||||
const Common::Input::ButtonStatus& pressed);
|
|
||||||
};
|
|
Reference in New Issue
Block a user