Nabla
Nabla copied to clipboard
Steam Input API
Description
This article covers the functionality of the Steam Input API.
Overview
The Steam Input API is designed to allow you to easily enable full support for Steam Input devices (I assume that the device list hasn't been updated in a while because there is no PS5 controller listed, which is 100% supported) in your game. Let's go over some concepts of the API.
Steam Input Configurator
Steam Input Configurator (SIC) is an intermediate layer, built into the client that translates the input, passed by the input device into the output, defined by the user, depending on the SIC mode.
SIC Modes
SIC supports two modes of translation: legacy and native.
Legacy Mode
Legacy Mode is the compatability mode, designed for games that do not implement the steam input API. In this case SIC just translates one physical input into some other physical input (e.g. X key -> Alt key). This mode works on any supported input device. Legacy mode is great, but it has several drawbacks. One of them is that the game doesn't know about the existance of SIC, it just receives raw physical input, so it's hard to match up the on-screen glyphs.
Native Mode
In Native Mode, the game receives input data from the controller in the form of actions (so the game does not receive the action like "Button X was pressed, but the action "Jump""). In this case the game has no idea about what "buttons" are pressed by the controller. All the configuration is managed by the SIC. That being said, the game can also receive from the SIC the info about what key was actually triggered (this is done for the on-screen glyphs like "Press the X button).
Steam Input API
The Steam Input API (SIAPI) is the API that allows developers communicate with the SIC in Native Mode. Players can set up fully customized input mappings for any game in their library, using native mode, legacy mode, or even a mix of both. These input mappings are called "controller configurations" and a player can make many different ones for a single game, as well as share them with other players online. The API doesn't necessarily support Legacy Mode.
TL;DR
What Steam Input can do:
- Provide a game/app with an interface to get key-agnostic events for PS4, PS5, Xbox, Steam, switch etc. gamepads.
- Provide a game/app with the keys that triggered the given event, if needed.
What Steam Input cannot do:
- Work with mouse/keyboard.
- TODO
Answering some questions @devshgraphicsprogramming was curious about:
How do you get events from the gamepad:
- The way the events are retrieved is by "IsEventTriggered()" principle (not an actual call, but a very simplified version).
Is there a way to send custom events to the controler:
- TODO: I couldn't find info if there is a way to sent custom events, so this needs more research/asking people who know.
Does SteamInput syphon events on its own or do i pump them myself?
- TODO
TODO
Still need to figure some things out, but it requires a thorough search through docs, so i'll postpone it till monday.