From ab3513c6aeeee4f0e90e8b69fce5a50e5fcd3383 Mon Sep 17 00:00:00 2001 From: HookedBehemoth Date: Sun, 23 Feb 2020 15:52:26 +0100 Subject: [PATCH] fix lbl --- nx/include/switch/services/lbl.h | 36 ++++++++++++++++++++++++++++++-- nx/source/services/lbl.c | 17 +++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/nx/include/switch/services/lbl.h b/nx/include/switch/services/lbl.h index 6532dca1..02f589fb 100644 --- a/nx/include/switch/services/lbl.h +++ b/nx/include/switch/services/lbl.h @@ -8,6 +8,13 @@ #include "../types.h" #include "../sf/service.h" +typedef enum { + LblBacklightSwitchStatus_Disabled = 0, + LblBacklightSwitchStatus_Enabled = 1, + LblBacklightSwitchStatus_Enabling = 2, + LblBacklightSwitchStatus_Disabling = 3 +} LblBacklightSwitchStatus; + /// Initialize lbl. Result lblInitialize(void); @@ -31,7 +38,7 @@ Result lblGetBrightnessSettingAppliedToBacklight(float *out_value); Result lblSwitchBacklightOn(u64 fade_time); Result lblSwitchBacklightOff(u64 fade_time); -Result lblGetBacklightSwitchStatus(bool *out_value); +Result lblGetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value); Result lblEnableDimming(void); Result lblDisableDimming(void); @@ -44,10 +51,35 @@ Result lblIsAutoBrightnessControlEnabled(bool *out_value); Result lblSetAmbientLightSensorValue(float value); Result lblGetAmbientLightSensorValue(bool *over_limit, float *lux); -/* Only available on [3.0.0+] */ +/** + * @note Only available on [3.0.0+]. + */ Result lblIsAmbientLightSensorAvailable(bool *out_value); + +/** + * @note Only available on [3.0.0+]. + */ Result lblSetCurrentBrightnessSettingForVrMode(float brightness); + +/** + * @note Only available on [3.0.0+]. + */ Result lblGetCurrentBrightnessSettingForVrMode(float *out_value); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by am SetVrModeEnabled. + */ Result lblEnableVrMode(void); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by am SetVrModeEnabled. + */ Result lblDisableVrMode(void); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by am IsVrModeEnabled. + */ Result lblIsVrModeEnabled(bool *out_value); diff --git a/nx/source/services/lbl.c b/nx/source/services/lbl.c index 4be83322..4e39b081 100644 --- a/nx/source/services/lbl.c +++ b/nx/source/services/lbl.c @@ -39,10 +39,7 @@ static Result _lblCmdNoInOutBool(bool *out, u32 cmd_id) { } static Result _lblCmdNoInOutFloat(float *out, u32 cmd_id) { - float tmpout=0; - Result rc = serviceDispatchOut(&g_lblSrv, cmd_id, tmpout); - if (R_SUCCEEDED(rc) && out) *out = tmpout; - return rc; + return serviceDispatchOut(&g_lblSrv, cmd_id, *out); } Result lblSaveCurrentSetting(void) { @@ -77,11 +74,8 @@ Result lblSwitchBacklightOff(u64 fade_time) { return _lblCmdInU64NoOut(fade_time, 7); } -Result lblGetBacklightSwitchStatus(bool *out_value) { - u32 tmpout=0; - Result rc = serviceDispatchOut(&g_lblSrv, 8, tmpout); - if (R_SUCCEEDED(rc) && out_value) *out_value = tmpout & 0xff; - return rc; +Result lblGetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value) { + return serviceDispatchOut(&g_lblSrv, 8, *out_value); } Result lblEnableDimming(void) { @@ -96,7 +90,6 @@ Result lblIsDimmingEnabled(bool *out_value) { return _lblCmdNoInOutBool(out_value, 11); } - Result lblEnableAutoBrightnessControl(void) { return _lblCmdNoIO(12); } @@ -121,7 +114,7 @@ Result lblGetAmbientLightSensorValue(bool *over_limit, float *lux) { Result rc = serviceDispatchOut(&g_lblSrv, 16, out); if (R_SUCCEEDED(rc)) { - if (over_limit) *over_limit = out.over_limit & 0xff; + if (over_limit) *over_limit = out.over_limit & 1; if (lux) *lux = out.lux; } return rc; @@ -130,7 +123,7 @@ Result lblGetAmbientLightSensorValue(bool *over_limit, float *lux) { Result lblIsAmbientLightSensorAvailable(bool *out_value) { if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - return _lblCmdNoIO(23); + return _lblCmdNoInOutBool(out_value, 23); } Result lblSetCurrentBrightnessSettingForVrMode(float brightness) { if (hosversionBefore(3,0,0))