Skip to content

Commit 55de890

Browse files
skymenArmaldio
andauthored
Added gamepad input keyboard actions + ignore mouse events (#5)
* fixed DLC result * Add actions for Steam gamepad text input methods - Add ShowGamepadTextInput action with input mode, line mode, description, max characters, and existing text parameters - Add ShowFloatingGamepadTextInput action with keyboard mode, x, y, width, and height parameters - Implement both actions with proper error handling and triggers - Add conditions and expressions for both actions * readme * fixed namespace error * Apply suggestions from code review Co-authored-by: Quentin Goinaud <armaldio@gmail.com> * Added support for set ignore mouse events * added triggers --------- Co-authored-by: Quentin Goinaud <armaldio@gmail.com>
1 parent 97b174c commit 55de890

3 files changed

Lines changed: 312 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ The main files you may want to look at would be instance.js
9191
| Show dev tools | Show or hide the dev tools. | Show *(combo)* <br>Tag *(string)* <br> |
9292
| Unmaximize | Unmaximize the window | Tag *(string)* <br> |
9393
| Set Fullscreen | Change fullscreen state | Fullscreen *(combo)* <br>Tag *(string)* <br> |
94+
| Set ignore mouse events | Set whether to ignore mouse events on the window, optionally forwarding them. | Ignore *(boolean)* <br>Forward *(boolean)* <br>Tag *(string)* <br> |
9495
| Activate achievement | Activate a steam achievement | Achievement *(string)* <br>Tag *(string)* <br> |
9596
| Clear achievement | Clear a steam achievement | Achievement *(string)* <br>Tag *(string)* <br> |
9697
| Check achievement activation state | Check the activation state of a steam achievement | Achievement *(string)* <br>Tag *(string)* <br> |
@@ -110,6 +111,8 @@ When Download type is Around the user, the offsets are the amount of entries aro
110111
| Save screenshot from URL | Saves an image from a URL as a Steam screenshot. The image will be loaded, converted to base64, and its dimensions calculated automatically. | URL *(string)* <br>Tag *(string)* <br> |
111112
| Add screenshot to library | Adds an existing screenshot file to the Steam screenshot library. Returns the handle of the screenshot. | Filename *(string)* <br>Thumbnail Filename *(string)* <br>Width *(number)* <br>Height *(number)* <br>Tag *(string)* <br> |
112113
| Check DLC is installed | Checks if the user owns and has installed a specific DLC | DLC App ID *(number)* <br>Tag *(string)* <br> |
114+
| Show gamepad text input | Shows the Steam gamepad text input dialog. Returns the entered text, or null if cancelled or could not show. | Input Mode *(combo)* <br>Line Mode *(combo)* <br>Description *(string)* <br>Max Characters *(number)* <br>Existing Text *(string)* <br>Tag *(string)* <br> |
115+
| Show floating gamepad text input | Shows the Steam floating gamepad text input. Returns true if shown, otherwise false. | Keyboard Mode *(combo)* <br>X *(number)* <br>Y *(number)* <br>Width *(number)* <br>Height *(number)* <br>Tag *(string)* <br> |
113116
| Create workshop item | Creates a new workshop item for the specified Steam App ID and returns its ID | App ID *(number)* <br>Tag *(string)* <br> |
114117
| Update workshop item | Updates content and metadata of a workshop item. Use the update flags to control which fields are updated. | App ID *(number)* <br>Item ID *(string)* <br>Update Title *(boolean)* <br>Title *(string)* <br>Update Description *(boolean)* <br>Description *(string)* <br>Update Content *(boolean)* <br>Content Folder Path *(string)* <br>Change Note *(string)* <br>Update Preview *(boolean)* <br>Preview Image Path *(string)* <br>Update Tags *(boolean)* <br>Tags *(string)* <br>Update Visibility *(boolean)* <br>Visibility *(combo)* <br>Tag *(string)* <br> |
115118
| Get subscribed items with metadata | Gets all subscribed workshop items with their metadata and install info | Tag *(string)* <br> |
@@ -281,6 +284,10 @@ When Download type is Around the user, the offsets are the amount of entries aro
281284
| On any "SetFullscreen" success | Trigger when any of the "SetFullscreen" are executed with success. | |
282285
| On "SetFullscreen" error | Trigger when the "SetFullscreen" failed to execute. | Tag *(string)* <br> |
283286
| On any "SetFullscreen" error | Trigger when any of the "SetFullscreen" failed to execute. | |
287+
| On "SetIgnoreMouseEvents" success | Trigger when the "SetIgnoreMouseEvents" is executed with success. | Tag *(string)* <br> |
288+
| On any "SetIgnoreMouseEvents" success | Trigger when any of the "SetIgnoreMouseEvents" are executed with success. | |
289+
| On "SetIgnoreMouseEvents" error | Trigger when the "SetIgnoreMouseEvents" failed to execute. | Tag *(string)* <br> |
290+
| On any "SetIgnoreMouseEvents" error | Trigger when any of the "SetIgnoreMouseEvents" failed to execute. | |
284291
| On "ActivateAchievement" success | Trigger when the "ActivateAchievement" is executed with success. | Tag *(string)* <br> |
285292
| On any "ActivateAchievement" success | Trigger when any of the "ActivateAchievement" are executed with success. | |
286293
| On "ActivateAchievement" error | Trigger when the "ActivateAchievement" failed to execute. | Tag *(string)* <br> |
@@ -359,6 +366,14 @@ When Download type is Around the user, the offsets are the amount of entries aro
359366
| On any "CheckDLCIsInstalled" success | Trigger when any of the "CheckDLCIsInstalled" are executed with success. | |
360367
| On "CheckDLCIsInstalled" error | Trigger when the "CheckDLCIsInstalled" failed to execute. | Tag *(string)* <br> |
361368
| On any "CheckDLCIsInstalled" error | Trigger when any of the "CheckDLCIsInstalled" failed to execute. | |
369+
| On "ShowGamepadTextInput" success | Trigger when the "ShowGamepadTextInput" is executed with success. | Tag *(string)* <br> |
370+
| On any "ShowGamepadTextInput" success | Trigger when any of the "ShowGamepadTextInput" are executed with success. | |
371+
| On "ShowGamepadTextInput" error | Trigger when the "ShowGamepadTextInput" failed to execute. | Tag *(string)* <br> |
372+
| On any "ShowGamepadTextInput" error | Trigger when any of the "ShowGamepadTextInput" failed to execute. | |
373+
| On "ShowFloatingGamepadTextInput" success | Trigger when the "ShowFloatingGamepadTextInput" is executed with success. | Tag *(string)* <br> |
374+
| On any "ShowFloatingGamepadTextInput" success | Trigger when any of the "ShowFloatingGamepadTextInput" are executed with success. | |
375+
| On "ShowFloatingGamepadTextInput" error | Trigger when the "ShowFloatingGamepadTextInput" failed to execute. | Tag *(string)* <br> |
376+
| On any "ShowFloatingGamepadTextInput" error | Trigger when any of the "ShowFloatingGamepadTextInput" failed to execute. | |
362377
| On "CreateWorkshopItem" success | Trigger when the "CreateWorkshopItem" is executed with success. | Tag *(string)* <br> |
363378
| On any "CreateWorkshopItem" success | Trigger when any of the "CreateWorkshopItem" are executed with success. | |
364379
| On "CreateWorkshopItem" error | Trigger when the "CreateWorkshopItem" failed to execute. | Tag *(string)* <br> |
@@ -505,6 +520,8 @@ When Download type is Around the user, the offsets are the amount of entries aro
505520
| UnmaximizeResult | The result of the "Unmaximize last call" | string | |
506521
| SetFullscreenError | The error of the "SetFullscreen last call" | string | |
507522
| SetFullscreenResult | The result of the "SetFullscreen last call" | string | |
523+
| SetIgnoreMouseEventsError | The error of the "SetIgnoreMouseEvents last call" | string | |
524+
| SetIgnoreMouseEventsResult | The result of the "SetIgnoreMouseEvents last call" | string | |
508525
| ActivateAchievementError | The error of the "ActivateAchievement last call" | string | |
509526
| ActivateAchievementResult | The result of the "ActivateAchievement last call" | string | |
510527
| ClearAchievementError | The error of the "ClearAchievement last call" | string | |
@@ -539,6 +556,10 @@ When Download type is Around the user, the offsets are the amount of entries aro
539556
| AddScreenshotToLibraryResult | The result of the "AddScreenshotToLibrary last call" | string | |
540557
| CheckDLCIsInstalledError | The error of the "CheckDLCIsInstalled last call" | string | |
541558
| CheckDLCIsInstalledResult | The result of the "CheckDLCIsInstalled last call" | string | |
559+
| ShowGamepadTextInputError | The error of the "ShowGamepadTextInput last call" | string | |
560+
| ShowGamepadTextInputResult | The result of the "ShowGamepadTextInput last call" | string | |
561+
| ShowFloatingGamepadTextInputError | The error of the "ShowFloatingGamepadTextInput last call" | string | |
562+
| ShowFloatingGamepadTextInputResult | The result of the "ShowFloatingGamepadTextInput last call" | string | |
542563
| CreateWorkshopItemError | The error of the "CreateWorkshopItem last call" | string | |
543564
| CreateWorkshopItemResult | The result of the "CreateWorkshopItem last call" | string | |
544565
| UpdateWorkshopItemError | The error of the "UpdateWorkshopItem last call" | string | |

src/instance.js

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,37 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
11281128
}
11291129
})
11301130

1131+
_SetIgnoreMouseEvents = this.wrap(super._SetIgnoreMouseEvents, async (/** @type {boolean} */ ignore, /** @type {boolean} */ forward, /** @type {Tag} */ tag) => {
1132+
try {
1133+
const order = {
1134+
url: '/window/set-ignore-mouse-events',
1135+
body: {
1136+
ignore,
1137+
forward,
1138+
}
1139+
}
1140+
1141+
await this.ws?.sendAndWaitForResponse(order)
1142+
1143+
this._SetIgnoreMouseEventsResultValue = true
1144+
this._SetIgnoreMouseEventsErrorValue = ''
1145+
await this.trigger(tag, [
1146+
C3.Plugins.pipelabv2.Cnds.OnSetIgnoreMouseEventsSuccess,
1147+
C3.Plugins.pipelabv2.Cnds.OnAnySetIgnoreMouseEventsSuccess,
1148+
])
1149+
} catch (e) {
1150+
if (e instanceof Error) {
1151+
this._SetIgnoreMouseEventsErrorValue = e.message
1152+
this._SetIgnoreMouseEventsResultValue = false
1153+
await this.trigger(tag, [
1154+
C3.Plugins.pipelabv2.Cnds.OnSetIgnoreMouseEventsError,
1155+
C3.Plugins.pipelabv2.Cnds.OnAnySetIgnoreMouseEventsError,
1156+
])
1157+
}
1158+
console.error(e)
1159+
}
1160+
}, this.unsupportedEngine)
1161+
11311162
_Unmaximize = this.wrap(super._Unmaximize, async () => {
11321163
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowUnmaximize, 'input'>} */
11331164
const order = {
@@ -2614,6 +2645,89 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
26142645
}
26152646
}, this.unsupportedEngine)
26162647

2648+
// Steam Gamepad Text Input
2649+
_ShowGamepadTextInput = this.wrap(super._ShowGamepadTextInput, async (
2650+
/** @type {number} */ inputMode,
2651+
/** @type {number} */ inputLineMode,
2652+
/** @type {string} */ description,
2653+
/** @type {number} */ maxCharacters,
2654+
/** @type {string} */ existingText,
2655+
/** @type {Tag} */ tag
2656+
) => {
2657+
try {
2658+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'input', 'showGamepadTextInput'>, 'input'>} */
2659+
const order = {
2660+
url: '/steam/raw',
2661+
body: {
2662+
namespace: 'utils',
2663+
method: 'showGamepadTextInput',
2664+
args: [inputMode, inputLineMode, description, maxCharacters, existingText || undefined],
2665+
},
2666+
};
2667+
const answer = await this.ws?.sendAndWaitForResponse(order);
2668+
if (answer?.body.success === false) {
2669+
throw new Error('Failed')
2670+
}
2671+
this._ShowGamepadTextInputResultValue = answer?.body.data ?? null
2672+
this._ShowGamepadTextInputErrorValue = ''
2673+
2674+
await this.trigger(tag, [
2675+
C3.Plugins.pipelabv2.Cnds.OnShowGamepadTextInputSuccess,
2676+
C3.Plugins.pipelabv2.Cnds.OnAnyShowGamepadTextInputSuccess
2677+
])
2678+
} catch (e) {
2679+
if (e instanceof Error) {
2680+
this._ShowGamepadTextInputErrorValue = e.message
2681+
this._ShowGamepadTextInputResultValue = null
2682+
await this.trigger(tag, [
2683+
C3.Plugins.pipelabv2.Cnds.OnShowGamepadTextInputError,
2684+
C3.Plugins.pipelabv2.Cnds.OnAnyShowGamepadTextInputError
2685+
])
2686+
}
2687+
}
2688+
}, this.unsupportedEngine)
2689+
2690+
_ShowFloatingGamepadTextInput = this.wrap(super._ShowFloatingGamepadTextInput, async (
2691+
/** @type {number} */ keyboardMode,
2692+
/** @type {number} */ x,
2693+
/** @type {number} */ y,
2694+
/** @type {number} */ width,
2695+
/** @type {number} */ height,
2696+
/** @type {Tag} */ tag
2697+
) => {
2698+
try {
2699+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'input', 'showFloatingGamepadTextInput'>, 'input'>} */
2700+
const order = {
2701+
url: '/steam/raw',
2702+
body: {
2703+
namespace: 'utils',
2704+
method: 'showFloatingGamepadTextInput',
2705+
args: [keyboardMode, x, y, width, height],
2706+
},
2707+
};
2708+
const answer = await this.ws?.sendAndWaitForResponse(order);
2709+
if (answer?.body.success === false) {
2710+
throw new Error('Failed')
2711+
}
2712+
this._ShowFloatingGamepadTextInputResultValue = answer?.body.data ? 1 : 0
2713+
this._ShowFloatingGamepadTextInputErrorValue = ''
2714+
2715+
await this.trigger(tag, [
2716+
C3.Plugins.pipelabv2.Cnds.OnShowFloatingGamepadTextInputSuccess,
2717+
C3.Plugins.pipelabv2.Cnds.OnAnyShowFloatingGamepadTextInputSuccess
2718+
])
2719+
} catch (e) {
2720+
if (e instanceof Error) {
2721+
this._ShowFloatingGamepadTextInputErrorValue = e.message
2722+
this._ShowFloatingGamepadTextInputResultValue = 0
2723+
await this.trigger(tag, [
2724+
C3.Plugins.pipelabv2.Cnds.OnShowFloatingGamepadTextInputError,
2725+
C3.Plugins.pipelabv2.Cnds.OnAnyShowFloatingGamepadTextInputError
2726+
])
2727+
}
2728+
}
2729+
}, this.unsupportedEngine)
2730+
26172731
// Steam Workshop
26182732
/** @type {Map<string, any>} */
26192733
_workshopItemsMap = new Map()
@@ -3732,6 +3846,15 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
37323846
return true
37333847
})
37343848

3849+
_OnSetIgnoreMouseEventsSuccess = this.wrap(super._OnSetIgnoreMouseEventsSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
3850+
_OnAnySetIgnoreMouseEventsSuccess = this.wrap(super._OnAnySetIgnoreMouseEventsSuccess, () => {
3851+
return true
3852+
})
3853+
_OnSetIgnoreMouseEventsError = this.wrap(super._OnSetIgnoreMouseEventsError, (/** @type {Tag} */ tag) => this._currentTag === tag)
3854+
_OnAnySetIgnoreMouseEventsError = this.wrap(super._OnAnySetIgnoreMouseEventsError, () => {
3855+
return true
3856+
})
3857+
37353858
_OnActivateAchievementSuccess = this.wrap(super._OnActivateAchievementSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
37363859
_OnAnyActivateAchievementSuccess = this.wrap(super._OnAnyActivateAchievementSuccess, () => true)
37373860
_OnActivateAchievementError = this.wrap(super._OnActivateAchievementError, (/** @type {Tag} */ tag) => this._currentTag === tag)
@@ -3851,6 +3974,16 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
38513974
_OnGetFriendNameError = this.wrap(super._OnGetFriendNameError, (/** @type {Tag} */ tag) => this._currentTag === tag)
38523975
_OnAnyGetFriendNameError = this.wrap(super._OnAnyGetFriendNameError, () => true)
38533976

3977+
_OnShowGamepadTextInputSuccess = this.wrap(super._OnShowGamepadTextInputSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
3978+
_OnAnyShowGamepadTextInputSuccess = this.wrap(super._OnAnyShowGamepadTextInputSuccess, () => true)
3979+
_OnShowGamepadTextInputError = this.wrap(super._OnShowGamepadTextInputError, (/** @type {Tag} */ tag) => this._currentTag === tag)
3980+
_OnAnyShowGamepadTextInputError = this.wrap(super._OnAnyShowGamepadTextInputError, () => true)
3981+
3982+
_OnShowFloatingGamepadTextInputSuccess = this.wrap(super._OnShowFloatingGamepadTextInputSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
3983+
_OnAnyShowFloatingGamepadTextInputSuccess = this.wrap(super._OnAnyShowFloatingGamepadTextInputSuccess, () => true)
3984+
_OnShowFloatingGamepadTextInputError = this.wrap(super._OnShowFloatingGamepadTextInputError, (/** @type {Tag} */ tag) => this._currentTag === tag)
3985+
_OnAnyShowFloatingGamepadTextInputError = this.wrap(super._OnAnyShowFloatingGamepadTextInputError, () => true)
3986+
38543987
_OnCreateWorkshopItemSuccess = this.wrap(super._OnCreateWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
38553988
_OnAnyCreateWorkshopItemSuccess = this.wrap(super._OnAnyCreateWorkshopItemSuccess, () => true)
38563989
_OnCreateWorkshopItemError = this.wrap(super._OnCreateWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag)
@@ -4378,6 +4511,12 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
43784511
_SetFullscreenResult = this.exprs(super._SetFullscreenResult, () => {
43794512
return this._SetFullscreenResultValue
43804513
})
4514+
_SetIgnoreMouseEventsError = this.exprs(super._SetIgnoreMouseEventsError, () => {
4515+
return this._SetIgnoreMouseEventsErrorValue
4516+
})
4517+
_SetIgnoreMouseEventsResult = this.exprs(super._SetIgnoreMouseEventsResult, () => {
4518+
return this._SetIgnoreMouseEventsResultValue
4519+
})
43814520
_ActivateAchievementError = this.exprs(super._ActivateAchievementError, () => {
43824521
return this._ActivateAchievementErrorValue
43834522
})
@@ -4507,6 +4646,20 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
45074646
return this._GetFriendNameResultValue
45084647
})
45094648

4649+
_ShowGamepadTextInputError = this.exprs(super._ShowGamepadTextInputError, () => {
4650+
return this._ShowGamepadTextInputErrorValue
4651+
})
4652+
_ShowGamepadTextInputResult = this.exprs(super._ShowGamepadTextInputResult, () => {
4653+
return this._ShowGamepadTextInputResultValue ?? ''
4654+
})
4655+
4656+
_ShowFloatingGamepadTextInputError = this.exprs(super._ShowFloatingGamepadTextInputError, () => {
4657+
return this._ShowFloatingGamepadTextInputErrorValue
4658+
})
4659+
_ShowFloatingGamepadTextInputResult = this.exprs(super._ShowFloatingGamepadTextInputResult, () => {
4660+
return this._ShowFloatingGamepadTextInputResultValue ?? 0
4661+
})
4662+
45104663
// Workshop expressions
45114664
_CreateWorkshopItemError = this.exprs(super._CreateWorkshopItemError, () => {
45124665
return this._CreateWorkshopItemErrorValue

0 commit comments

Comments
 (0)