Skip to content

Commit

Permalink
Add Switch.operationMode()
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Mar 23, 2024
1 parent ed21758 commit 696580c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-penguins-tie.md
@@ -0,0 +1,5 @@
---
"nxjs-runtime": patch
---

Add `Switch.operationMode()`
21 changes: 21 additions & 0 deletions packages/runtime/src/switch.ts
Expand Up @@ -259,6 +259,27 @@ export function appletType(): number {
return $.appletGetAppletType();
}

/**
* Returns the current "operation mode" of the device.
*
* This can be used to identify if the device is handheld or docked.
*
* @example
*
* ```typescript
* import { OperationMode } from '@nx.js/constants';
*
* if (Switch.operationMode() === OperationMode.Handheld) {
* console.log('Device is currently handheld');
* } else {
* console.log('Device is currently docked');
* }
* ```
*/
export function operationMode(): number {
return $.appletGetOperationMode();
}

/**
* Set media playback state.
*
Expand Down

0 comments on commit 696580c

Please sign in to comment.