steamutils

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package steamutils wraps miscellaneous Steam utility functions.

This package includes functions to help monitor computer state and interact with the Steam overlay and VR.

This package works with both clients and servers, but the Steam overlay and VR-related functions do not work on headless servers.

See the ISteamUtils documentation for more details. <https://partner.steamgames.com/doc/api/ISteamUtils>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentBatteryPower

func CurrentBatteryPower() uint8

CurrentBatteryPower returns the current battery power percentage from 0 to 100, or 255 if the user is on AC power.

func GamepadTextInput

func GamepadTextInput(password, multiLine bool, description string, maxLength uint32, existingText string) (string, bool)

GamepadTextInput activates the Big Picture text input dialog which only supports gamepad input.

This function will return immediately if the big picture overlay is not available. Otherwise, it waits for the user to close the text input.

If the user closes the text input by confirming it, the text they entered and true are returned.

In any other case, the value of the existingText parameter and false are returned.

Because this function blocks, the steam callback loop and your game's render loop must be called in another goroutine.

func IPCountry

func IPCountry() string

IPCountry returns the 2 digit ISO 3166-1-alpha-2 format country code which client is running in. (e.g. "US" or "UK")

This is looked up via an IP-to-location database.

func IsOverlayEnabled

func IsOverlayEnabled() bool

IsOverlayEnabled checks if the Steam Overlay is running and the user can access it.

The overlay process could take a few seconds to start and hook the game process, so this function will initially return false while the overlay is loading.

func IsSteamInBigPictureMode

func IsSteamInBigPictureMode() bool

IsSteamInBigPictureMode checks if Steam and the Steam Overlay are running in Big Picture mode.

Games must be launched through the Steam client to enable the Big Picture overlay. During development, a game can be added as a non-steam game to the developers library to test this feature.

This will always return false if your app is not the 'game' application type.

func IsSteamRunningInVR

func IsSteamRunningInVR() bool

IsSteamRunningInVR returns true if Steam itself is running in VR mode.

func IsVRHeadsetStreamingEnabled

func IsVRHeadsetStreamingEnabled() bool

IsVRHeadsetStreamingEnabled checks if the HMD view will be streamed via Steam In-Home Streaming.

func OnIPCountryChanged

func OnIPCountryChanged(f func()) steamworks.Registration

OnIPCountryChanged registers a function to be called when the user's country changes. Call IPCountry to retrieve the new country code.

func OnLowBatteryPower

func OnLowBatteryPower(f func(remaining time.Duration)) steamworks.Registration

OnLowBatteryPower registers a function to be called when the computer is running out of power.

The function is called when the computer has less than ten minutes of power remaining, and again every minute after that.

func OnSteamShutdown

func OnSteamShutdown(f func()) steamworks.Registration

OnSteamShutdown registers a function to be called when Steam wants to shut down.

func OverlayNeedsPresent

func OverlayNeedsPresent() bool

OverlayNeedsPresent checks if the Overlay needs a present. Only required if using event driven render updates.

Typically this call is unneeded if your game has a constantly running frame loop that calls the D3D Present API, or OGL SwapBuffers API every frame as is the case in most games. However, if you have a game that only refreshes the screen on an event driven basis then that can break the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also need to Present() to the screen any time a notification happens or when the overlay is brought up over the game by a user.

You can use this API to ask the overlay if it currently need a present in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you refresh the screen with Present or SwapBuffers to allow the overlay to do its work.

func RegisterDebugMessageHook

func RegisterDebugMessageHook(f func(string)) steamworks.Registration

RegisterDebugMessageHook registers a function to be called when Steam produces a debug message. This will only happen if Steam is started with -debug_steamapi.

func RegisterWarningMessageHook

func RegisterWarningMessageHook(f func(string)) steamworks.Registration

RegisterWarningMessageHook registers a function to be called when Steam produces a warning message.

func SecondsSinceAppActive

func SecondsSinceAppActive() time.Duration

SecondsSinceAppActive returns the number of seconds since the application was active.

func SecondsSinceComputerActive

func SecondsSinceComputerActive() time.Duration

SecondsSinceComputerActive returns the number of seconds since the user last moved the mouse.

func ServerRealTime

func ServerRealTime() time.Time

ServerRealTime returns the Steam server time to the nearest second.

func SetOverlayNotificationInset

func SetOverlayNotificationInset(horizontal, vertical int)

SetOverlayNotificationInset sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.

A value of (0, 0) resets the position into the corner.

This position is per-game and is reset each launch.

func SetOverlayNotificationPosition

func SetOverlayNotificationPosition(left, top bool)

SetOverlayNotificationPosition sets which corner the Steam overlay notification popup should display itself in.

You can also set the distance from the specified corner by using SetOverlayNotificationInset.

This position is per-game and is reset each launch.

func SetVRHeadsetStreamingEnabled

func SetVRHeadsetStreamingEnabled(enabled bool)

SetVRHeadsetStreamingEnabled sets whether the HMD content will be streamed via Steam In-Home Streaming.

If this is enabled, then the scene in the HMD headset will be streamed, and remote input will not be allowed. Otherwise if this is disabled, then the application window will be streamed instead, and remote input will be allowed. VR games default to enabled unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game.

This is useful for games that have asymmetric multiplayer gameplay.

func StartVRDashboard

func StartVRDashboard()

StartVRDashboard asks Steam to create and render the OpenVR dashboard.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL