mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
add fan service (#376)
This commit is contained in:
parent
abc3522724
commit
7e07d1edf0
@ -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
|
||||
|
32
nx/include/switch/services/fan.h
Normal file
32
nx/include/switch/services/fan.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file fan.h
|
||||
* @brief Fan service IPC wrapper.
|
||||
* @author Behemoth
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../sf/service.h"
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
} FanController;
|
||||
|
||||
/// Initialize fan.
|
||||
Result fanInitialize(void);
|
||||
|
||||
/// Exit fan.
|
||||
void fanExit(void);
|
||||
|
||||
/// Gets the Service object for the actual fan service session.
|
||||
Service* fanGetServiceSession(void);
|
||||
|
||||
/// Opens IController session.
|
||||
Result fanOpenController(FanController *out, u32 device_code);
|
||||
|
||||
/// Close IController session.
|
||||
void fanControllerClose(FanController *controller);
|
||||
|
||||
/// @warning Disabling your fan can damage your system.
|
||||
Result fanControllerSetRotationSpeedLevel(FanController *controller, float level);
|
||||
Result fanControllerGetRotationSpeedLevel(FanController *controller, float *level);
|
39
nx/source/services/fan.c
Normal file
39
nx/source/services/fan.c
Normal file
@ -0,0 +1,39 @@
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include "service_guard.h"
|
||||
#include "services/fan.h"
|
||||
#include "runtime/hosversion.h"
|
||||
|
||||
static Service g_fanSrv;
|
||||
|
||||
NX_GENERATE_SERVICE_GUARD(fan);
|
||||
|
||||
Result _fanInitialize(void) {
|
||||
return smGetService(&g_fanSrv, "fan");
|
||||
}
|
||||
|
||||
void _fanCleanup(void) {
|
||||
serviceClose(&g_fanSrv);
|
||||
}
|
||||
|
||||
Result fanOpenController(FanController *out, u32 device_code) {
|
||||
return serviceDispatchIn(&g_fanSrv, 0, device_code,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
Service* fanGetServiceSession(void) {
|
||||
return &g_fanSrv;
|
||||
}
|
||||
|
||||
void fanControllerClose(FanController *controller) {
|
||||
serviceClose(&controller->s);
|
||||
}
|
||||
|
||||
Result fanControllerSetRotationSpeedLevel(FanController *controller, float level) {
|
||||
return serviceDispatchIn(&controller->s, 0, level);
|
||||
}
|
||||
|
||||
Result fanControllerGetRotationSpeedLevel(FanController *controller, float *level) {
|
||||
return serviceDispatchOut(&controller->s, 2, *level);
|
||||
}
|
Loading…
Reference in New Issue
Block a user