This commit is contained in:
HookedBehemoth 2020-02-28 17:59:31 +01:00 committed by GitHub
parent 3ff12e7337
commit 23852ad932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 0 deletions

View File

@ -84,6 +84,7 @@ extern "C" {
#include "switch/services/ns.h"
#include "switch/services/ldr.h"
#include "switch/services/ro.h"
#include "switch/services/tc.h"
#include "switch/services/ts.h"
#include "switch/services/pm.h"
#include "switch/services/set.h"

View File

@ -0,0 +1,26 @@
/**
* @file tc.h
* @brief Temperature control (tc) service IPC wrapper.
* @author Behemoth
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
/// Initialize tc.
Result tcInitialize(void);
/// Exit tc.
void tcExit(void);
/// Gets the Service for tc.
Service* tcGetServiceSession(void);
Result tcEnableFanControl(void);
/// @warning Disabling your fan can damage your system.
Result tcDisableFanControl(void);
Result tcIsFanControlEnabled(bool *status);
/// Only available on [5.0.0+].
Result tcGetSkinTemperatureMilliC(s32 *skinTemp);

47
nx/source/services/tc.c Normal file
View File

@ -0,0 +1,47 @@
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include <string.h>
#include "service_guard.h"
#include "runtime/hosversion.h"
#include "services/tc.h"
static Service g_tcSrv;
NX_GENERATE_SERVICE_GUARD(tc);
Result _tcInitialize(void) {
return smGetService(&g_tcSrv, "tc");
}
void _tcCleanup(void) {
serviceClose(&g_tcSrv);
}
Service* tcGetServiceSession(void) {
return &g_tcSrv;
}
static Result _tcNoInNoOut(u32 cmd_id) {
return serviceDispatch(&g_tcSrv, cmd_id);
}
Result tcEnableFanControl(void) {
return _tcNoInNoOut(6);
}
Result tcDisableFanControl(void) {
return _tcNoInNoOut(7);
}
Result tcIsFanControlEnabled(bool *status) {
u8 tmp=0;
Result rc = serviceDispatchOut(&g_tcSrv, 8, tmp);
if (R_SUCCEEDED(rc) && status) *status = tmp & 1;
return rc;
}
Result tcGetSkinTemperatureMilliC(s32 *skinTemp) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_tcSrv, 9, *skinTemp);
}