Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Narr the Reg | b003224ff0 | |
Narr the Reg | ed536603af | |
Narr the Reg | 9908ae7d45 |
|
@ -203,7 +203,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) {
|
|||
if (ring_connected && report_mode == ReportMode::STANDARD_FULL_60HZ) {
|
||||
InputReportActive data{};
|
||||
memcpy(&data, buffer.data(), sizeof(InputReportActive));
|
||||
calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input);
|
||||
// calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input);
|
||||
}
|
||||
|
||||
const RingStatus ring_status{
|
||||
|
|
|
@ -51,7 +51,7 @@ Common::Input::DriverResult GenericProtocol::GetControllerType(ControllerType& c
|
|||
|
||||
Common::Input::DriverResult GenericProtocol::EnableImu(bool enable) {
|
||||
ScopedSetBlocking sb(this);
|
||||
const std::array<u8, 1> buffer{static_cast<u8>(enable ? 1 : 0)};
|
||||
const std::array<u8, 1> buffer{static_cast<u8>(enable ? 2 : 0)};
|
||||
return SendSubCommand(SubCommand::ENABLE_IMU, buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -528,11 +528,9 @@ struct InputReportActive {
|
|||
std::array<u8, 3> left_stick_state;
|
||||
std::array<u8, 3> right_stick_state;
|
||||
u8 vibration_code;
|
||||
std::array<s16, 6 * 2> motion_input;
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
s16 ring_input;
|
||||
std::array<s16, 6 * 3> motion_input;
|
||||
};
|
||||
static_assert(sizeof(InputReportActive) == 0x29, "InputReportActive is an invalid size");
|
||||
static_assert(sizeof(InputReportActive) > 0x29, "InputReportActive is an invalid size");
|
||||
|
||||
struct InputReportNfcIr {
|
||||
ReportMode report_mode;
|
||||
|
|
|
@ -36,7 +36,7 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
|
|||
}
|
||||
|
||||
if (ring_status.is_enabled) {
|
||||
UpdateRing(data.ring_input, ring_status);
|
||||
// UpdateRing(data.ring_input, ring_status);
|
||||
}
|
||||
|
||||
callbacks.on_battery_data(data.battery_status);
|
||||
|
@ -367,7 +367,72 @@ MotionData JoyconPoller::GetMotionInput(const InputReportActive& input,
|
|||
motion.gyro_y = GetGyroValue(raw_gyro_y, gyro_cal[0], motion_status.gyro_sensitivity);
|
||||
motion.gyro_z = GetGyroValue(raw_gyro_z, gyro_cal[2], motion_status.gyro_sensitivity);
|
||||
|
||||
std::array<u8, 18> gyro_raw{};
|
||||
memcpy(gyro_raw.data(), &input.motion_input[3], 2);
|
||||
memcpy(gyro_raw.data() + 2, &input.motion_input[4], 2);
|
||||
memcpy(gyro_raw.data() + 4, &input.motion_input[5], 2);
|
||||
memcpy(gyro_raw.data() + 6, &input.motion_input[9], 2);
|
||||
memcpy(gyro_raw.data() + 8, &input.motion_input[10], 2);
|
||||
memcpy(gyro_raw.data() + 10, &input.motion_input[11], 2);
|
||||
memcpy(gyro_raw.data() + 12, &input.motion_input[15], 2);
|
||||
memcpy(gyro_raw.data() + 14, &input.motion_input[16], 2);
|
||||
memcpy(gyro_raw.data() + 16, &input.motion_input[17], 2);
|
||||
|
||||
u32 aa = (gyro_raw[4] & 0xe0) << 0xb | (u32)gyro_raw[5] << 0x13 | (u32)gyro_raw[6] << 0x1b;
|
||||
u32 bb =
|
||||
(int)((gyro_raw[0] & 0xe0) << 0xb | (u32)gyro_raw[1] << 0x13 | (u32)gyro_raw[2] << 0x1b) >>
|
||||
0x10;
|
||||
u32 cc =
|
||||
(int)((gyro_raw[2] & 0xe0) << 0xb | (u32)gyro_raw[3] << 0x13 | (u32)gyro_raw[4] << 0x1b) >>
|
||||
0x10;
|
||||
// u32 aa = (gyro_raw[0] & 0xe0) << 0xb | gyro_raw[1] << 0x13 | gyro_raw[2] << 0x1b;
|
||||
// u32 bb = (gyro_raw[2] & 0xe0) << 0xb | gyro_raw[3] << 0x13 | gyro_raw[4] << 0x1b;
|
||||
// u32 cc = (gyro_raw[4] & 0xe0) << 0xb | gyro_raw[5] << 0x13 | gyro_raw[6] << 0x1b;
|
||||
// u32 dd = (gyro_raw[6] & 0xe0) << 0xb | gyro_raw[7] << 0x13 | gyro_raw[8] << 0x1b;
|
||||
// u32 ee = (gyro_raw[8] & 0xe0) << 0xb | gyro_raw[9] << 0x13 | gyro_raw[10] << 0x1b;
|
||||
// u32 ff = (gyro_raw[10] & 0xe0) << 0xb | gyro_raw[11] << 0x13 | gyro_raw[12] << 0x1b;
|
||||
|
||||
// u32 gg = (gyro_raw[0xc] & 0xe0) << 0x13 | gyro_raw[0xd] << 0x1b;
|
||||
// u32 hh = (gyro_raw[0xd] & 0xe0) << 0x13 | gyro_raw[0xe] << 0x1b;
|
||||
// u32 ii = (gyro_raw[0xe] & 0xe0) << 0x13 | gyro_raw[0xf] << 0x1b;
|
||||
|
||||
u32 uVar21 = (gyro_raw[0] & 0xf0) << 7 | (u32)gyro_raw[1] << 0xf | (u32)gyro_raw[2] << 0x17 |
|
||||
(u32)gyro_raw[3] << 0x1f;
|
||||
u32 uVar18 = (gyro_raw[3] & 0xfe) << 10 | (u32)gyro_raw[4] << 0x12 | (u32)gyro_raw[5] << 0x1a;
|
||||
u32 uVar20 = (gyro_raw[5] & 0xc0) << 5 | (u32)gyro_raw[6] << 0xd | (u32)gyro_raw[7] << 0x15 |
|
||||
(u32)gyro_raw[8] << 0x1d;
|
||||
|
||||
u32 iVar13 = (int)uVar21 >> 0xb;
|
||||
s32 iVar9 = iVar13 - ((int)((gyro_raw[8] & 0xf8) << 0x10 | (u32)gyro_raw[9] << 0x18) >> 0x13);
|
||||
u32 iVar26 = (int)uVar18 >> 0xb;
|
||||
s32 iVar10 = iVar26 - ((int)((u32)gyro_raw[10] << 0x13 | (u32)gyro_raw[0xb] << 0x1b) >> 0x13);
|
||||
u32 iVar25 = (int)uVar20 >> 0xb;
|
||||
s32 iVar11 = iVar25 - ((int)((gyro_raw[0xb] & 0xe0) << 0xe | (u32)gyro_raw[0xc] << 0x16 |
|
||||
(u32)gyro_raw[0xd] << 0x1e) >>
|
||||
0x13);
|
||||
|
||||
std::string str = "";
|
||||
for (u8 dddd : gyro_raw) {
|
||||
str += fmt::format("{:02x} ", dddd);
|
||||
}
|
||||
// LOG_ERROR(Input, "{}", str);
|
||||
|
||||
// LOG_ERROR(Input, "{}, {:08x} {:08x} {:08x} {:08x} {:08x} {:08x}, {:08x} {:08x} {:08x}",
|
||||
// gyro_raw[0] & 3, aa, bb, cc, dd, ee, ff, gg, hh, ii);
|
||||
|
||||
// LOG_ERROR(Input, "{}, {} {} {}",
|
||||
// gyro_raw[0] & 3, iVar9, iVar10, iVar11);
|
||||
LOG_ERROR(Input, "{}, {:08x} {:08x} {:08x}", gyro_raw[0] & 3, aa, bb, cc);
|
||||
//
|
||||
// TODO(German77): Return all three samples data
|
||||
|
||||
motion.accel_x = 0;
|
||||
motion.accel_y = 0;
|
||||
motion.accel_z = 0;
|
||||
motion.gyro_x = static_cast<float>(iVar9) / 5000000.0f;
|
||||
motion.gyro_y = static_cast<float>(iVar10) / 5000000.0f;
|
||||
motion.gyro_z = static_cast<float>(iVar11) / 5000000.0f;
|
||||
|
||||
return motion;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <discord_rpc.h>
|
||||
#include <fmt/format.h>
|
||||
#include <httplib.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
|
@ -31,7 +32,7 @@ void DiscordImpl::Pause() {
|
|||
Discord_ClearPresence();
|
||||
}
|
||||
|
||||
static std::string GetGameString(const std::string& title) {
|
||||
std::string DiscordImpl::GetGameString(const std::string& title) {
|
||||
// Convert to lowercase
|
||||
std::string icon_name = Common::ToLower(title);
|
||||
|
||||
|
@ -56,51 +57,60 @@ static std::string GetGameString(const std::string& title) {
|
|||
return icon_name;
|
||||
}
|
||||
|
||||
void DiscordImpl::Update() {
|
||||
void DiscordImpl::UpdateGameStatus(QNetworkReply* reply) {
|
||||
s64 start_time = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
const std::string default_text = "yuzu is an emulator for the Nintendo Switch";
|
||||
const std::string default_image = "yuzu_logo";
|
||||
std::string game_cover_url = "https://yuzu-emu.org";
|
||||
std::string title;
|
||||
|
||||
DiscordRichPresence presence{};
|
||||
std::string url = default_image;
|
||||
|
||||
if (system.IsPoweredOn()) {
|
||||
system.GetAppLoader().ReadTitle(title);
|
||||
|
||||
// Used to format Icon URL for yuzu website game compatibility page
|
||||
std::string icon_name = GetGameString(title);
|
||||
|
||||
// New Check for game cover
|
||||
httplib::Client cli(game_cover_url);
|
||||
cli.set_connection_timeout(std::chrono::seconds(3));
|
||||
cli.set_read_timeout(std::chrono::seconds(3));
|
||||
|
||||
if (auto res = cli.Head(fmt::format("/images/game/boxart/{}.png", icon_name))) {
|
||||
if (res->status == 200) {
|
||||
game_cover_url += fmt::format("/images/game/boxart/{}.png", icon_name);
|
||||
} else {
|
||||
game_cover_url = "yuzu_logo";
|
||||
}
|
||||
} else {
|
||||
game_cover_url = "yuzu_logo";
|
||||
}
|
||||
|
||||
presence.largeImageKey = game_cover_url.c_str();
|
||||
presence.largeImageText = title.c_str();
|
||||
|
||||
presence.smallImageKey = default_image.c_str();
|
||||
presence.smallImageText = default_text.c_str();
|
||||
presence.state = title.c_str();
|
||||
presence.details = "Currently in game";
|
||||
} else {
|
||||
presence.largeImageKey = default_image.c_str();
|
||||
presence.largeImageText = default_text.c_str();
|
||||
presence.details = "Currently not in game";
|
||||
// Set game cover url only if it exist
|
||||
if (!reply->error() &&
|
||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||
url = game_url;
|
||||
}
|
||||
|
||||
presence.largeImageKey = url.c_str();
|
||||
presence.largeImageText = game_title.c_str();
|
||||
presence.smallImageKey = default_image.c_str();
|
||||
presence.smallImageText = default_text.c_str();
|
||||
presence.state = game_title.c_str();
|
||||
presence.details = "Currently in game";
|
||||
presence.startTimestamp = start_time;
|
||||
Discord_UpdatePresence(&presence);
|
||||
}
|
||||
void DiscordImpl::Update() {
|
||||
if (system.IsPoweredOn()) {
|
||||
system.GetAppLoader().ReadTitle(game_title);
|
||||
|
||||
// Used to format Icon URL for yuzu website game compatibility page
|
||||
std::string icon_name = GetGameString(game_title);
|
||||
game_url = fmt::format("https://yuzu-emu.org/images/game/boxart/{}.png", icon_name);
|
||||
|
||||
QNetworkAccessManager* manager = new QNetworkAccessManager();
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(QString::fromStdString(game_url)));
|
||||
request.setTransferTimeout(3000);
|
||||
QNetworkReply* rep = manager->get(request);
|
||||
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished,
|
||||
[this](QNetworkReply* reply) { UpdateGameStatus(reply); });
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished, manager,
|
||||
&QNetworkAccessManager::deleteLater);
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished, rep,
|
||||
&QNetworkReply::deleteLater);
|
||||
return;
|
||||
}
|
||||
|
||||
s64 start_time = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
|
||||
DiscordRichPresence presence{};
|
||||
presence.largeImageKey = default_image.c_str();
|
||||
presence.largeImageText = default_text.c_str();
|
||||
presence.details = "Currently not in game";
|
||||
presence.startTimestamp = start_time;
|
||||
Discord_UpdatePresence(&presence);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "yuzu/discord.h"
|
||||
|
||||
namespace Core {
|
||||
|
@ -19,6 +21,16 @@ public:
|
|||
void Pause() override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
std::string GetGameString(const std::string& title);
|
||||
void UpdateGameStatus(QNetworkReply* reply);
|
||||
|
||||
const std::string default_text = "yuzu is an emulator for the Nintendo Switch";
|
||||
const std::string default_image = "yuzu_logo";
|
||||
|
||||
std::string game_url{};
|
||||
std::string game_title{};
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
|
|
|
@ -1355,6 +1355,7 @@ void GMainWindow::InitializeHotkeys() {
|
|||
if (Settings::values.mouse_panning) {
|
||||
render_window->installEventFilter(render_window);
|
||||
render_window->setAttribute(Qt::WA_Hover, true);
|
||||
SetDiscordEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue