mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
lbl: more commands (#377)
This commit is contained in:
parent
23852ad932
commit
abc3522724
@ -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);
|
||||
|
||||
@ -17,8 +24,8 @@ void lblExit(void);
|
||||
/// Gets the Service object for the actual lbl service session.
|
||||
Service* lblGetServiceSession(void);
|
||||
|
||||
Result lblSwitchBacklightOn(u64 fade_time);
|
||||
Result lblSwitchBacklightOff(u64 fade_time);
|
||||
Result lblSaveCurrentSetting(void);
|
||||
Result lblLoadCurrentSetting(void);
|
||||
|
||||
/**
|
||||
* @note The brightness goes from 0 to 1.0.
|
||||
@ -26,6 +33,58 @@ Result lblSwitchBacklightOff(u64 fade_time);
|
||||
Result lblSetCurrentBrightnessSetting(float brightness);
|
||||
Result lblGetCurrentBrightnessSetting(float *out_value);
|
||||
|
||||
Result lblApplyCurrentBrightnessSettingToBacklight(void);
|
||||
Result lblGetBrightnessSettingAppliedToBacklight(float *out_value);
|
||||
|
||||
Result lblSwitchBacklightOn(u64 fade_time);
|
||||
Result lblSwitchBacklightOff(u64 fade_time);
|
||||
Result lblGetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value);
|
||||
|
||||
Result lblEnableDimming(void);
|
||||
Result lblDisableDimming(void);
|
||||
Result lblIsDimmingEnabled(bool *out_value);
|
||||
|
||||
Result lblEnableAutoBrightnessControl(void);
|
||||
Result lblDisableAutoBrightnessControl(void);
|
||||
Result lblIsAutoBrightnessControlEnabled(bool *out_value);
|
||||
|
||||
Result lblSetAmbientLightSensorValue(float value);
|
||||
|
||||
/**
|
||||
* @note Used internally by \ref appletGetAmbientLightSensorValue and \ref appletGetCurrentIlluminanceEx.
|
||||
*/
|
||||
Result lblGetAmbientLightSensorValue(bool *over_limit, float *lux);
|
||||
|
||||
/**
|
||||
* @note Only available on [3.0.0+].
|
||||
* @note Used internally by \ref appletIsIlluminanceAvailable.
|
||||
*/
|
||||
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 \ref appletSetVrModeEnabled.
|
||||
*/
|
||||
Result lblEnableVrMode(void);
|
||||
|
||||
/**
|
||||
* @note Only available on [3.0.0+].
|
||||
* @note Used internally by \ref appletSetVrModeEnabled.
|
||||
*/
|
||||
Result lblDisableVrMode(void);
|
||||
|
||||
/**
|
||||
* @note Only available on [3.0.0+].
|
||||
* @note Used internally by \ref appletIsVrModeEnabled.
|
||||
*/
|
||||
Result lblIsVrModeEnabled(bool *out_value);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include "service_guard.h"
|
||||
#include "services/lbl.h"
|
||||
#include "runtime/hosversion.h"
|
||||
|
||||
static Service g_lblSrv;
|
||||
|
||||
@ -37,6 +38,38 @@ static Result _lblCmdNoInOutBool(bool *out, u32 cmd_id) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _lblCmdNoInOutFloat(float *out, u32 cmd_id) {
|
||||
return serviceDispatchOut(&g_lblSrv, cmd_id, *out);
|
||||
}
|
||||
|
||||
static Result _lblCmdInFloatNoOut(float in, u32 cmd_id) {
|
||||
return serviceDispatchIn(&g_lblSrv, cmd_id, in);
|
||||
}
|
||||
|
||||
Result lblSaveCurrentSetting(void) {
|
||||
return _lblCmdNoIO(0);
|
||||
}
|
||||
|
||||
Result lblLoadCurrentSetting(void) {
|
||||
return _lblCmdNoIO(1);
|
||||
}
|
||||
|
||||
Result lblSetCurrentBrightnessSetting(float brightness) {
|
||||
return _lblCmdInFloatNoOut(brightness, 2);
|
||||
}
|
||||
|
||||
Result lblGetCurrentBrightnessSetting(float *out_value) {
|
||||
return _lblCmdNoInOutFloat(out_value, 3);
|
||||
}
|
||||
|
||||
Result lblApplyCurrentBrightnessSettingToBacklight(void) {
|
||||
return _lblCmdNoIO(4);
|
||||
}
|
||||
|
||||
Result lblGetBrightnessSettingAppliedToBacklight(float *out_value) {
|
||||
return _lblCmdNoInOutFloat(out_value, 5);
|
||||
}
|
||||
|
||||
Result lblSwitchBacklightOn(u64 fade_time) {
|
||||
return _lblCmdInU64NoOut(fade_time, 6);
|
||||
}
|
||||
@ -45,12 +78,20 @@ Result lblSwitchBacklightOff(u64 fade_time) {
|
||||
return _lblCmdInU64NoOut(fade_time, 7);
|
||||
}
|
||||
|
||||
Result lblSetCurrentBrightnessSetting(float brightness) {
|
||||
return serviceDispatchIn(&g_lblSrv, 2, brightness);
|
||||
Result lblGetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value) {
|
||||
return serviceDispatchOut(&g_lblSrv, 8, *out_value);
|
||||
}
|
||||
|
||||
Result lblGetCurrentBrightnessSetting(float *out_value) {
|
||||
return serviceDispatchOut(&g_lblSrv, 3, *out_value);
|
||||
Result lblEnableDimming(void) {
|
||||
return _lblCmdNoIO(9);
|
||||
}
|
||||
|
||||
Result lblDisableDimming(void) {
|
||||
return _lblCmdNoIO(10);
|
||||
}
|
||||
|
||||
Result lblIsDimmingEnabled(bool *out_value) {
|
||||
return _lblCmdNoInOutBool(out_value, 11);
|
||||
}
|
||||
|
||||
Result lblEnableAutoBrightnessControl(void) {
|
||||
@ -64,3 +105,55 @@ Result lblDisableAutoBrightnessControl(void) {
|
||||
Result lblIsAutoBrightnessControlEnabled(bool *out_value){
|
||||
return _lblCmdNoInOutBool(out_value, 14);
|
||||
}
|
||||
|
||||
Result lblSetAmbientLightSensorValue(float value) {
|
||||
return _lblCmdInFloatNoOut(value, 15);
|
||||
}
|
||||
|
||||
Result lblGetAmbientLightSensorValue(bool *over_limit, float *lux) {
|
||||
struct {
|
||||
u32 over_limit;
|
||||
float lux;
|
||||
} out;
|
||||
|
||||
Result rc = serviceDispatchOut(&g_lblSrv, 16, out);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (over_limit) *over_limit = out.over_limit & 1;
|
||||
if (lux) *lux = out.lux;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result lblIsAmbientLightSensorAvailable(bool *out_value) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdNoInOutBool(out_value, 23);
|
||||
}
|
||||
Result lblSetCurrentBrightnessSettingForVrMode(float brightness) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdInFloatNoOut(brightness, 24);
|
||||
}
|
||||
Result lblGetCurrentBrightnessSettingForVrMode(float *out_value) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdNoInOutFloat(out_value, 25);
|
||||
}
|
||||
|
||||
Result lblEnableVrMode(void) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdNoIO(26);
|
||||
}
|
||||
|
||||
Result lblDisableVrMode(void) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdNoIO(27);
|
||||
}
|
||||
|
||||
Result lblIsVrModeEnabled(bool *out_value) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
return _lblCmdNoInOutBool(out_value, 28);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user