diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/lbl/lbl.cpp | 283 |
1 files changed, 261 insertions, 22 deletions
diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index 6ad3a2877..f4490f3d9 100644 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp | |||
| @@ -20,30 +20,30 @@ public: | |||
| 20 | static const FunctionInfo functions[] = { | 20 | static const FunctionInfo functions[] = { |
| 21 | {0, nullptr, "SaveCurrentSetting"}, | 21 | {0, nullptr, "SaveCurrentSetting"}, |
| 22 | {1, nullptr, "LoadCurrentSetting"}, | 22 | {1, nullptr, "LoadCurrentSetting"}, |
| 23 | {2, nullptr, "SetCurrentBrightnessSetting"}, | 23 | {2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"}, |
| 24 | {3, nullptr, "GetCurrentBrightnessSetting"}, | 24 | {3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"}, |
| 25 | {4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"}, | 25 | {4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"}, |
| 26 | {5, nullptr, "GetBrightnessSettingAppliedToBacklight"}, | 26 | {5, nullptr, "GetBrightnessSettingAppliedToBacklight"}, |
| 27 | {6, nullptr, "SwitchBacklightOn"}, | 27 | {6, &LBL::SwitchBacklightOn, "SwitchBacklightOn"}, |
| 28 | {7, nullptr, "SwitchBacklightOff"}, | 28 | {7, &LBL::SwitchBacklightOff, "SwitchBacklightOff"}, |
| 29 | {8, nullptr, "GetBacklightSwitchStatus"}, | 29 | {8, &LBL::GetBacklightSwitchStatus, "GetBacklightSwitchStatus"}, |
| 30 | {9, nullptr, "EnableDimming"}, | 30 | {9, &LBL::EnableDimming, "EnableDimming"}, |
| 31 | {10, nullptr, "DisableDimming"}, | 31 | {10, &LBL::DisableDimming, "DisableDimming"}, |
| 32 | {11, nullptr, "IsDimmingEnabled"}, | 32 | {11, &LBL::IsDimmingEnabled, "IsDimmingEnabled"}, |
| 33 | {12, nullptr, "EnableAutoBrightnessControl"}, | 33 | {12, &LBL::EnableAutoBrightnessControl, "EnableAutoBrightnessControl"}, |
| 34 | {13, nullptr, "DisableAutoBrightnessControl"}, | 34 | {13, &LBL::DisableAutoBrightnessControl, "DisableAutoBrightnessControl"}, |
| 35 | {14, nullptr, "IsAutoBrightnessControlEnabled"}, | 35 | {14, &LBL::IsAutoBrightnessControlEnabled, "IsAutoBrightnessControlEnabled"}, |
| 36 | {15, nullptr, "SetAmbientLightSensorValue"}, | 36 | {15, &LBL::SetAmbientLightSensorValue, "SetAmbientLightSensorValue"}, |
| 37 | {16, nullptr, "GetAmbientLightSensorValue"}, | 37 | {16, &LBL::GetAmbientLightSensorValue, "GetAmbientLightSensorValue"}, |
| 38 | {17, nullptr, "SetBrightnessReflectionDelayLevel"}, | 38 | {17, &LBL::SetBrightnessReflectionDelayLevel, "SetBrightnessReflectionDelayLevel"}, |
| 39 | {18, nullptr, "GetBrightnessReflectionDelayLevel"}, | 39 | {18, &LBL::GetBrightnessReflectionDelayLevel, "GetBrightnessReflectionDelayLevel"}, |
| 40 | {19, nullptr, "SetCurrentBrightnessMapping"}, | 40 | {19, &LBL::SetCurrentBrightnessMapping, "SetCurrentBrightnessMapping"}, |
| 41 | {20, nullptr, "GetCurrentBrightnessMapping"}, | 41 | {20, &LBL::GetCurrentBrightnessMapping, "GetCurrentBrightnessMapping"}, |
| 42 | {21, nullptr, "SetCurrentAmbientLightSensorMapping"}, | 42 | {21, &LBL::SetCurrentAmbientLightSensorMapping, "SetCurrentAmbientLightSensorMapping"}, |
| 43 | {22, nullptr, "GetCurrentAmbientLightSensorMapping"}, | 43 | {22, &LBL::GetCurrentAmbientLightSensorMapping, "GetCurrentAmbientLightSensorMapping"}, |
| 44 | {23, nullptr, "IsAmbientLightSensorAvailable"}, | 44 | {23, &LBL::IsAmbientLightSensorAvailable, "IsAmbientLightSensorAvailable"}, |
| 45 | {24, nullptr, "SetCurrentBrightnessSettingForVrMode"}, | 45 | {24, &LBL::SetCurrentBrightnessSettingForVrMode, "SetCurrentBrightnessSettingForVrMode"}, |
| 46 | {25, nullptr, "GetCurrentBrightnessSettingForVrMode"}, | 46 | {25, &LBL::GetCurrentBrightnessSettingForVrMode, "GetCurrentBrightnessSettingForVrMode"}, |
| 47 | {26, &LBL::EnableVrMode, "EnableVrMode"}, | 47 | {26, &LBL::EnableVrMode, "EnableVrMode"}, |
| 48 | {27, &LBL::DisableVrMode, "DisableVrMode"}, | 48 | {27, &LBL::DisableVrMode, "DisableVrMode"}, |
| 49 | {28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"}, | 49 | {28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"}, |
| @@ -55,6 +55,237 @@ public: | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | private: | 57 | private: |
| 58 | enum class BacklightSwitchStatus : u32 { | ||
| 59 | Off = 0, | ||
| 60 | On = 1, | ||
| 61 | }; | ||
| 62 | |||
| 63 | void SetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) { | ||
| 64 | IPC::RequestParser rp{ctx}; | ||
| 65 | auto brightness = rp.Pop<float>(); | ||
| 66 | |||
| 67 | if (!std::isfinite(brightness)) { | ||
| 68 | LOG_ERROR(Service_LBL, "Brightness is infinite!"); | ||
| 69 | brightness = 0.0f; | ||
| 70 | } | ||
| 71 | |||
| 72 | LOG_DEBUG(Service_LBL, "called brightness={}", brightness); | ||
| 73 | |||
| 74 | current_brightness = brightness; | ||
| 75 | update_instantly = true; | ||
| 76 | |||
| 77 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 78 | rb.Push(RESULT_SUCCESS); | ||
| 79 | } | ||
| 80 | |||
| 81 | void GetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) { | ||
| 82 | IPC::RequestParser rp{ctx}; | ||
| 83 | auto brightness = current_brightness; | ||
| 84 | if (!std::isfinite(brightness)) { | ||
| 85 | LOG_ERROR(Service_LBL, "Brightness is infinite!"); | ||
| 86 | brightness = 0.0f; | ||
| 87 | } | ||
| 88 | |||
| 89 | LOG_DEBUG(Service_LBL, "called brightness={}", brightness); | ||
| 90 | |||
| 91 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 92 | rb.Push(RESULT_SUCCESS); | ||
| 93 | rb.Push(brightness); | ||
| 94 | } | ||
| 95 | |||
| 96 | void SwitchBacklightOn(Kernel::HLERequestContext& ctx) { | ||
| 97 | IPC::RequestParser rp{ctx}; | ||
| 98 | const auto fade_time = rp.Pop<u64_le>(); | ||
| 99 | LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time); | ||
| 100 | |||
| 101 | backlight_enabled = true; | ||
| 102 | |||
| 103 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 104 | rb.Push(RESULT_SUCCESS); | ||
| 105 | } | ||
| 106 | |||
| 107 | void SwitchBacklightOff(Kernel::HLERequestContext& ctx) { | ||
| 108 | IPC::RequestParser rp{ctx}; | ||
| 109 | const auto fade_time = rp.Pop<u64_le>(); | ||
| 110 | LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time); | ||
| 111 | |||
| 112 | backlight_enabled = false; | ||
| 113 | |||
| 114 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 115 | rb.Push(RESULT_SUCCESS); | ||
| 116 | } | ||
| 117 | |||
| 118 | void GetBacklightSwitchStatus(Kernel::HLERequestContext& ctx) { | ||
| 119 | LOG_DEBUG(Service_LBL, "called"); | ||
| 120 | |||
| 121 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 122 | rb.Push(RESULT_SUCCESS); | ||
| 123 | rb.PushEnum<BacklightSwitchStatus>(backlight_enabled ? BacklightSwitchStatus::On | ||
| 124 | : BacklightSwitchStatus::Off); | ||
| 125 | } | ||
| 126 | |||
| 127 | void EnableDimming(Kernel::HLERequestContext& ctx) { | ||
| 128 | LOG_DEBUG(Service_LBL, "called"); | ||
| 129 | |||
| 130 | dimming = true; | ||
| 131 | |||
| 132 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 133 | rb.Push(RESULT_SUCCESS); | ||
| 134 | } | ||
| 135 | |||
| 136 | void DisableDimming(Kernel::HLERequestContext& ctx) { | ||
| 137 | LOG_DEBUG(Service_LBL, "called"); | ||
| 138 | |||
| 139 | dimming = false; | ||
| 140 | |||
| 141 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 142 | rb.Push(RESULT_SUCCESS); | ||
| 143 | } | ||
| 144 | |||
| 145 | void IsDimmingEnabled(Kernel::HLERequestContext& ctx) { | ||
| 146 | LOG_DEBUG(Service_LBL, "called"); | ||
| 147 | |||
| 148 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 149 | rb.Push(RESULT_SUCCESS); | ||
| 150 | rb.Push(dimming); | ||
| 151 | } | ||
| 152 | |||
| 153 | void EnableAutoBrightnessControl(Kernel::HLERequestContext& ctx) { | ||
| 154 | LOG_DEBUG(Service_LBL, "called"); | ||
| 155 | auto_brightness = true; | ||
| 156 | update_instantly = true; | ||
| 157 | |||
| 158 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 159 | rb.Push(RESULT_SUCCESS); | ||
| 160 | } | ||
| 161 | |||
| 162 | void DisableAutoBrightnessControl(Kernel::HLERequestContext& ctx) { | ||
| 163 | LOG_DEBUG(Service_LBL, "called"); | ||
| 164 | auto_brightness = false; | ||
| 165 | |||
| 166 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 167 | rb.Push(RESULT_SUCCESS); | ||
| 168 | } | ||
| 169 | |||
| 170 | void IsAutoBrightnessControlEnabled(Kernel::HLERequestContext& ctx) { | ||
| 171 | LOG_DEBUG(Service_LBL, "called"); | ||
| 172 | |||
| 173 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 174 | rb.Push(RESULT_SUCCESS); | ||
| 175 | rb.Push(auto_brightness); | ||
| 176 | } | ||
| 177 | |||
| 178 | void SetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) { | ||
| 179 | IPC::RequestParser rp{ctx}; | ||
| 180 | const auto light_value = rp.Pop<float>(); | ||
| 181 | |||
| 182 | LOG_DEBUG(Service_LBL, "called light_value={}", light_value); | ||
| 183 | |||
| 184 | ambient_light_value = light_value; | ||
| 185 | |||
| 186 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 187 | rb.Push(RESULT_SUCCESS); | ||
| 188 | } | ||
| 189 | |||
| 190 | void GetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) { | ||
| 191 | LOG_DEBUG(Service_LBL, "called"); | ||
| 192 | |||
| 193 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 194 | rb.Push(RESULT_SUCCESS); | ||
| 195 | rb.Push(ambient_light_value); | ||
| 196 | } | ||
| 197 | |||
| 198 | void SetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) { | ||
| 199 | // This is Intentional, this function does absolutely nothing | ||
| 200 | LOG_DEBUG(Service_LBL, "called"); | ||
| 201 | |||
| 202 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 203 | rb.Push(RESULT_SUCCESS); | ||
| 204 | } | ||
| 205 | |||
| 206 | void GetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) { | ||
| 207 | // This is intentional, the function is hard coded to return 0.0f on hardware | ||
| 208 | LOG_DEBUG(Service_LBL, "called"); | ||
| 209 | |||
| 210 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 211 | rb.Push(RESULT_SUCCESS); | ||
| 212 | rb.Push(0.0f); | ||
| 213 | } | ||
| 214 | |||
| 215 | void SetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) { | ||
| 216 | // This is Intentional, this function does absolutely nothing | ||
| 217 | LOG_DEBUG(Service_LBL, "called"); | ||
| 218 | |||
| 219 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 220 | rb.Push(RESULT_SUCCESS); | ||
| 221 | } | ||
| 222 | |||
| 223 | void GetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) { | ||
| 224 | // This is Intentional, this function does absolutely nothing | ||
| 225 | LOG_DEBUG(Service_LBL, "called"); | ||
| 226 | |||
| 227 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 228 | rb.Push(RESULT_SUCCESS); | ||
| 229 | // This function is suppose to return something but it seems like it doesn't | ||
| 230 | } | ||
| 231 | |||
| 232 | void SetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) { | ||
| 233 | // This is Intentional, this function does absolutely nothing | ||
| 234 | LOG_DEBUG(Service_LBL, "called"); | ||
| 235 | |||
| 236 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 237 | rb.Push(RESULT_SUCCESS); | ||
| 238 | } | ||
| 239 | |||
| 240 | void GetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) { | ||
| 241 | // This is Intentional, this function does absolutely nothing | ||
| 242 | LOG_DEBUG(Service_LBL, "called"); | ||
| 243 | |||
| 244 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 245 | rb.Push(RESULT_SUCCESS); | ||
| 246 | // This function is suppose to return something but it seems like it doesn't | ||
| 247 | } | ||
| 248 | |||
| 249 | void IsAmbientLightSensorAvailable(Kernel::HLERequestContext& ctx) { | ||
| 250 | LOG_WARNING(Service_LBL, "(STUBBED) called"); | ||
| 251 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 252 | rb.Push(RESULT_SUCCESS); | ||
| 253 | // TODO(ogniK): Only return true if there's no device error | ||
| 254 | rb.Push(true); | ||
| 255 | } | ||
| 256 | |||
| 257 | void SetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) { | ||
| 258 | IPC::RequestParser rp{ctx}; | ||
| 259 | auto brightness = rp.Pop<float>(); | ||
| 260 | |||
| 261 | if (!std::isfinite(brightness)) { | ||
| 262 | LOG_ERROR(Service_LBL, "Brightness is infinite!"); | ||
| 263 | brightness = 0.0f; | ||
| 264 | } | ||
| 265 | |||
| 266 | LOG_DEBUG(Service_LBL, "called brightness={}", brightness); | ||
| 267 | |||
| 268 | current_vr_brightness = brightness; | ||
| 269 | |||
| 270 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 271 | rb.Push(RESULT_SUCCESS); | ||
| 272 | } | ||
| 273 | |||
| 274 | void GetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) { | ||
| 275 | IPC::RequestParser rp{ctx}; | ||
| 276 | auto brightness = current_vr_brightness; | ||
| 277 | if (!std::isfinite(brightness)) { | ||
| 278 | LOG_ERROR(Service_LBL, "Brightness is infinite!"); | ||
| 279 | brightness = 0.0f; | ||
| 280 | } | ||
| 281 | |||
| 282 | LOG_DEBUG(Service_LBL, "called brightness={}", brightness); | ||
| 283 | |||
| 284 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 285 | rb.Push(RESULT_SUCCESS); | ||
| 286 | rb.Push(brightness); | ||
| 287 | } | ||
| 288 | |||
| 58 | void EnableVrMode(Kernel::HLERequestContext& ctx) { | 289 | void EnableVrMode(Kernel::HLERequestContext& ctx) { |
| 59 | LOG_DEBUG(Service_LBL, "called"); | 290 | LOG_DEBUG(Service_LBL, "called"); |
| 60 | 291 | ||
| @@ -82,6 +313,14 @@ private: | |||
| 82 | } | 313 | } |
| 83 | 314 | ||
| 84 | bool vr_mode_enabled = false; | 315 | bool vr_mode_enabled = false; |
| 316 | float current_brightness = 1.0f; | ||
| 317 | float backlight_brightness = 1.0f; | ||
| 318 | float ambient_light_value = 0.0f; | ||
| 319 | float current_vr_brightness = 1.0f; | ||
| 320 | bool dimming = true; | ||
| 321 | bool backlight_enabled = true; | ||
| 322 | bool update_instantly = false; | ||
| 323 | bool auto_brightness = false; // TODO(ogniK): Move to system settings | ||
| 85 | }; | 324 | }; |
| 86 | 325 | ||
| 87 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 326 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { |