Compare commits

..

14 Commits

Author SHA1 Message Date
ameerj
03137086db OpenGL: Prefer glClientWaitSync for OGLSync objects
At least on Nvidia, glClientWaitSync with a timeout of 0 (non-blocking) is faster than glGetSynciv of GL_SYNC_STATUS.
2023-03-08 20:29:25 -05:00
liamwhite
6d61430311 Merge pull request #9890 from Kelebek1/reverb_fix
Fix a bug with the Reverb command in reading from the pre delay line
2023-03-06 11:23:34 -05:00
liamwhite
b210174087 Merge pull request #9910 from jbeich/libc++
kernel: add missing header for libc++
2023-03-06 11:21:51 -05:00
liamwhite
e6349fcd3b Merge pull request #9905 from german77/usbssl
Service: USB, SSL, PSC: Update
2023-03-06 11:21:37 -05:00
liamwhite
f7e6bda5cd Merge pull request #9907 from german77/joycon
input_common: joycon: Add stick input from passive reports
2023-03-06 11:21:27 -05:00
liamwhite
31f0fa1065 Merge pull request #9908 from german77/pfp
service: acc: Replace default image with a 32x32 image
2023-03-06 11:21:17 -05:00
liamwhite
3bd29fb66b Merge pull request #9909 from eltociear/patch-1
fix typo in settings.h
2023-03-06 11:21:06 -05:00
Ikko Eltociear Ashimine
c161e3f433 fix typo in settings.h
Intial -> Initial
2023-03-06 20:28:47 +09:00
Narr the Reg
8a501ff30b service: acc: Replace default image with a 32x32 image 2023-03-05 16:36:19 -06:00
german77
97704b8da9 input_common: joycon: Add stick input from passive reports 2023-03-05 12:50:15 -06:00
Narr the Reg
1f57ae6949 service: psc: Update names 2023-03-05 12:02:10 -06:00
Narr the Reg
f01540da6c service: ssl: Add missing properties and update names 2023-03-05 12:02:04 -06:00
Narr the Reg
54711df739 service: usb: Update names 2023-03-05 10:45:24 -06:00
Kelebek1
104cb6aa0a Fix a bug with the Reverb command in reading from the pre_delay line. 2023-03-02 06:00:55 +00:00
17 changed files with 234 additions and 123 deletions

View File

@@ -308,7 +308,8 @@ static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, Rever
}
Common::FixedPoint<50, 14> pre_delay_sample{
state.pre_delay_line.Read() * Common::FixedPoint<50, 14>::from_base(params.late_gain)};
state.pre_delay_line.TapOut(state.pre_delay_time) *
Common::FixedPoint<50, 14>::from_base(params.late_gain)};
std::array<Common::FixedPoint<50, 14>, ReverbInfo::MaxDelayLines> mix_matrix{
state.prev_feedback_output[2] + state.prev_feedback_output[1] + pre_delay_sample,

View File

@@ -104,7 +104,8 @@ public:
}
void Write(const Common::FixedPoint<50, 14> sample) {
*(input++) = sample;
*input = sample;
input++;
if (input >= buffer_end) {
input = buffer.data();
}

View File

@@ -79,12 +79,10 @@ public:
return;
}
sample_count = delay_time;
input = &buffer[(output - buffer.data() + sample_count) % (sample_count_max + 1)];
input = &buffer[0];
}
Common::FixedPoint<50, 14> Tick(const Common::FixedPoint<50, 14> sample) {
Write(sample);
auto out_sample{Read()};
output++;
@@ -92,6 +90,7 @@ public:
output = buffer.data();
}
Write(sample);
return out_sample;
}
@@ -100,7 +99,8 @@ public:
}
void Write(const Common::FixedPoint<50, 14> sample) {
*(input++) = sample;
*input = sample;
input++;
if (input >= buffer_end) {
input = buffer.data();
}

View File

@@ -128,7 +128,7 @@ public:
/**
* Sets a default value, label, and setting value.
*
* @param default_val Intial value of the setting, and default value of the setting
* @param default_val Initial value of the setting, and default value of the setting
* @param name Label for the setting
*/
explicit Setting(const Type& default_val, const std::string& name)
@@ -139,7 +139,7 @@ public:
/**
* Sets a default value, minimum value, maximum value, and label.
*
* @param default_val Intial value of the setting, and default value of the setting
* @param default_val Initial value of the setting, and default value of the setting
* @param min_val Sets the minimum allowed value of the setting
* @param max_val Sets the maximum allowed value of the setting
* @param name Label for the setting
@@ -231,7 +231,7 @@ public:
/**
* Sets a default value, label, and setting value.
*
* @param default_val Intial value of the setting, and default value of the setting
* @param default_val Initial value of the setting, and default value of the setting
* @param name Label for the setting
*/
explicit SwitchableSetting(const Type& default_val, const std::string& name)
@@ -242,7 +242,7 @@ public:
/**
* Sets a default value, minimum value, maximum value, and label.
*
* @param default_val Intial value of the setting, and default value of the setting
* @param default_val Initial value of the setting, and default value of the setting
* @param min_val Sets the minimum allowed value of the setting
* @param max_val Sets the maximum allowed value of the setting
* @param name Label for the setting

View File

@@ -4,13 +4,24 @@
#include "core/constants.h"
namespace Core::Constants {
const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e,
0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13,
0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01,
0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08,
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
const std::array<u8, 287> ACCOUNT_BACKUP_JPEG{{
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x06, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06,
0x05, 0x05, 0x06, 0x09, 0x06, 0x05, 0x06, 0x09, 0x0b, 0x08, 0x06, 0x06, 0x08, 0x0b, 0x0c, 0x0a,
0x0a, 0x0b, 0x0a, 0x0a, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x10, 0x0c, 0x0e, 0x0f,
0x10, 0x0f, 0x0e, 0x0c, 0x13, 0x13, 0x14, 0x14, 0x13, 0x13, 0x1c, 0x1b, 0x1b, 0x1b, 0x1c, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x07, 0x07,
0x07, 0x0d, 0x0c, 0x0d, 0x18, 0x10, 0x10, 0x18, 0x1a, 0x15, 0x11, 0x15, 0x1a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xc0,
0x00, 0x11, 0x08, 0x00, 0x20, 0x00, 0x20, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
0x01, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00,
0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd9,
}};
}

View File

@@ -12,6 +12,6 @@
namespace Core::Constants {
// ACC Service - Blank JPEG used as user icon in absentia of real one.
extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG;
extern const std::array<u8, 287> ACCOUNT_BACKUP_JPEG;
} // namespace Core::Constants

View File

@@ -11,9 +11,9 @@
namespace Service::PSC {
class PSC_C final : public ServiceFramework<PSC_C> {
class IPmControl final : public ServiceFramework<IPmControl> {
public:
explicit PSC_C(Core::System& system_) : ServiceFramework{system_, "psc:c"} {
explicit IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "Initialize"},
@@ -23,8 +23,8 @@ public:
{4, nullptr, "Cancel"},
{5, nullptr, "PrintModuleInformation"},
{6, nullptr, "GetModuleInformation"},
{10, nullptr, "Unknown10"},
{11, nullptr, "Unknown11"},
{10, nullptr, "AcquireStateLock"},
{11, nullptr, "HasStateLock"},
};
// clang-format on
@@ -49,12 +49,12 @@ public:
}
};
class PSC_M final : public ServiceFramework<PSC_M> {
class IPmService final : public ServiceFramework<IPmService> {
public:
explicit PSC_M(Core::System& system_) : ServiceFramework{system_, "psc:m"} {
explicit IPmService(Core::System& system_) : ServiceFramework{system_, "psc:m"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &PSC_M::GetPmModule, "GetPmModule"},
{0, &IPmService::GetPmModule, "GetPmModule"},
};
// clang-format on
@@ -74,8 +74,8 @@ private:
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("psc:c", std::make_shared<PSC_C>(system));
server_manager->RegisterNamedService("psc:m", std::make_shared<PSC_M>(system));
server_manager->RegisterNamedService("psc:c", std::make_shared<IPmControl>(system));
server_manager->RegisterNamedService("psc:m", std::make_shared<IPmService>(system));
ServerManager::RunServer(std::move(server_manager));
}

View File

@@ -8,14 +8,36 @@
namespace Service::SSL {
// This is nn::ssl::sf::CertificateFormat
enum class CertificateFormat : u32 {
Pem = 1,
Der = 2,
};
// This is nn::ssl::sf::ContextOption
enum class ContextOption : u32 {
None = 0,
CrlImportDateCheckEnable = 1,
};
// This is nn::ssl::sf::SslVersion
struct SslVersion {
union {
u32 raw{};
BitField<0, 1, u32> tls_auto;
BitField<3, 1, u32> tls_v10;
BitField<4, 1, u32> tls_v11;
BitField<5, 1, u32> tls_v12;
BitField<6, 1, u32> tls_v13;
BitField<24, 7, u32> api_version;
};
};
class ISslConnection final : public ServiceFramework<ISslConnection> {
public:
explicit ISslConnection(Core::System& system_) : ServiceFramework{system_, "ISslConnection"} {
explicit ISslConnection(Core::System& system_, SslVersion version)
: ServiceFramework{system_, "ISslConnection"}, ssl_version{version} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "SetSocketDescriptor"},
@@ -59,11 +81,15 @@ public:
RegisterHandlers(functions);
}
private:
SslVersion ssl_version;
};
class ISslContext final : public ServiceFramework<ISslContext> {
public:
explicit ISslContext(Core::System& system_) : ServiceFramework{system_, "ISslContext"} {
explicit ISslContext(Core::System& system_, SslVersion version)
: ServiceFramework{system_, "ISslContext"}, ssl_version{version} {
static const FunctionInfo functions[] = {
{0, &ISslContext::SetOption, "SetOption"},
{1, nullptr, "GetOption"},
@@ -84,17 +110,20 @@ public:
}
private:
SslVersion ssl_version;
void SetOption(HLERequestContext& ctx) {
struct Parameters {
u8 enable;
u32 option;
ContextOption option;
s32 value;
};
static_assert(sizeof(Parameters) == 0x8, "Parameters is an invalid size");
IPC::RequestParser rp{ctx};
const auto parameters = rp.PopRaw<Parameters>();
LOG_WARNING(Service_SSL, "(STUBBED) called. enable={}, option={}", parameters.enable,
parameters.option);
LOG_WARNING(Service_SSL, "(STUBBED) called. option={}, value={}", parameters.option,
parameters.value);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@@ -105,7 +134,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ISslConnection>(system);
rb.PushIpcInterface<ISslConnection>(system, ssl_version);
}
void ImportServerPki(HLERequestContext& ctx) {
@@ -142,20 +171,21 @@ private:
}
};
class SSL final : public ServiceFramework<SSL> {
class ISslService final : public ServiceFramework<ISslService> {
public:
explicit SSL(Core::System& system_) : ServiceFramework{system_, "ssl"} {
explicit ISslService(Core::System& system_) : ServiceFramework{system_, "ssl"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &SSL::CreateContext, "CreateContext"},
{0, &ISslService::CreateContext, "CreateContext"},
{1, nullptr, "GetContextCount"},
{2, nullptr, "GetCertificates"},
{3, nullptr, "GetCertificateBufSize"},
{4, nullptr, "DebugIoctl"},
{5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"},
{5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"},
{6, nullptr, "FlushSessionCache"},
{7, nullptr, "SetDebugOption"},
{8, nullptr, "GetDebugOption"},
{8, nullptr, "ClearTls12FallbackFlag"},
};
// clang-format on
@@ -163,20 +193,30 @@ public:
}
private:
u32 ssl_version{};
void CreateContext(HLERequestContext& ctx) {
LOG_WARNING(Service_SSL, "(STUBBED) called");
struct Parameters {
SslVersion ssl_version;
INSERT_PADDING_BYTES(0x4);
u64 pid_placeholder;
};
static_assert(sizeof(Parameters) == 0x10, "Parameters is an invalid size");
IPC::RequestParser rp{ctx};
const auto parameters = rp.PopRaw<Parameters>();
LOG_WARNING(Service_SSL, "(STUBBED) called, api_version={}, pid_placeholder={}",
parameters.ssl_version.api_version, parameters.pid_placeholder);
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ISslContext>(system);
rb.PushIpcInterface<ISslContext>(system, parameters.ssl_version);
}
void SetInterfaceVersion(HLERequestContext& ctx) {
LOG_DEBUG(Service_SSL, "called");
IPC::RequestParser rp{ctx};
ssl_version = rp.Pop<u32>();
u32 ssl_version = rp.Pop<u32>();
LOG_DEBUG(Service_SSL, "called, ssl_version={}", ssl_version);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@@ -186,7 +226,7 @@ private:
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("ssl", std::make_shared<SSL>(system));
server_manager->RegisterNamedService("ssl", std::make_shared<ISslService>(system));
ServerManager::RunServer(std::move(server_manager));
}

View File

@@ -16,19 +16,19 @@ public:
explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "BindDevice"},
{1, nullptr, "BindClientProcess"},
{2, nullptr, "AddInterface"},
{3, nullptr, "GetStateChangeEvent"},
{4, nullptr, "GetState"},
{5, nullptr, "ClearDeviceData"},
{6, nullptr, "AddUsbStringDescriptor"},
{7, nullptr, "DeleteUsbStringDescriptor"},
{8, nullptr, "SetUsbDeviceDescriptor"},
{9, nullptr, "SetBinaryObjectStore"},
{10, nullptr, "Enable"},
{11, nullptr, "Disable"},
{12, nullptr, "Unknown12"},
{0, nullptr, "AddEndpoint"},
{1, nullptr, "GetSetupEvent"},
{2, nullptr, "GetSetupPacket"},
{3, nullptr, "Enable"},
{4, nullptr, "Disable"},
{5, nullptr, "CtrlIn"},
{6, nullptr, "CtrlOut"},
{7, nullptr, "GetCtrlInCompletionEvent"},
{8, nullptr, "GetCtrlInUrbReport"},
{9, nullptr, "GetCtrlOutCompletionEvent"},
{10, nullptr, "GetCtrlOutUrbReport"},
{11, nullptr, "CtrlStall"},
{12, nullptr, "AppendConfigurationData"},
};
// clang-format on
@@ -36,9 +36,9 @@ public:
}
};
class USB_DS final : public ServiceFramework<USB_DS> {
class IDsRootSession final : public ServiceFramework<IDsRootSession> {
public:
explicit USB_DS(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {
explicit IDsRootSession(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "OpenDsService"},
@@ -94,9 +94,9 @@ public:
}
};
class USB_HS final : public ServiceFramework<USB_HS> {
class IClientRootSession final : public ServiceFramework<IClientRootSession> {
public:
explicit USB_HS(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {
explicit IClientRootSession(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "BindClientProcess"},
@@ -107,7 +107,7 @@ public:
{5, nullptr, "DestroyInterfaceAvailableEvent"},
{6, nullptr, "GetInterfaceStateChangeEvent"},
{7, nullptr, "AcquireUsbIf"},
{8, nullptr, "ResetDevice"},
{8, nullptr, "SetTestMode"},
};
// clang-format on
@@ -134,12 +134,12 @@ public:
}
};
class USB_PD final : public ServiceFramework<USB_PD> {
class IPdManager final : public ServiceFramework<IPdManager> {
public:
explicit USB_PD(Core::System& system_) : ServiceFramework{system_, "usb:pd"} {
explicit IPdManager(Core::System& system_) : ServiceFramework{system_, "usb:pd"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &USB_PD::GetPdSession, "GetPdSession"},
{0, &IPdManager::OpenSession, "OpenSession"},
};
// clang-format on
@@ -147,7 +147,7 @@ public:
}
private:
void GetPdSession(HLERequestContext& ctx) {
void OpenSession(HLERequestContext& ctx) {
LOG_DEBUG(Service_USB, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -178,12 +178,12 @@ public:
}
};
class USB_PD_C final : public ServiceFramework<USB_PD_C> {
class IPdCradleManager final : public ServiceFramework<IPdCradleManager> {
public:
explicit USB_PD_C(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} {
explicit IPdCradleManager(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"},
{0, &IPdCradleManager::OpenCradleSession, "OpenCradleSession"},
};
// clang-format on
@@ -191,18 +191,18 @@ public:
}
private:
void GetPdCradleSession(HLERequestContext& ctx) {
void OpenCradleSession(HLERequestContext& ctx) {
LOG_DEBUG(Service_USB, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<IPdCradleSession>(system);
LOG_DEBUG(Service_USB, "called");
}
};
class USB_PM final : public ServiceFramework<USB_PM> {
class IPmMainService final : public ServiceFramework<IPmMainService> {
public:
explicit USB_PM(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {
explicit IPmMainService(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GetPowerEvent"},
@@ -221,11 +221,11 @@ public:
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("usb:ds", std::make_shared<USB_DS>(system));
server_manager->RegisterNamedService("usb:hs", std::make_shared<USB_HS>(system));
server_manager->RegisterNamedService("usb:pd", std::make_shared<USB_PD>(system));
server_manager->RegisterNamedService("usb:pd:c", std::make_shared<USB_PD_C>(system));
server_manager->RegisterNamedService("usb:pm", std::make_shared<USB_PM>(system));
server_manager->RegisterNamedService("usb:ds", std::make_shared<IDsRootSession>(system));
server_manager->RegisterNamedService("usb:hs", std::make_shared<IClientRootSession>(system));
server_manager->RegisterNamedService("usb:pd", std::make_shared<IPdManager>(system));
server_manager->RegisterNamedService("usb:pd:c", std::make_shared<IPdCradleManager>(system));
server_manager->RegisterNamedService("usb:pm", std::make_shared<IPmMainService>(system));
ServerManager::RunServer(std::move(server_manager));
}

View File

@@ -95,6 +95,18 @@ enum class PasivePadButton : u32 {
ZL_ZR = 0x8000,
};
enum class PasivePadStick : u8 {
Right = 0x00,
RightDown = 0x01,
Down = 0x02,
DownLeft = 0x03,
Left = 0x04,
LeftUp = 0x05,
Up = 0x06,
UpRight = 0x07,
Neutral = 0x08,
};
enum class OutputReport : u8 {
RUMBLE_AND_SUBCMD = 0x01,
FW_UPDATE_PKT = 0x03,

View File

@@ -12,7 +12,7 @@ JoyconPoller::JoyconPoller(ControllerType device_type_, JoyStickCalibration left
: device_type{device_type_}, left_stick_calibration{left_stick_calibration_},
right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {}
void JoyconPoller::SetCallbacks(const Joycon::JoyconCallbacks& callbacks_) {
void JoyconPoller::SetCallbacks(const JoyconCallbacks& callbacks_) {
callbacks = std::move(callbacks_);
}
@@ -22,13 +22,13 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
memcpy(&data, buffer.data(), sizeof(InputReportActive));
switch (device_type) {
case Joycon::ControllerType::Left:
case ControllerType::Left:
UpdateActiveLeftPadInput(data, motion_status);
break;
case Joycon::ControllerType::Right:
case ControllerType::Right:
UpdateActiveRightPadInput(data, motion_status);
break;
case Joycon::ControllerType::Pro:
case ControllerType::Pro:
UpdateActiveProPadInput(data, motion_status);
break;
default:
@@ -47,13 +47,13 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) {
memcpy(&data, buffer.data(), sizeof(InputReportPassive));
switch (device_type) {
case Joycon::ControllerType::Left:
case ControllerType::Left:
UpdatePasiveLeftPadInput(data);
break;
case Joycon::ControllerType::Right:
case ControllerType::Right:
UpdatePasiveRightPadInput(data);
break;
case Joycon::ControllerType::Pro:
case ControllerType::Pro:
UpdatePasiveProPadInput(data);
break;
default:
@@ -211,13 +211,11 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input,
}
void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) {
static constexpr std::array<Joycon::PasivePadButton, 11> left_buttons{
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Capture,
Joycon::PasivePadButton::StickL,
static constexpr std::array<PasivePadButton, 11> left_buttons{
PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B,
PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR,
PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus,
PasivePadButton::Capture, PasivePadButton::StickL,
};
for (auto left_button : left_buttons) {
@@ -225,16 +223,19 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) {
const int button = static_cast<int>(left_button);
callbacks.on_button_data(button, button_status);
}
const auto [left_axis_x, left_axis_y] =
GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state));
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x);
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y);
}
void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) {
static constexpr std::array<Joycon::PasivePadButton, 11> right_buttons{
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
Joycon::PasivePadButton::Plus, Joycon::PasivePadButton::Home,
Joycon::PasivePadButton::StickR,
static constexpr std::array<PasivePadButton, 11> right_buttons{
PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B,
PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR,
PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Plus,
PasivePadButton::Home, PasivePadButton::StickR,
};
for (auto right_button : right_buttons) {
@@ -242,17 +243,20 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) {
const int button = static_cast<int>(right_button);
callbacks.on_button_data(button, button_status);
}
const auto [right_axis_x, right_axis_y] =
GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state));
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x);
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y);
}
void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) {
static constexpr std::array<Joycon::PasivePadButton, 14> pro_buttons{
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Plus,
Joycon::PasivePadButton::Capture, Joycon::PasivePadButton::Home,
Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR,
static constexpr std::array<PasivePadButton, 14> pro_buttons{
PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B,
PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR,
PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus,
PasivePadButton::Plus, PasivePadButton::Capture, PasivePadButton::Home,
PasivePadButton::StickL, PasivePadButton::StickR,
};
for (auto pro_button : pro_buttons) {
@@ -260,6 +264,15 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) {
const int button = static_cast<int>(pro_button);
callbacks.on_button_data(button, button_status);
}
const auto [left_axis_x, left_axis_y] =
GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state && 0xf));
const auto [right_axis_x, right_axis_y] =
GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state >> 4));
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x);
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y);
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x);
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y);
}
f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const {
@@ -270,6 +283,30 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca
return value / calibration.min;
}
std::pair<f32, f32> JoyconPoller::GetPassiveAxisValue(PasivePadStick raw_value) const {
switch (raw_value) {
case PasivePadStick::Right:
return {1.0f, 0.0f};
case PasivePadStick::RightDown:
return {1.0f, -1.0f};
case PasivePadStick::Down:
return {0.0f, -1.0f};
case PasivePadStick::DownLeft:
return {-1.0f, -1.0f};
case PasivePadStick::Left:
return {-1.0f, 0.0f};
case PasivePadStick::LeftUp:
return {-1.0f, 1.0f};
case PasivePadStick::Up:
return {0.0f, 1.0f};
case PasivePadStick::UpRight:
return {1.0f, 1.0f};
case PasivePadStick::Neutral:
default:
return {0.0f, 0.0f};
}
}
f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal,
AccelerometerSensitivity sensitivity) const {
const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4;

View File

@@ -22,7 +22,7 @@ public:
JoyStickCalibration right_stick_calibration_,
MotionCalibration motion_calibration_);
void SetCallbacks(const Joycon::JoyconCallbacks& callbacks_);
void SetCallbacks(const JoyconCallbacks& callbacks_);
/// Handles data from passive packages
void ReadPassiveMode(std::span<u8> buffer);
@@ -51,7 +51,10 @@ private:
void UpdatePasiveProPadInput(const InputReportPassive& buffer);
/// Returns a calibrated joystick axis from raw axis data
f32 GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const;
f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const;
/// Returns a digital joystick axis from passive axis data
std::pair<f32, f32> GetPassiveAxisValue(PasivePadStick raw_value) const;
/// Returns a calibrated accelerometer axis from raw motion data
f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal,
@@ -75,7 +78,7 @@ private:
JoyStickCalibration right_stick_calibration{};
MotionCalibration motion_calibration{};
Joycon::JoyconCallbacks callbacks{};
JoyconCallbacks callbacks{};
};
} // namespace InputCommon::Joycon

View File

@@ -27,9 +27,7 @@ bool GLInnerFence::IsSignaled() const {
return true;
}
ASSERT(sync_object.handle != 0);
GLint sync_status;
glGetSynciv(sync_object.handle, GL_SYNC_STATUS, 1, nullptr, &sync_status);
return sync_status == GL_SIGNALED;
return sync_object.IsSignaled();
}
void GLInnerFence::Wait() {

View File

@@ -621,10 +621,7 @@ bool GraphicsPipeline::IsBuilt() noexcept {
if (built_fence.handle == 0) {
return false;
}
// Timeout of zero means this is non-blocking
const auto sync_status = glClientWaitSync(built_fence.handle, 0, 0);
ASSERT(sync_status != GL_WAIT_FAILED);
is_built = sync_status != GL_TIMEOUT_EXPIRED;
is_built = built_fence.IsSignaled();
return is_built;
}

View File

@@ -3,6 +3,7 @@
#include <string_view>
#include <glad/glad.h>
#include "common/assert.h"
#include "common/microprofile.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
#include "video_core/renderer_opengl/gl_shader_util.h"
@@ -158,6 +159,15 @@ void OGLSync::Release() {
handle = 0;
}
bool OGLSync::IsSignaled() const noexcept {
// At least on Nvidia, glClientWaitSync with a timeout of 0
// is faster than glGetSynciv of GL_SYNC_STATUS.
// Timeout of 0 means this check is non-blocking.
const auto sync_status = glClientWaitSync(handle, 0, 0);
ASSERT(sync_status != GL_WAIT_FAILED);
return sync_status != GL_TIMEOUT_EXPIRED;
}
void OGLFramebuffer::Create() {
if (handle != 0)
return;

View File

@@ -263,6 +263,9 @@ public:
/// Deletes the internal OpenGL resource
void Release();
/// Checks if the sync has been signaled
bool IsSignaled() const noexcept;
GLsync handle = 0;
};

View File

@@ -714,9 +714,7 @@ std::optional<size_t> TextureCacheRuntime::StagingBuffers::FindBuffer(size_t req
continue;
}
if (syncs[index].handle != 0) {
GLint status;
glGetSynciv(syncs[index].handle, GL_SYNC_STATUS, 1, nullptr, &status);
if (status != GL_SIGNALED) {
if (!syncs[index].IsSignaled()) {
continue;
}
syncs[index].Release();