mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 02:22:15 +02:00
fan: expose fanOpenController
This commit is contained in:
parent
11c55b3189
commit
48eb64a53e
@ -8,6 +8,10 @@
|
||||
#include "../types.h"
|
||||
#include "../sf/service.h"
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
} FanController;
|
||||
|
||||
/// Initialize fan.
|
||||
Result fanInitialize(void);
|
||||
|
||||
@ -17,9 +21,9 @@ void fanExit(void);
|
||||
/// Gets the Service object for the actual fan service session.
|
||||
Service* fanGetServiceSession(void);
|
||||
|
||||
/// Gets the Service object for the actual fan controller service session.
|
||||
Service* fanGetServiceSession_Controller(void);
|
||||
/// Opens IController session.
|
||||
Result fanOpenController(FanController *out, u32 device_code);
|
||||
|
||||
/// @warning Disabling your fan can damage your system.
|
||||
Result fanSetRotationSpeedLevel(float level);
|
||||
Result fanGetRotationSpeedLevel(float *level);
|
||||
Result fanSetRotationSpeedLevel(FanController *controller, float level);
|
||||
Result fanGetRotationSpeedLevel(FanController *controller, float *level);
|
@ -4,30 +4,21 @@
|
||||
#include "runtime/hosversion.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;
|
||||
return smGetService(&g_fanSrv, "fan");
|
||||
}
|
||||
|
||||
void _fanCleanup(void) {
|
||||
serviceClose(&g_fanCtl);
|
||||
serviceClose(&g_fanSrv);
|
||||
}
|
||||
|
||||
Result _fanOpenController(void) {
|
||||
u32 in = hosversionBefore(7,0,0) ? 1 : 0x3d000001;
|
||||
return serviceDispatchIn(&g_fanSrv, 0, in,
|
||||
Result fanOpenController(FanController *out, u32 device_code) {
|
||||
return serviceDispatchIn(&g_fanSrv, 0, device_code,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &g_fanCtl
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
@ -35,14 +26,10 @@ Service* fanGetServiceSession(void) {
|
||||
return &g_fanSrv;
|
||||
}
|
||||
|
||||
Service* fanGetServiceSession_Controller(void) {
|
||||
return &g_fanCtl;
|
||||
Result fanSetRotationSpeedLevel(FanController *controller, float level) {
|
||||
return serviceDispatchIn(&controller->s, 0, level);
|
||||
}
|
||||
|
||||
Result fanSetRotationSpeedLevel(float level) {
|
||||
return serviceDispatchIn(&g_fanCtl, 0, level);
|
||||
}
|
||||
|
||||
Result fanGetRotationSpeedLevel(float *level) {
|
||||
return serviceDispatchOut(&g_fanCtl, 2, *level);
|
||||
Result fanGetRotationSpeedLevel(FanController *controller, float *level) {
|
||||
return serviceDispatchOut(&controller->s, 2, *level);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user