mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 02:22:15 +02:00
add tc
This commit is contained in:
parent
129b3a95b8
commit
9c69fde167
@ -84,6 +84,7 @@ extern "C" {
|
|||||||
#include "switch/services/ns.h"
|
#include "switch/services/ns.h"
|
||||||
#include "switch/services/ldr.h"
|
#include "switch/services/ldr.h"
|
||||||
#include "switch/services/ro.h"
|
#include "switch/services/ro.h"
|
||||||
|
#include "switch/services/tc.h"
|
||||||
#include "switch/services/ts.h"
|
#include "switch/services/ts.h"
|
||||||
#include "switch/services/pm.h"
|
#include "switch/services/pm.h"
|
||||||
#include "switch/services/set.h"
|
#include "switch/services/set.h"
|
||||||
|
25
nx/include/switch/services/tc.h
Normal file
25
nx/include/switch/services/tc.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @file tc.h
|
||||||
|
* @brief Temperature control (tc) service IPC wrapper.
|
||||||
|
* @author yellows8
|
||||||
|
* @copyright libnx Authors
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../sf/service.h"
|
||||||
|
|
||||||
|
/// Initialize tc.
|
||||||
|
Result tcInitialize(void);
|
||||||
|
|
||||||
|
/// Exit tc.
|
||||||
|
void tcExit(void);
|
||||||
|
|
||||||
|
/// Getc the Service for tc.
|
||||||
|
Service* tcGetServiceSession(void);
|
||||||
|
|
||||||
|
Result tcEnableFanControl(void);
|
||||||
|
Result tcDisableFanControl(void);
|
||||||
|
Result tcIsFanControlEnabled(bool *status);
|
||||||
|
/// Only available on [5.0.0+]
|
||||||
|
Result tcGetSkinTemperatureMilliC(s32 *skinTemp);
|
||||||
|
|
56
nx/source/services/tc.c
Normal file
56
nx/source/services/tc.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#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) {
|
||||||
|
struct {
|
||||||
|
u8 status;
|
||||||
|
} out;
|
||||||
|
|
||||||
|
Result rc = serviceDispatchOut(&g_tcSrv, 8, out);
|
||||||
|
if (R_SUCCEEDED(rc)) *status = out.status;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result tcGetSkinTemperatureMilliC(s32 *skinTemp) {
|
||||||
|
if (hosversionBefore(5,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
s32 skinTemp;
|
||||||
|
} out;
|
||||||
|
|
||||||
|
Result rc = serviceDispatchOut(&g_tcSrv, 9, out);
|
||||||
|
if (R_SUCCEEDED(rc)) *skinTemp = out.skinTemp;
|
||||||
|
return rc;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user