Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nx/include/switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ extern "C" {
#include "switch/services/ectx.h"
#include "switch/services/avm.h"
#include "switch/services/mm.h"
#include "switch/services/omm.h"

#include "switch/display/binder.h"
#include "switch/display/parcel.h"
Expand Down
41 changes: 41 additions & 0 deletions nx/include/switch/services/omm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file omm.h
* @author MasaGratoR
* @copyright libnx Authors
*/

#pragma once

#include "../types.h"
#include "../sf/service.h"

///OperationMode
typedef enum {
OmmOperationMode_Handheld = 0,
OmmOperationMode_Console = 1
} OmmOperationMode;

///OperationModePolicy
typedef enum {
OmmOperationModePolicy_Auto = 0,
OmmOperationModePolicy_Handheld = 1,
OmmOperationModePolicy_Console = 2
} OmmOperationModePolicy;

/// Initialize omm.
Result ommInitialize(void);

/// Exit omm.
void ommExit(void);

/// Gets the Service for omm.
Service* ommGetServiceSession(void);

/// Returns a DefaultDisplayResolution. Only available on [3.0.0+].
Result ommGetDefaultDisplayResolution(s32* width, s32* height);

/// Returns an OmmOperationMode.
Result ommGetOperationMode(OmmOperationMode* s);

/// Takes an OmmOperationModePolicy. Only available on [3.0.0+].
Result ommSetOperationModePolicy(OmmOperationModePolicy value);
58 changes: 58 additions & 0 deletions nx/source/services/omm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include "service_guard.h"
#include "services/omm.h"
#include "runtime/hosversion.h"

static Service g_ommSrv;

NX_GENERATE_SERVICE_GUARD(omm);

Result _ommInitialize(void) {
return smGetService(&g_ommSrv, "omm");
}

void _ommCleanup(void) {
serviceClose(&g_ommSrv);
}

Service* ommGetServiceSession(void) {
return &g_ommSrv;
}

Result ommGetDefaultDisplayResolution(s32* width, s32* height) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

struct {
s32 width;
s32 height;
} out;

Result rc = serviceDispatchOut(&g_ommSrv, 11, out);

if (R_SUCCEEDED(rc)) {
*width = out.width;
*height = out.height;
}

return rc;
}

Result ommGetOperationMode(OmmOperationMode* s) {
u8 out;
Result rc = serviceDispatchOut(&g_ommSrv, 0, out);

if (R_SUCCEEDED(rc)) {
*s = out;
}

return rc;
}

Result ommSetOperationModePolicy(OmmOperationModePolicy value) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

u8 tmp = value;
return serviceDispatchIn(&g_ommSrv, 10, tmp);
}