mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
add tc (#378)
This commit is contained in:
parent
3ff12e7337
commit
23852ad932
@ -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"
|
||||
|
26
nx/include/switch/services/tc.h
Normal file
26
nx/include/switch/services/tc.h
Normal 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
47
nx/source/services/tc.c
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user