diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.h | 8 | ||||
| -rw-r--r-- | src/core/constants.cpp | 27 | ||||
| -rw-r--r-- | src/core/constants.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/psc/psc.cpp | 18 | ||||
| -rw-r--r-- | src/core/hle/service/ssl/ssl.cpp | 76 | ||||
| -rw-r--r-- | src/core/hle/service/usb/usb.cpp | 70 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/joycon_types.h | 12 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/poller.cpp | 95 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/poller.h | 9 |
9 files changed, 210 insertions, 107 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index 512ecff69..1ae28ce93 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -128,7 +128,7 @@ public: | |||
| 128 | /** | 128 | /** |
| 129 | * Sets a default value, label, and setting value. | 129 | * Sets a default value, label, and setting value. |
| 130 | * | 130 | * |
| 131 | * @param default_val Intial value of the setting, and default value of the setting | 131 | * @param default_val Initial value of the setting, and default value of the setting |
| 132 | * @param name Label for the setting | 132 | * @param name Label for the setting |
| 133 | */ | 133 | */ |
| 134 | explicit Setting(const Type& default_val, const std::string& name) | 134 | explicit Setting(const Type& default_val, const std::string& name) |
| @@ -139,7 +139,7 @@ public: | |||
| 139 | /** | 139 | /** |
| 140 | * Sets a default value, minimum value, maximum value, and label. | 140 | * Sets a default value, minimum value, maximum value, and label. |
| 141 | * | 141 | * |
| 142 | * @param default_val Intial value of the setting, and default value of the setting | 142 | * @param default_val Initial value of the setting, and default value of the setting |
| 143 | * @param min_val Sets the minimum allowed value of the setting | 143 | * @param min_val Sets the minimum allowed value of the setting |
| 144 | * @param max_val Sets the maximum allowed value of the setting | 144 | * @param max_val Sets the maximum allowed value of the setting |
| 145 | * @param name Label for the setting | 145 | * @param name Label for the setting |
| @@ -231,7 +231,7 @@ public: | |||
| 231 | /** | 231 | /** |
| 232 | * Sets a default value, label, and setting value. | 232 | * Sets a default value, label, and setting value. |
| 233 | * | 233 | * |
| 234 | * @param default_val Intial value of the setting, and default value of the setting | 234 | * @param default_val Initial value of the setting, and default value of the setting |
| 235 | * @param name Label for the setting | 235 | * @param name Label for the setting |
| 236 | */ | 236 | */ |
| 237 | explicit SwitchableSetting(const Type& default_val, const std::string& name) | 237 | explicit SwitchableSetting(const Type& default_val, const std::string& name) |
| @@ -242,7 +242,7 @@ public: | |||
| 242 | /** | 242 | /** |
| 243 | * Sets a default value, minimum value, maximum value, and label. | 243 | * Sets a default value, minimum value, maximum value, and label. |
| 244 | * | 244 | * |
| 245 | * @param default_val Intial value of the setting, and default value of the setting | 245 | * @param default_val Initial value of the setting, and default value of the setting |
| 246 | * @param min_val Sets the minimum allowed value of the setting | 246 | * @param min_val Sets the minimum allowed value of the setting |
| 247 | * @param max_val Sets the maximum allowed value of the setting | 247 | * @param max_val Sets the maximum allowed value of the setting |
| 248 | * @param name Label for the setting | 248 | * @param name Label for the setting |
diff --git a/src/core/constants.cpp b/src/core/constants.cpp index 4430173ef..760dc5f23 100644 --- a/src/core/constants.cpp +++ b/src/core/constants.cpp | |||
| @@ -4,13 +4,24 @@ | |||
| 4 | #include "core/constants.h" | 4 | #include "core/constants.h" |
| 5 | 5 | ||
| 6 | namespace Core::Constants { | 6 | namespace Core::Constants { |
| 7 | const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{ | 7 | const std::array<u8, 287> ACCOUNT_BACKUP_JPEG{{ |
| 8 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, | 8 | 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48, |
| 9 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, | 9 | 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x06, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, |
| 10 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, | 10 | 0x05, 0x05, 0x06, 0x09, 0x06, 0x05, 0x06, 0x09, 0x0b, 0x08, 0x06, 0x06, 0x08, 0x0b, 0x0c, 0x0a, |
| 11 | 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, | 11 | 0x0a, 0x0b, 0x0a, 0x0a, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x10, 0x0c, 0x0e, 0x0f, |
| 12 | 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, | 12 | 0x10, 0x0f, 0x0e, 0x0c, 0x13, 0x13, 0x14, 0x14, 0x13, 0x13, 0x1c, 0x1b, 0x1b, 0x1b, 0x1c, 0x20, |
| 13 | 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, | 13 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x07, 0x07, |
| 14 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | 14 | 0x07, 0x0d, 0x0c, 0x0d, 0x18, 0x10, 0x10, 0x18, 0x1a, 0x15, 0x11, 0x15, 0x1a, 0x20, 0x20, 0x20, |
| 15 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 16 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 17 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xc0, | ||
| 18 | 0x00, 0x11, 0x08, 0x00, 0x20, 0x00, 0x20, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, | ||
| 19 | 0x01, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00, | ||
| 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, | ||
| 22 | 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 23 | 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, | ||
| 25 | 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd9, | ||
| 15 | }}; | 26 | }}; |
| 16 | } | 27 | } |
diff --git a/src/core/constants.h b/src/core/constants.h index f916ce0b6..f1f67d3b8 100644 --- a/src/core/constants.h +++ b/src/core/constants.h | |||
| @@ -12,6 +12,6 @@ | |||
| 12 | namespace Core::Constants { | 12 | namespace Core::Constants { |
| 13 | 13 | ||
| 14 | // ACC Service - Blank JPEG used as user icon in absentia of real one. | 14 | // ACC Service - Blank JPEG used as user icon in absentia of real one. |
| 15 | extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG; | 15 | extern const std::array<u8, 287> ACCOUNT_BACKUP_JPEG; |
| 16 | 16 | ||
| 17 | } // namespace Core::Constants | 17 | } // namespace Core::Constants |
diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp index 25702703e..cd0cc9287 100644 --- a/src/core/hle/service/psc/psc.cpp +++ b/src/core/hle/service/psc/psc.cpp | |||
| @@ -11,9 +11,9 @@ | |||
| 11 | 11 | ||
| 12 | namespace Service::PSC { | 12 | namespace Service::PSC { |
| 13 | 13 | ||
| 14 | class PSC_C final : public ServiceFramework<PSC_C> { | 14 | class IPmControl final : public ServiceFramework<IPmControl> { |
| 15 | public: | 15 | public: |
| 16 | explicit PSC_C(Core::System& system_) : ServiceFramework{system_, "psc:c"} { | 16 | explicit IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} { |
| 17 | // clang-format off | 17 | // clang-format off |
| 18 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 19 | {0, nullptr, "Initialize"}, | 19 | {0, nullptr, "Initialize"}, |
| @@ -23,8 +23,8 @@ public: | |||
| 23 | {4, nullptr, "Cancel"}, | 23 | {4, nullptr, "Cancel"}, |
| 24 | {5, nullptr, "PrintModuleInformation"}, | 24 | {5, nullptr, "PrintModuleInformation"}, |
| 25 | {6, nullptr, "GetModuleInformation"}, | 25 | {6, nullptr, "GetModuleInformation"}, |
| 26 | {10, nullptr, "Unknown10"}, | 26 | {10, nullptr, "AcquireStateLock"}, |
| 27 | {11, nullptr, "Unknown11"}, | 27 | {11, nullptr, "HasStateLock"}, |
| 28 | }; | 28 | }; |
| 29 | // clang-format on | 29 | // clang-format on |
| 30 | 30 | ||
| @@ -49,12 +49,12 @@ public: | |||
| 49 | } | 49 | } |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | class PSC_M final : public ServiceFramework<PSC_M> { | 52 | class IPmService final : public ServiceFramework<IPmService> { |
| 53 | public: | 53 | public: |
| 54 | explicit PSC_M(Core::System& system_) : ServiceFramework{system_, "psc:m"} { | 54 | explicit IPmService(Core::System& system_) : ServiceFramework{system_, "psc:m"} { |
| 55 | // clang-format off | 55 | // clang-format off |
| 56 | static const FunctionInfo functions[] = { | 56 | static const FunctionInfo functions[] = { |
| 57 | {0, &PSC_M::GetPmModule, "GetPmModule"}, | 57 | {0, &IPmService::GetPmModule, "GetPmModule"}, |
| 58 | }; | 58 | }; |
| 59 | // clang-format on | 59 | // clang-format on |
| 60 | 60 | ||
| @@ -74,8 +74,8 @@ private: | |||
| 74 | void LoopProcess(Core::System& system) { | 74 | void LoopProcess(Core::System& system) { |
| 75 | auto server_manager = std::make_unique<ServerManager>(system); | 75 | auto server_manager = std::make_unique<ServerManager>(system); |
| 76 | 76 | ||
| 77 | server_manager->RegisterNamedService("psc:c", std::make_shared<PSC_C>(system)); | 77 | server_manager->RegisterNamedService("psc:c", std::make_shared<IPmControl>(system)); |
| 78 | server_manager->RegisterNamedService("psc:m", std::make_shared<PSC_M>(system)); | 78 | server_manager->RegisterNamedService("psc:m", std::make_shared<IPmService>(system)); |
| 79 | ServerManager::RunServer(std::move(server_manager)); | 79 | ServerManager::RunServer(std::move(server_manager)); |
| 80 | } | 80 | } |
| 81 | 81 | ||
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index b19bc1b3e..2b99dd7ac 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp | |||
| @@ -8,14 +8,36 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service::SSL { | 9 | namespace Service::SSL { |
| 10 | 10 | ||
| 11 | // This is nn::ssl::sf::CertificateFormat | ||
| 11 | enum class CertificateFormat : u32 { | 12 | enum class CertificateFormat : u32 { |
| 12 | Pem = 1, | 13 | Pem = 1, |
| 13 | Der = 2, | 14 | Der = 2, |
| 14 | }; | 15 | }; |
| 15 | 16 | ||
| 17 | // This is nn::ssl::sf::ContextOption | ||
| 18 | enum class ContextOption : u32 { | ||
| 19 | None = 0, | ||
| 20 | CrlImportDateCheckEnable = 1, | ||
| 21 | }; | ||
| 22 | |||
| 23 | // This is nn::ssl::sf::SslVersion | ||
| 24 | struct SslVersion { | ||
| 25 | union { | ||
| 26 | u32 raw{}; | ||
| 27 | |||
| 28 | BitField<0, 1, u32> tls_auto; | ||
| 29 | BitField<3, 1, u32> tls_v10; | ||
| 30 | BitField<4, 1, u32> tls_v11; | ||
| 31 | BitField<5, 1, u32> tls_v12; | ||
| 32 | BitField<6, 1, u32> tls_v13; | ||
| 33 | BitField<24, 7, u32> api_version; | ||
| 34 | }; | ||
| 35 | }; | ||
| 36 | |||
| 16 | class ISslConnection final : public ServiceFramework<ISslConnection> { | 37 | class ISslConnection final : public ServiceFramework<ISslConnection> { |
| 17 | public: | 38 | public: |
| 18 | explicit ISslConnection(Core::System& system_) : ServiceFramework{system_, "ISslConnection"} { | 39 | explicit ISslConnection(Core::System& system_, SslVersion version) |
| 40 | : ServiceFramework{system_, "ISslConnection"}, ssl_version{version} { | ||
| 19 | // clang-format off | 41 | // clang-format off |
| 20 | static const FunctionInfo functions[] = { | 42 | static const FunctionInfo functions[] = { |
| 21 | {0, nullptr, "SetSocketDescriptor"}, | 43 | {0, nullptr, "SetSocketDescriptor"}, |
| @@ -59,11 +81,15 @@ public: | |||
| 59 | 81 | ||
| 60 | RegisterHandlers(functions); | 82 | RegisterHandlers(functions); |
| 61 | } | 83 | } |
| 84 | |||
| 85 | private: | ||
| 86 | SslVersion ssl_version; | ||
| 62 | }; | 87 | }; |
| 63 | 88 | ||
| 64 | class ISslContext final : public ServiceFramework<ISslContext> { | 89 | class ISslContext final : public ServiceFramework<ISslContext> { |
| 65 | public: | 90 | public: |
| 66 | explicit ISslContext(Core::System& system_) : ServiceFramework{system_, "ISslContext"} { | 91 | explicit ISslContext(Core::System& system_, SslVersion version) |
| 92 | : ServiceFramework{system_, "ISslContext"}, ssl_version{version} { | ||
| 67 | static const FunctionInfo functions[] = { | 93 | static const FunctionInfo functions[] = { |
| 68 | {0, &ISslContext::SetOption, "SetOption"}, | 94 | {0, &ISslContext::SetOption, "SetOption"}, |
| 69 | {1, nullptr, "GetOption"}, | 95 | {1, nullptr, "GetOption"}, |
| @@ -84,17 +110,20 @@ public: | |||
| 84 | } | 110 | } |
| 85 | 111 | ||
| 86 | private: | 112 | private: |
| 113 | SslVersion ssl_version; | ||
| 114 | |||
| 87 | void SetOption(HLERequestContext& ctx) { | 115 | void SetOption(HLERequestContext& ctx) { |
| 88 | struct Parameters { | 116 | struct Parameters { |
| 89 | u8 enable; | 117 | ContextOption option; |
| 90 | u32 option; | 118 | s32 value; |
| 91 | }; | 119 | }; |
| 120 | static_assert(sizeof(Parameters) == 0x8, "Parameters is an invalid size"); | ||
| 92 | 121 | ||
| 93 | IPC::RequestParser rp{ctx}; | 122 | IPC::RequestParser rp{ctx}; |
| 94 | const auto parameters = rp.PopRaw<Parameters>(); | 123 | const auto parameters = rp.PopRaw<Parameters>(); |
| 95 | 124 | ||
| 96 | LOG_WARNING(Service_SSL, "(STUBBED) called. enable={}, option={}", parameters.enable, | 125 | LOG_WARNING(Service_SSL, "(STUBBED) called. option={}, value={}", parameters.option, |
| 97 | parameters.option); | 126 | parameters.value); |
| 98 | 127 | ||
| 99 | IPC::ResponseBuilder rb{ctx, 2}; | 128 | IPC::ResponseBuilder rb{ctx, 2}; |
| 100 | rb.Push(ResultSuccess); | 129 | rb.Push(ResultSuccess); |
| @@ -105,7 +134,7 @@ private: | |||
| 105 | 134 | ||
| 106 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 135 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 107 | rb.Push(ResultSuccess); | 136 | rb.Push(ResultSuccess); |
| 108 | rb.PushIpcInterface<ISslConnection>(system); | 137 | rb.PushIpcInterface<ISslConnection>(system, ssl_version); |
| 109 | } | 138 | } |
| 110 | 139 | ||
| 111 | void ImportServerPki(HLERequestContext& ctx) { | 140 | void ImportServerPki(HLERequestContext& ctx) { |
| @@ -142,20 +171,21 @@ private: | |||
| 142 | } | 171 | } |
| 143 | }; | 172 | }; |
| 144 | 173 | ||
| 145 | class SSL final : public ServiceFramework<SSL> { | 174 | class ISslService final : public ServiceFramework<ISslService> { |
| 146 | public: | 175 | public: |
| 147 | explicit SSL(Core::System& system_) : ServiceFramework{system_, "ssl"} { | 176 | explicit ISslService(Core::System& system_) : ServiceFramework{system_, "ssl"} { |
| 148 | // clang-format off | 177 | // clang-format off |
| 149 | static const FunctionInfo functions[] = { | 178 | static const FunctionInfo functions[] = { |
| 150 | {0, &SSL::CreateContext, "CreateContext"}, | 179 | {0, &ISslService::CreateContext, "CreateContext"}, |
| 151 | {1, nullptr, "GetContextCount"}, | 180 | {1, nullptr, "GetContextCount"}, |
| 152 | {2, nullptr, "GetCertificates"}, | 181 | {2, nullptr, "GetCertificates"}, |
| 153 | {3, nullptr, "GetCertificateBufSize"}, | 182 | {3, nullptr, "GetCertificateBufSize"}, |
| 154 | {4, nullptr, "DebugIoctl"}, | 183 | {4, nullptr, "DebugIoctl"}, |
| 155 | {5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"}, | 184 | {5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"}, |
| 156 | {6, nullptr, "FlushSessionCache"}, | 185 | {6, nullptr, "FlushSessionCache"}, |
| 157 | {7, nullptr, "SetDebugOption"}, | 186 | {7, nullptr, "SetDebugOption"}, |
| 158 | {8, nullptr, "GetDebugOption"}, | 187 | {8, nullptr, "GetDebugOption"}, |
| 188 | {8, nullptr, "ClearTls12FallbackFlag"}, | ||
| 159 | }; | 189 | }; |
| 160 | // clang-format on | 190 | // clang-format on |
| 161 | 191 | ||
| @@ -163,20 +193,30 @@ public: | |||
| 163 | } | 193 | } |
| 164 | 194 | ||
| 165 | private: | 195 | private: |
| 166 | u32 ssl_version{}; | ||
| 167 | void CreateContext(HLERequestContext& ctx) { | 196 | void CreateContext(HLERequestContext& ctx) { |
| 168 | LOG_WARNING(Service_SSL, "(STUBBED) called"); | 197 | struct Parameters { |
| 198 | SslVersion ssl_version; | ||
| 199 | INSERT_PADDING_BYTES(0x4); | ||
| 200 | u64 pid_placeholder; | ||
| 201 | }; | ||
| 202 | static_assert(sizeof(Parameters) == 0x10, "Parameters is an invalid size"); | ||
| 203 | |||
| 204 | IPC::RequestParser rp{ctx}; | ||
| 205 | const auto parameters = rp.PopRaw<Parameters>(); | ||
| 206 | |||
| 207 | LOG_WARNING(Service_SSL, "(STUBBED) called, api_version={}, pid_placeholder={}", | ||
| 208 | parameters.ssl_version.api_version, parameters.pid_placeholder); | ||
| 169 | 209 | ||
| 170 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 210 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 171 | rb.Push(ResultSuccess); | 211 | rb.Push(ResultSuccess); |
| 172 | rb.PushIpcInterface<ISslContext>(system); | 212 | rb.PushIpcInterface<ISslContext>(system, parameters.ssl_version); |
| 173 | } | 213 | } |
| 174 | 214 | ||
| 175 | void SetInterfaceVersion(HLERequestContext& ctx) { | 215 | void SetInterfaceVersion(HLERequestContext& ctx) { |
| 176 | LOG_DEBUG(Service_SSL, "called"); | ||
| 177 | |||
| 178 | IPC::RequestParser rp{ctx}; | 216 | IPC::RequestParser rp{ctx}; |
| 179 | ssl_version = rp.Pop<u32>(); | 217 | u32 ssl_version = rp.Pop<u32>(); |
| 218 | |||
| 219 | LOG_DEBUG(Service_SSL, "called, ssl_version={}", ssl_version); | ||
| 180 | 220 | ||
| 181 | IPC::ResponseBuilder rb{ctx, 2}; | 221 | IPC::ResponseBuilder rb{ctx, 2}; |
| 182 | rb.Push(ResultSuccess); | 222 | rb.Push(ResultSuccess); |
| @@ -186,7 +226,7 @@ private: | |||
| 186 | void LoopProcess(Core::System& system) { | 226 | void LoopProcess(Core::System& system) { |
| 187 | auto server_manager = std::make_unique<ServerManager>(system); | 227 | auto server_manager = std::make_unique<ServerManager>(system); |
| 188 | 228 | ||
| 189 | server_manager->RegisterNamedService("ssl", std::make_shared<SSL>(system)); | 229 | server_manager->RegisterNamedService("ssl", std::make_shared<ISslService>(system)); |
| 190 | ServerManager::RunServer(std::move(server_manager)); | 230 | ServerManager::RunServer(std::move(server_manager)); |
| 191 | } | 231 | } |
| 192 | 232 | ||
diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp index a2855e783..f29fff1dd 100644 --- a/src/core/hle/service/usb/usb.cpp +++ b/src/core/hle/service/usb/usb.cpp | |||
| @@ -16,19 +16,19 @@ public: | |||
| 16 | explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} { | 16 | explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} { |
| 17 | // clang-format off | 17 | // clang-format off |
| 18 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 19 | {0, nullptr, "BindDevice"}, | 19 | {0, nullptr, "AddEndpoint"}, |
| 20 | {1, nullptr, "BindClientProcess"}, | 20 | {1, nullptr, "GetSetupEvent"}, |
| 21 | {2, nullptr, "AddInterface"}, | 21 | {2, nullptr, "GetSetupPacket"}, |
| 22 | {3, nullptr, "GetStateChangeEvent"}, | 22 | {3, nullptr, "Enable"}, |
| 23 | {4, nullptr, "GetState"}, | 23 | {4, nullptr, "Disable"}, |
| 24 | {5, nullptr, "ClearDeviceData"}, | 24 | {5, nullptr, "CtrlIn"}, |
| 25 | {6, nullptr, "AddUsbStringDescriptor"}, | 25 | {6, nullptr, "CtrlOut"}, |
| 26 | {7, nullptr, "DeleteUsbStringDescriptor"}, | 26 | {7, nullptr, "GetCtrlInCompletionEvent"}, |
| 27 | {8, nullptr, "SetUsbDeviceDescriptor"}, | 27 | {8, nullptr, "GetCtrlInUrbReport"}, |
| 28 | {9, nullptr, "SetBinaryObjectStore"}, | 28 | {9, nullptr, "GetCtrlOutCompletionEvent"}, |
| 29 | {10, nullptr, "Enable"}, | 29 | {10, nullptr, "GetCtrlOutUrbReport"}, |
| 30 | {11, nullptr, "Disable"}, | 30 | {11, nullptr, "CtrlStall"}, |
| 31 | {12, nullptr, "Unknown12"}, | 31 | {12, nullptr, "AppendConfigurationData"}, |
| 32 | }; | 32 | }; |
| 33 | // clang-format on | 33 | // clang-format on |
| 34 | 34 | ||
| @@ -36,9 +36,9 @@ public: | |||
| 36 | } | 36 | } |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | class USB_DS final : public ServiceFramework<USB_DS> { | 39 | class IDsRootSession final : public ServiceFramework<IDsRootSession> { |
| 40 | public: | 40 | public: |
| 41 | explicit USB_DS(Core::System& system_) : ServiceFramework{system_, "usb:ds"} { | 41 | explicit IDsRootSession(Core::System& system_) : ServiceFramework{system_, "usb:ds"} { |
| 42 | // clang-format off | 42 | // clang-format off |
| 43 | static const FunctionInfo functions[] = { | 43 | static const FunctionInfo functions[] = { |
| 44 | {0, nullptr, "OpenDsService"}, | 44 | {0, nullptr, "OpenDsService"}, |
| @@ -94,9 +94,9 @@ public: | |||
| 94 | } | 94 | } |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | class USB_HS final : public ServiceFramework<USB_HS> { | 97 | class IClientRootSession final : public ServiceFramework<IClientRootSession> { |
| 98 | public: | 98 | public: |
| 99 | explicit USB_HS(Core::System& system_) : ServiceFramework{system_, "usb:hs"} { | 99 | explicit IClientRootSession(Core::System& system_) : ServiceFramework{system_, "usb:hs"} { |
| 100 | // clang-format off | 100 | // clang-format off |
| 101 | static const FunctionInfo functions[] = { | 101 | static const FunctionInfo functions[] = { |
| 102 | {0, nullptr, "BindClientProcess"}, | 102 | {0, nullptr, "BindClientProcess"}, |
| @@ -107,7 +107,7 @@ public: | |||
| 107 | {5, nullptr, "DestroyInterfaceAvailableEvent"}, | 107 | {5, nullptr, "DestroyInterfaceAvailableEvent"}, |
| 108 | {6, nullptr, "GetInterfaceStateChangeEvent"}, | 108 | {6, nullptr, "GetInterfaceStateChangeEvent"}, |
| 109 | {7, nullptr, "AcquireUsbIf"}, | 109 | {7, nullptr, "AcquireUsbIf"}, |
| 110 | {8, nullptr, "ResetDevice"}, | 110 | {8, nullptr, "SetTestMode"}, |
| 111 | }; | 111 | }; |
| 112 | // clang-format on | 112 | // clang-format on |
| 113 | 113 | ||
| @@ -134,12 +134,12 @@ public: | |||
| 134 | } | 134 | } |
| 135 | }; | 135 | }; |
| 136 | 136 | ||
| 137 | class USB_PD final : public ServiceFramework<USB_PD> { | 137 | class IPdManager final : public ServiceFramework<IPdManager> { |
| 138 | public: | 138 | public: |
| 139 | explicit USB_PD(Core::System& system_) : ServiceFramework{system_, "usb:pd"} { | 139 | explicit IPdManager(Core::System& system_) : ServiceFramework{system_, "usb:pd"} { |
| 140 | // clang-format off | 140 | // clang-format off |
| 141 | static const FunctionInfo functions[] = { | 141 | static const FunctionInfo functions[] = { |
| 142 | {0, &USB_PD::GetPdSession, "GetPdSession"}, | 142 | {0, &IPdManager::OpenSession, "OpenSession"}, |
| 143 | }; | 143 | }; |
| 144 | // clang-format on | 144 | // clang-format on |
| 145 | 145 | ||
| @@ -147,7 +147,7 @@ public: | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | private: | 149 | private: |
| 150 | void GetPdSession(HLERequestContext& ctx) { | 150 | void OpenSession(HLERequestContext& ctx) { |
| 151 | LOG_DEBUG(Service_USB, "called"); | 151 | LOG_DEBUG(Service_USB, "called"); |
| 152 | 152 | ||
| 153 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 153 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| @@ -178,12 +178,12 @@ public: | |||
| 178 | } | 178 | } |
| 179 | }; | 179 | }; |
| 180 | 180 | ||
| 181 | class USB_PD_C final : public ServiceFramework<USB_PD_C> { | 181 | class IPdCradleManager final : public ServiceFramework<IPdCradleManager> { |
| 182 | public: | 182 | public: |
| 183 | explicit USB_PD_C(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} { | 183 | explicit IPdCradleManager(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} { |
| 184 | // clang-format off | 184 | // clang-format off |
| 185 | static const FunctionInfo functions[] = { | 185 | static const FunctionInfo functions[] = { |
| 186 | {0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"}, | 186 | {0, &IPdCradleManager::OpenCradleSession, "OpenCradleSession"}, |
| 187 | }; | 187 | }; |
| 188 | // clang-format on | 188 | // clang-format on |
| 189 | 189 | ||
| @@ -191,18 +191,18 @@ public: | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | private: | 193 | private: |
| 194 | void GetPdCradleSession(HLERequestContext& ctx) { | 194 | void OpenCradleSession(HLERequestContext& ctx) { |
| 195 | LOG_DEBUG(Service_USB, "called"); | ||
| 196 | |||
| 195 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 197 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 196 | rb.Push(ResultSuccess); | 198 | rb.Push(ResultSuccess); |
| 197 | rb.PushIpcInterface<IPdCradleSession>(system); | 199 | rb.PushIpcInterface<IPdCradleSession>(system); |
| 198 | |||
| 199 | LOG_DEBUG(Service_USB, "called"); | ||
| 200 | } | 200 | } |
| 201 | }; | 201 | }; |
| 202 | 202 | ||
| 203 | class USB_PM final : public ServiceFramework<USB_PM> { | 203 | class IPmMainService final : public ServiceFramework<IPmMainService> { |
| 204 | public: | 204 | public: |
| 205 | explicit USB_PM(Core::System& system_) : ServiceFramework{system_, "usb:pm"} { | 205 | explicit IPmMainService(Core::System& system_) : ServiceFramework{system_, "usb:pm"} { |
| 206 | // clang-format off | 206 | // clang-format off |
| 207 | static const FunctionInfo functions[] = { | 207 | static const FunctionInfo functions[] = { |
| 208 | {0, nullptr, "GetPowerEvent"}, | 208 | {0, nullptr, "GetPowerEvent"}, |
| @@ -221,11 +221,11 @@ public: | |||
| 221 | void LoopProcess(Core::System& system) { | 221 | void LoopProcess(Core::System& system) { |
| 222 | auto server_manager = std::make_unique<ServerManager>(system); | 222 | auto server_manager = std::make_unique<ServerManager>(system); |
| 223 | 223 | ||
| 224 | server_manager->RegisterNamedService("usb:ds", std::make_shared<USB_DS>(system)); | 224 | server_manager->RegisterNamedService("usb:ds", std::make_shared<IDsRootSession>(system)); |
| 225 | server_manager->RegisterNamedService("usb:hs", std::make_shared<USB_HS>(system)); | 225 | server_manager->RegisterNamedService("usb:hs", std::make_shared<IClientRootSession>(system)); |
| 226 | server_manager->RegisterNamedService("usb:pd", std::make_shared<USB_PD>(system)); | 226 | server_manager->RegisterNamedService("usb:pd", std::make_shared<IPdManager>(system)); |
| 227 | server_manager->RegisterNamedService("usb:pd:c", std::make_shared<USB_PD_C>(system)); | 227 | server_manager->RegisterNamedService("usb:pd:c", std::make_shared<IPdCradleManager>(system)); |
| 228 | server_manager->RegisterNamedService("usb:pm", std::make_shared<USB_PM>(system)); | 228 | server_manager->RegisterNamedService("usb:pm", std::make_shared<IPmMainService>(system)); |
| 229 | ServerManager::RunServer(std::move(server_manager)); | 229 | ServerManager::RunServer(std::move(server_manager)); |
| 230 | } | 230 | } |
| 231 | 231 | ||
diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index b91934990..2e50a99a8 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h | |||
| @@ -95,6 +95,18 @@ enum class PasivePadButton : u32 { | |||
| 95 | ZL_ZR = 0x8000, | 95 | ZL_ZR = 0x8000, |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | enum class PasivePadStick : u8 { | ||
| 99 | Right = 0x00, | ||
| 100 | RightDown = 0x01, | ||
| 101 | Down = 0x02, | ||
| 102 | DownLeft = 0x03, | ||
| 103 | Left = 0x04, | ||
| 104 | LeftUp = 0x05, | ||
| 105 | Up = 0x06, | ||
| 106 | UpRight = 0x07, | ||
| 107 | Neutral = 0x08, | ||
| 108 | }; | ||
| 109 | |||
| 98 | enum class OutputReport : u8 { | 110 | enum class OutputReport : u8 { |
| 99 | RUMBLE_AND_SUBCMD = 0x01, | 111 | RUMBLE_AND_SUBCMD = 0x01, |
| 100 | FW_UPDATE_PKT = 0x03, | 112 | FW_UPDATE_PKT = 0x03, |
diff --git a/src/input_common/helpers/joycon_protocol/poller.cpp b/src/input_common/helpers/joycon_protocol/poller.cpp index 9bb15e935..ab48352b8 100644 --- a/src/input_common/helpers/joycon_protocol/poller.cpp +++ b/src/input_common/helpers/joycon_protocol/poller.cpp | |||
| @@ -12,7 +12,7 @@ JoyconPoller::JoyconPoller(ControllerType device_type_, JoyStickCalibration left | |||
| 12 | : device_type{device_type_}, left_stick_calibration{left_stick_calibration_}, | 12 | : device_type{device_type_}, left_stick_calibration{left_stick_calibration_}, |
| 13 | right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {} | 13 | right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {} |
| 14 | 14 | ||
| 15 | void JoyconPoller::SetCallbacks(const Joycon::JoyconCallbacks& callbacks_) { | 15 | void JoyconPoller::SetCallbacks(const JoyconCallbacks& callbacks_) { |
| 16 | callbacks = std::move(callbacks_); | 16 | callbacks = std::move(callbacks_); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -22,13 +22,13 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti | |||
| 22 | memcpy(&data, buffer.data(), sizeof(InputReportActive)); | 22 | memcpy(&data, buffer.data(), sizeof(InputReportActive)); |
| 23 | 23 | ||
| 24 | switch (device_type) { | 24 | switch (device_type) { |
| 25 | case Joycon::ControllerType::Left: | 25 | case ControllerType::Left: |
| 26 | UpdateActiveLeftPadInput(data, motion_status); | 26 | UpdateActiveLeftPadInput(data, motion_status); |
| 27 | break; | 27 | break; |
| 28 | case Joycon::ControllerType::Right: | 28 | case ControllerType::Right: |
| 29 | UpdateActiveRightPadInput(data, motion_status); | 29 | UpdateActiveRightPadInput(data, motion_status); |
| 30 | break; | 30 | break; |
| 31 | case Joycon::ControllerType::Pro: | 31 | case ControllerType::Pro: |
| 32 | UpdateActiveProPadInput(data, motion_status); | 32 | UpdateActiveProPadInput(data, motion_status); |
| 33 | break; | 33 | break; |
| 34 | default: | 34 | default: |
| @@ -47,13 +47,13 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) { | |||
| 47 | memcpy(&data, buffer.data(), sizeof(InputReportPassive)); | 47 | memcpy(&data, buffer.data(), sizeof(InputReportPassive)); |
| 48 | 48 | ||
| 49 | switch (device_type) { | 49 | switch (device_type) { |
| 50 | case Joycon::ControllerType::Left: | 50 | case ControllerType::Left: |
| 51 | UpdatePasiveLeftPadInput(data); | 51 | UpdatePasiveLeftPadInput(data); |
| 52 | break; | 52 | break; |
| 53 | case Joycon::ControllerType::Right: | 53 | case ControllerType::Right: |
| 54 | UpdatePasiveRightPadInput(data); | 54 | UpdatePasiveRightPadInput(data); |
| 55 | break; | 55 | break; |
| 56 | case Joycon::ControllerType::Pro: | 56 | case ControllerType::Pro: |
| 57 | UpdatePasiveProPadInput(data); | 57 | UpdatePasiveProPadInput(data); |
| 58 | break; | 58 | break; |
| 59 | default: | 59 | default: |
| @@ -211,13 +211,11 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input, | |||
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { | 213 | void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { |
| 214 | static constexpr std::array<Joycon::PasivePadButton, 11> left_buttons{ | 214 | static constexpr std::array<PasivePadButton, 11> left_buttons{ |
| 215 | Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, | 215 | PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, |
| 216 | Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, | 216 | PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, |
| 217 | Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, | 217 | PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus, |
| 218 | Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, | 218 | PasivePadButton::Capture, PasivePadButton::StickL, |
| 219 | Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Capture, | ||
| 220 | Joycon::PasivePadButton::StickL, | ||
| 221 | }; | 219 | }; |
| 222 | 220 | ||
| 223 | for (auto left_button : left_buttons) { | 221 | for (auto left_button : left_buttons) { |
| @@ -225,16 +223,19 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { | |||
| 225 | const int button = static_cast<int>(left_button); | 223 | const int button = static_cast<int>(left_button); |
| 226 | callbacks.on_button_data(button, button_status); | 224 | callbacks.on_button_data(button, button_status); |
| 227 | } | 225 | } |
| 226 | |||
| 227 | const auto [left_axis_x, left_axis_y] = | ||
| 228 | GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state)); | ||
| 229 | callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); | ||
| 230 | callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); | ||
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { | 233 | void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { |
| 231 | static constexpr std::array<Joycon::PasivePadButton, 11> right_buttons{ | 234 | static constexpr std::array<PasivePadButton, 11> right_buttons{ |
| 232 | Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, | 235 | PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, |
| 233 | Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, | 236 | PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, |
| 234 | Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, | 237 | PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Plus, |
| 235 | Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, | 238 | PasivePadButton::Home, PasivePadButton::StickR, |
| 236 | Joycon::PasivePadButton::Plus, Joycon::PasivePadButton::Home, | ||
| 237 | Joycon::PasivePadButton::StickR, | ||
| 238 | }; | 239 | }; |
| 239 | 240 | ||
| 240 | for (auto right_button : right_buttons) { | 241 | for (auto right_button : right_buttons) { |
| @@ -242,17 +243,20 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { | |||
| 242 | const int button = static_cast<int>(right_button); | 243 | const int button = static_cast<int>(right_button); |
| 243 | callbacks.on_button_data(button, button_status); | 244 | callbacks.on_button_data(button, button_status); |
| 244 | } | 245 | } |
| 246 | |||
| 247 | const auto [right_axis_x, right_axis_y] = | ||
| 248 | GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state)); | ||
| 249 | callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); | ||
| 250 | callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); | ||
| 245 | } | 251 | } |
| 246 | 252 | ||
| 247 | void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { | 253 | void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { |
| 248 | static constexpr std::array<Joycon::PasivePadButton, 14> pro_buttons{ | 254 | static constexpr std::array<PasivePadButton, 14> pro_buttons{ |
| 249 | Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, | 255 | PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, |
| 250 | Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, | 256 | PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, |
| 251 | Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, | 257 | PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus, |
| 252 | Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, | 258 | PasivePadButton::Plus, PasivePadButton::Capture, PasivePadButton::Home, |
| 253 | Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Plus, | 259 | PasivePadButton::StickL, PasivePadButton::StickR, |
| 254 | Joycon::PasivePadButton::Capture, Joycon::PasivePadButton::Home, | ||
| 255 | Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR, | ||
| 256 | }; | 260 | }; |
| 257 | 261 | ||
| 258 | for (auto pro_button : pro_buttons) { | 262 | for (auto pro_button : pro_buttons) { |
| @@ -260,6 +264,15 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { | |||
| 260 | const int button = static_cast<int>(pro_button); | 264 | const int button = static_cast<int>(pro_button); |
| 261 | callbacks.on_button_data(button, button_status); | 265 | callbacks.on_button_data(button, button_status); |
| 262 | } | 266 | } |
| 267 | |||
| 268 | const auto [left_axis_x, left_axis_y] = | ||
| 269 | GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state && 0xf)); | ||
| 270 | const auto [right_axis_x, right_axis_y] = | ||
| 271 | GetPassiveAxisValue(static_cast<PasivePadStick>(input.stick_state >> 4)); | ||
| 272 | callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); | ||
| 273 | callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); | ||
| 274 | callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); | ||
| 275 | callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); | ||
| 263 | } | 276 | } |
| 264 | 277 | ||
| 265 | f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const { | 278 | f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const { |
| @@ -270,6 +283,30 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca | |||
| 270 | return value / calibration.min; | 283 | return value / calibration.min; |
| 271 | } | 284 | } |
| 272 | 285 | ||
| 286 | std::pair<f32, f32> JoyconPoller::GetPassiveAxisValue(PasivePadStick raw_value) const { | ||
| 287 | switch (raw_value) { | ||
| 288 | case PasivePadStick::Right: | ||
| 289 | return {1.0f, 0.0f}; | ||
| 290 | case PasivePadStick::RightDown: | ||
| 291 | return {1.0f, -1.0f}; | ||
| 292 | case PasivePadStick::Down: | ||
| 293 | return {0.0f, -1.0f}; | ||
| 294 | case PasivePadStick::DownLeft: | ||
| 295 | return {-1.0f, -1.0f}; | ||
| 296 | case PasivePadStick::Left: | ||
| 297 | return {-1.0f, 0.0f}; | ||
| 298 | case PasivePadStick::LeftUp: | ||
| 299 | return {-1.0f, 1.0f}; | ||
| 300 | case PasivePadStick::Up: | ||
| 301 | return {0.0f, 1.0f}; | ||
| 302 | case PasivePadStick::UpRight: | ||
| 303 | return {1.0f, 1.0f}; | ||
| 304 | case PasivePadStick::Neutral: | ||
| 305 | default: | ||
| 306 | return {0.0f, 0.0f}; | ||
| 307 | } | ||
| 308 | } | ||
| 309 | |||
| 273 | f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, | 310 | f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, |
| 274 | AccelerometerSensitivity sensitivity) const { | 311 | AccelerometerSensitivity sensitivity) const { |
| 275 | const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4; | 312 | const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4; |
diff --git a/src/input_common/helpers/joycon_protocol/poller.h b/src/input_common/helpers/joycon_protocol/poller.h index 354d41dad..5c897f070 100644 --- a/src/input_common/helpers/joycon_protocol/poller.h +++ b/src/input_common/helpers/joycon_protocol/poller.h | |||
| @@ -22,7 +22,7 @@ public: | |||
| 22 | JoyStickCalibration right_stick_calibration_, | 22 | JoyStickCalibration right_stick_calibration_, |
| 23 | MotionCalibration motion_calibration_); | 23 | MotionCalibration motion_calibration_); |
| 24 | 24 | ||
| 25 | void SetCallbacks(const Joycon::JoyconCallbacks& callbacks_); | 25 | void SetCallbacks(const JoyconCallbacks& callbacks_); |
| 26 | 26 | ||
| 27 | /// Handles data from passive packages | 27 | /// Handles data from passive packages |
| 28 | void ReadPassiveMode(std::span<u8> buffer); | 28 | void ReadPassiveMode(std::span<u8> buffer); |
| @@ -51,7 +51,10 @@ private: | |||
| 51 | void UpdatePasiveProPadInput(const InputReportPassive& buffer); | 51 | void UpdatePasiveProPadInput(const InputReportPassive& buffer); |
| 52 | 52 | ||
| 53 | /// Returns a calibrated joystick axis from raw axis data | 53 | /// Returns a calibrated joystick axis from raw axis data |
| 54 | f32 GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const; | 54 | f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const; |
| 55 | |||
| 56 | /// Returns a digital joystick axis from passive axis data | ||
| 57 | std::pair<f32, f32> GetPassiveAxisValue(PasivePadStick raw_value) const; | ||
| 55 | 58 | ||
| 56 | /// Returns a calibrated accelerometer axis from raw motion data | 59 | /// Returns a calibrated accelerometer axis from raw motion data |
| 57 | f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, | 60 | f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, |
| @@ -75,7 +78,7 @@ private: | |||
| 75 | JoyStickCalibration right_stick_calibration{}; | 78 | JoyStickCalibration right_stick_calibration{}; |
| 76 | MotionCalibration motion_calibration{}; | 79 | MotionCalibration motion_calibration{}; |
| 77 | 80 | ||
| 78 | Joycon::JoyconCallbacks callbacks{}; | 81 | JoyconCallbacks callbacks{}; |
| 79 | }; | 82 | }; |
| 80 | 83 | ||
| 81 | } // namespace InputCommon::Joycon | 84 | } // namespace InputCommon::Joycon |