Skip to content

Commit 47cb5c6

Browse files
committed
add IsRunningOnSteamDeck
1 parent d28e024 commit 47cb5c6

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A plugin that integrate with Pipelab <br>
55
Author: Armaldio <br>
66
Website: https://github.com/CynToolkit/construct-plugin <br>
77
Addon Url: https://github.com/CynToolkit/construct-plugin <br>
8-
Download Latest Version : [Version: 2.1.0](https://github.com/CynToolkit/construct-plugin/releases/latest) <br>
8+
Download Latest Version : [Version: 2.1.1](https://github.com/CynToolkit/construct-plugin/releases/latest) <br>
99
<sub>Made using [c3ide2-framework](https://github.com/ConstructFund/c3ide2-framework) </sub><br>
1010

1111
## Table of Contents
@@ -451,6 +451,7 @@ The main files you may want to look at would be instance.js
451451
| SteamUsername | Get the Steam username. | string | |
452452
| SteamLevel | Get the Steam level. | number | |
453453
| SteamIpCountry | Get the Steam IP country. | string | |
454+
| SteamIsRunningOnSteamDeck | Return true if the app is running on a Steam Deck. | number | |
454455

455456
## Paths
456457
**ProjectFilesFolder**: Direct path to your games's content

examples/example.c3p

678 Bytes
Binary file not shown.

src/instance.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export const fullscreenPipelabStateToC3State = (/** @type {import('@pipelab/core
209209
const defaultSteamId = {
210210
accountId: -1,
211211
steamId32: '',
212-
steamId64: BigInt(-1),
212+
steamId64: '',
213213
}
214214

215215
/**
@@ -319,14 +319,16 @@ export function getInstanceJs(parentClass, addonTriggers, C3) {
319319
/** @type {import("./sdk.js").IsFullScreenState} */
320320
_fullscreenState = 0;
321321

322-
/** @type {import('@pipelab/core').NamespacedFunctionReturnType<'localplayer', 'getSteamId'>} */
322+
/** @type {{accountId: number, steamId32: string, steamId64: string}} */
323323
_steam_SteamId = defaultSteamId
324324
/** @type {import('@pipelab/core').NamespacedFunctionReturnType<'localplayer', 'getName'>} */
325325
_steam_Name = ""
326326
/** @type {import('@pipelab/core').NamespacedFunctionReturnType<'localplayer', 'getLevel'>} */
327327
_steam_Level = -1
328328
/** @type {import('@pipelab/core').NamespacedFunctionReturnType<'localplayer', 'getIpCountry'>} */
329329
_steam_IpCountry = ''
330+
/** @type {import('@pipelab/core').NamespacedFunctionReturnType<'utils', 'isSteamRunningOnSteamDeck'>} */
331+
_steam_IsRunningOnSteamDeck = false
330332

331333
/** @type {string} */
332334
_platform = ''
@@ -522,19 +524,19 @@ export function getInstanceJs(parentClass, addonTriggers, C3) {
522524
}
523525

524526
// TODO: BigInt support
525-
// promises.push(async () => {
526-
// /** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'localplayer', 'getSteamId'>, 'input'>} */
527-
// const order = {
528-
// url: '/steam/raw',
529-
// body: {
530-
// namespace: 'localplayer',
531-
// method: 'getSteamId',
532-
// args: [],
533-
// },
534-
// };
535-
// const response = await this.ws?.sendAndWaitForResponse(order);
536-
// this._steam_SteamId = response?.body.data ?? defaultSteamId
537-
// })
527+
promises.push(async () => {
528+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'localplayer', 'getSteamId'>, 'input'>} */
529+
const order = {
530+
url: '/steam/raw',
531+
body: {
532+
namespace: 'localplayer',
533+
method: 'getSteamId',
534+
args: [],
535+
},
536+
};
537+
const response = await this.ws?.sendAndWaitForResponse(order);
538+
this._steam_SteamId = response?.body.data ?? defaultSteamId
539+
})
538540

539541
promises.push(async () => {
540542
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'localplayer', 'getName'>, 'input'>} */
@@ -580,6 +582,20 @@ export function getInstanceJs(parentClass, addonTriggers, C3) {
580582
this._steam_IpCountry = response?.body.data ?? '';
581583
})
582584

585+
promises.push(async () => {
586+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'utils', 'isSteamRunningOnSteamDeck'>, 'input'>} */
587+
const order = {
588+
url: '/steam/raw',
589+
body: {
590+
namespace: 'utils',
591+
method: 'isSteamRunningOnSteamDeck',
592+
args: [],
593+
},
594+
};
595+
const response = await this.ws?.sendAndWaitForResponse(order);
596+
this._steam_IsRunningOnSteamDeck = response?.body.data ?? false;
597+
})
598+
583599
promises.push(async () => {
584600
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageInfos, 'input'>} */
585601
const order = {
@@ -2417,6 +2433,9 @@ export function getInstanceJs(parentClass, addonTriggers, C3) {
24172433
_SteamIpCountry = this.exprs(super._SteamIpCountry, () => {
24182434
return this._steam_IpCountry
24192435
})
2436+
_SteamIsRunningOnSteamDeck = this.exprs(super._SteamIsRunningOnSteamDeck, () => {
2437+
return this._steam_IsRunningOnSteamDeck ? 1 : 0
2438+
})
24202439

24212440
_InitializeError = this.exprs(super._InitializeError, () => {
24222441
return this._InitializeErrorValue

src/pluginConfig.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,6 @@ const Config = /** @type {const} */({
16661666
description: "Return the fullscreen state of the window.",
16671667
},
16681668

1669-
// Steam
16701669
CurrentPlatform: {
16711670
category: "general",
16721671
forward: "_CurrentPlatform",
@@ -1683,6 +1682,7 @@ const Config = /** @type {const} */({
16831682
returnType: 'string',
16841683
description: "Get the current architecture (e.g., 'x64', 'arm64').",
16851684
},
1685+
// Steam
16861686
SteamAccountId: {
16871687
category: "steam",
16881688
forward: "_SteamAccountId",
@@ -1731,6 +1731,14 @@ const Config = /** @type {const} */({
17311731
returnType: 'string',
17321732
description: "Get the Steam IP country.",
17331733
},
1734+
SteamIsRunningOnSteamDeck: {
1735+
category: "steam",
1736+
forward: "_SteamIsRunningOnSteamDeck",
1737+
highlight: false,
1738+
deprecated: false,
1739+
returnType: 'number',
1740+
description: "Return true if the app is running on a Steam Deck.",
1741+
},
17341742
},
17351743
});
17361744

0 commit comments

Comments
 (0)