Modules

SDL_Input_Map

moduleSource

Available on macOS, Linux, Windows, Wasm

#import "Gamepad/SDL_Input_Map";

Parses SDL game controller mapping strings, the guid,name,a:b0,leftx:a0,... lines of the SDL controller database.

parse_gamepad_mapping_string turns one line into an SDL_Gamepad_Mapping; free it with deinit.

Example↗
mapping, ok := parse_gamepad_mapping_string("030000005e040000,Pad,a:b0,leftx:a0,dpup:h0.1,platform:Mac OS X");
assert(ok && mapping.name == "Pad" && mapping.mappings.count == 3);
assert(mapping.mappings[0].target == .A && mapping.mappings[0].type == .BUTTON);
deinit(mapping);

Procedures#

(bustype: s16, vendor: s16, product: s16, version: s16) -> temp_string: string

Builds the 32-character SDL GUID for a device from its bus type, vendor, product and version. The string lives in temporary storage.

guid := get_guid_string(3, 0x45e, 0x28e, 0x110);
assert(guid.count == 32);
↗

Types#

:: enum

Whether a mapped input is a button, an axis or a hat (d-pad) direction.

UNINITIALIZED
BUTTON
AXIS
HAT
:: enum

The part of a standard controller an input is mapped onto.

UNINITIALIZED
LEFTX
RIGHTX
LEFTY
RIGHTY
LEFT_TRIGGER
RIGHT_TRIGGER
DPAD_LEFT
DPAD_RIGHT
DPAD_UP
DPAD_DOWN
BACK
GUIDE
START
LEFT_SHOULDER
RIGHT_SHOULDER
LEFT_STICK
RIGHT_STICK
A
B
X
Y

Constants#

:: #string SDL_DATABASE # Derived from the official SDL 2.0.9 native controller database. # Normalized and platform-qualified; see tools/window_render/window-rende ...

Altered data extraction: platform-qualified and sorted by device identity.