mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 18:12:14 +02:00
add fan
This commit is contained in:
parent
129b3a95b8
commit
168a9fc464
@ -64,6 +64,7 @@ extern "C" {
|
||||
#include "switch/services/bpc.h"
|
||||
#include "switch/services/pcv.h"
|
||||
#include "switch/services/clkrst.h"
|
||||
#include "switch/services/fan.h"
|
||||
#include "switch/services/psm.h"
|
||||
#include "switch/services/spsm.h"
|
||||
//#include "switch/services/bsd.h" Use <sys/socket.h> instead
|
||||
|
11
nx/include/switch/services/fan.h
Normal file
11
nx/include/switch/services/fan.h
Normal 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
46
nx/source/services/fan.c
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user