This commit is contained in:
HookedBehemoth 2020-02-21 13:40:18 +01:00
parent 129b3a95b8
commit 168a9fc464
3 changed files with 58 additions and 0 deletions

View File

@ -64,6 +64,7 @@ extern "C" {
#include "switch/services/bpc.h" #include "switch/services/bpc.h"
#include "switch/services/pcv.h" #include "switch/services/pcv.h"
#include "switch/services/clkrst.h" #include "switch/services/clkrst.h"
#include "switch/services/fan.h"
#include "switch/services/psm.h" #include "switch/services/psm.h"
#include "switch/services/spsm.h" #include "switch/services/spsm.h"
//#include "switch/services/bsd.h" Use <sys/socket.h> instead //#include "switch/services/bsd.h" Use <sys/socket.h> instead

View File

@ -0,0 +1,11 @@
#pragma once
#include "../types.h"
#include "../sf/service.h"
Result fanInitialize(void);
void fanExit(void);
Service* fanGetServiceSession(void);
Service* fanGetServiceSession_Controller(void);
Result fanSetRotationSpeedLevel(float level);
Result fanGetRotationSpeedLevel(float *level);

46
nx/source/services/fan.c Normal file
View File

@ -0,0 +1,46 @@
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include "service_guard.h"
#include "services/fan.h"
static Service g_fanSrv;
static Service g_fanCtl;
static Result _fanOpenController(void);
NX_GENERATE_SERVICE_GUARD(fan);
Result _fanInitialize(void) {
Result rc = smGetService(&g_fanSrv, "fan");
if (R_SUCCEEDED(rc)) rc = _fanOpenController();
return rc;
}
void _fanCleanup(void) {
serviceClose(&g_fanSrv);
}
Result _fanOpenController(void) {
u32 in = 0x3d000001;
return serviceDispatchIn(&g_fanSrv, 0, in,
.out_num_objects = 1,
.out_objects = &g_fanCtl
);
}
Service* fanGetServiceSession(void) {
return &g_fanSrv;
}
Service* fanGetServiceSession_Controller(void) {
return &g_fanCtl;
}
Result fanSetRotationSpeedLevel(float level) {
return serviceDispatchOut(&g_fanCtl, 0, level);
}
Result fanGetRotationSpeedLevel(float *level) {
return serviceDispatchOut(&g_fanCtl, 2, *level);
}