-
Notifications
You must be signed in to change notification settings - Fork 15
Utilities
The Steam utility functions provide access to gamepad keyboard UI and Steam Deck getters.
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
- steam_show_floating_gamepad_text_input
- steam_dismiss_floating_gamepad_text_input
- steam_show_gamepad_text_input
- steam_get_entered_gamepad_text_input
- steam_utils_enable_callbacks
- steam_utils_is_steam_running_on_steam_deck
- steam_utils_is_steam_in_big_picture_mode
- steam_utils_set_game_launcher_mode
- steam_utils_get_server_real_time
- steam_utils_get_steam_ui_language
With this function you can show a floating gamepad keyboard window, all input is emulated as if it is a physical keyboard, so keyboard_string or keyboard_check can be used to obtain the input. This function only works in Big Picture or on the Steam Deck. Returns true
if the keyboard has been shown successfully, false
otherwise.
Warning
You must call steam_utils_enable_callbacks prior to calling this function if you wish to receive Async - Steam
gamepad keyboard events.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.
Syntax:
steam_show_floating_gamepad_text_input(mode, text_field_x, text_field_y, text_field_width, text_field_height)
Argument | Type | Description |
---|---|---|
mode | Real | A steam_floating_gamepad_text_input_mode_ constant. |
text_field_x | Real | X position of the keyboard window in display coordinates. |
text_field_y | Real | Y position of the keyboard window in display coordinates. |
text_field_width | Real | Width of the keyboard window in display coordinates. |
text_field_height | Real | Height of the keyboard window in display coordinates. |
Returns:
Triggers:
Key | Type | Description |
---|---|---|
event_type | String | A constant string "floating_gamepad_text_input_dismissed" . |
Example:
steam_utils_enable_callbacks(); // do this somewhere once.
// show the dialog:
steam_show_floating_gamepad_text_input(
steam_floating_gamepad_text_input_mode_single_line,
// in Display coordinates: use window_get_ or display_get_ functions to obtain the dimensions
window_get_x(),
window_get_y()/2,
window_get_width(),
window_get_height()/2
);
/// @description Async - Steam event
if (async_load[? "event_type"] == "floating_gamepad_text_input_dismissed") {
show_debug_message("Floating gamepad keyboard UI dialog dismissed.");
}
The above code shows a floating keyboard window in the bottom half of the window, then print a message to debug output when the dialog is dismissed.
With this function you can dismiss a floating keyboard window if it is being currently shown. Returns true
if the operation was successful, false
otherwise.
Syntax:
steam_dismiss_floating_gamepad_text_input()
Returns:
Example:
steam_dismiss_floating_gamepad_text_input();
The above code will dismiss the floating keyboard window if it is being displayed.
With this function you can show a full-screen old-style Big Picture Mode-only keyboard UI. This one does not emulate the physical keyboard so you must use the steam_get_entered_gamepad_text_input function inside a corresponding Async - Steam
event to obtain the input. Returns true
if the window is being shown successfully, false
otherwise.
Warning
You must call steam_utils_enable_callbacks prior to calling this function if you wish to receive Async - Steam
gamepad keyboard events.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.
Syntax:
steam_show_gamepad_text_input(mode, lines_mode, description, chars_max, existing_text)
Argument | Type | Description |
---|---|---|
mode | Real | A steam_gamepad_text_input_mode_ constant. |
lines_mode | Real | A steam_gamepad_text_input_line_mode_ constant. |
description | String | The description of the window. |
chars_max | Real | The maximum nupber of characters the player can enter. |
existing_text | String | Some existing text to put into the text field or an empty string. |
Returns:
Triggers:
Key | Type | Description |
---|---|---|
event_type | String | A string "gamepad_text_input_dismissed" . |
submitted | Boolean |
true if the dialog was submitted successfully and false if it was cancelled. |
submitted_text_raw_byte_length | Real | Raw length of the text in bytes. |
Example:
steam_utils_enable_callbacks(); // somewhere once.
// show the dialog:
steam_show_gamepad_text_input(
steam_gamepad_text_input_mode_normal,
steam_gamepad_text_input_line_mode_single_line,
"Some Description",
100, // up to 100 string characters
"" // no default text, can be any string, ex: "Player 1" etc
);
/// @description Async - Steam event
if (async_load[? "event_type"] == "gamepad_text_input_dismissed") {
if (async_load[? "submitted"]) {
var _input = steam_get_entered_gamepad_text_input();
show_debug_message("Old-style dialog result: " + _input);
}
}
The above code will show a modal gamepad keyboard input dialog with "Some Description"
as the description and an empty text field, then print the typed text.
With this function you can obtain the result of the steam_show_gamepad_text_input input dialog. This function must only be called in the corresponding Async - Steam
event.
Warning
You must call steam_utils_enable_callbacks prior to calling this function if you wish to receive Async - Steam
gamepad keyboard events.
Syntax:
steam_get_entered_gamepad_text_input()
Returns:
Example:
/// @description Async - Steam event
if (async_load[? "event_type"] == "gamepad_text_input_dismissed") {
if (async_load[? "submitted"]) {
var _input = steam_get_entered_gamepad_text_input();
show_debug_message("Old-style dialog result: " + _input);
}
}
The above code will activate the use of gamepad keyboard UI async events.
With this function you can activate the dispatch of Async - Steam
events for gamepad keyboard UI. Returns true
if the operation was successful and false
otherwise.
Syntax:
steam_utils_enable_callbacks()
Returns:
Example:
steam_utils_enable_callbacks();
The above code will activate the use of gamepad keyboard UI async events.
With this function you can check if your game is currently running on a Steam Deck, returns true
if yes and false
otherwise.
Syntax:
steam_utils_is_steam_running_on_steam_deck()
Returns:
Example:
if (steam_utils_is_steam_running_on_steam_deck()) {
show_debug_message("The game is running on a Steam Deck.");
}
The above code will print a message to debug output if the game is running on the Steam Deck.
This function returns if Steam is running in Big Picture mode.
Syntax:
steam_utils_is_steam_in_big_picture_mode()
Returns:
Example:
if (steam_utils_is_steam_in_big_picture_mode()) {
show_debug_message("The game is running in Big Picture mode");
}
This function can be used to set your game to "launcher mode" if your launcher is written with GameMaker.
Syntax:
steam_utils_set_game_launcher_mode(launcher_mode)
Argument | Type | Description |
---|---|---|
launcher_mode | Boolean | Whether to set the game to 'launcher mode' |
Returns:
N/A
Example:
steam_utils_set_game_launcher_mode(true);
show_debug_message("Game set to launcher mode");
This function returns the Steam server time in Unix epoch format. (Number of seconds since Jan 1, 1970 UTC)
Syntax:
steam_utils_get_server_real_time()
Returns:
Example:
show_debug_message("Current server time is " + string(steam_utils_get_server_real_time()));
This function returns the Steam language string for the language the Steam Client is running in.
Syntax:
steam_utils_get_steam_ui_language()
Returns:
Example:
show_debug_message("Current Steam UI language is " + steam_utils_get_steam_ui_language());
// "english", "russian", "japanese", etc...
This example prints the current Steam client UI language into the Debug Output
GameMaker 2024