mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-25 18:48:51 -04:00
Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
91
host/steam_pads.h
Normal file
91
host/steam_pads.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* (Triforce, 11-24) Valve's own controllers under Steam, and the motion sensors behind Steam Input's stand-in pads
|
||||
(host/pad_sdl.c).
|
||||
|
||||
Started from Steam, the game gets SDL_GAMECONTROLLER_IGNORE_DEVICES, which lists Valve's controllers (the Steam
|
||||
Controller, the Steam Deck's) and others Steam reads itself, and SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD=1.
|
||||
SDL then opens only Steam Input's stand-in pad, which has no gyroscope or accelerometer, so Motion controls found no
|
||||
pad (a Steam Controller on CachyOS, and on Windows). Valve's entries come out of that list, so SDL opens the real pad
|
||||
as well, all but the Steam Deck's built-in controls (STEAM_PADS_DECK): SDL's Steam Deck driver resets their trackpad
|
||||
and button settings as it opens them, which is not yet tested beside Steam Input in Game Mode, so they stay as Steam
|
||||
set them. While a Steam stand-in pad is open, a real Valve pad gives its motion only: its buttons and sticks come
|
||||
through the stand-in pad, as the player's Steam layout maps them, and are not counted twice.
|
||||
|
||||
The Steam Deck's built-in controls opened as a pad of their own (Desktop Mode, the game started outside Steam) also
|
||||
show the system a mouse, whose buttons Steam's Desktop layout presses for the triggers: steam_pads_deck_builtin.
|
||||
|
||||
Nothing here applies to a player without Steam Input or a Steam Deck. Each rule asks for something only they have:
|
||||
Steam's two variables in the environment (steam_pads_from_steam), a pad with a Steam Input handle open
|
||||
(steam_pads_motion_only), or the Deck's own USB id on an open pad (steam_pads_deck_builtin). An SDL without the
|
||||
calls that tell these apart answers vendor 0, product 0 and handle 0, which no rule takes. HOS_STEAM_PADS=0 turns
|
||||
all three off (steam_pads_off): the list as Steam set it, every open pad's buttons counted, the mouse as before.
|
||||
|
||||
Pure (no state, no SDL): tests/test_steam_pads.py compiles it. */
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define STEAM_PADS_VALVE 0x28de
|
||||
#define STEAM_PADS_DECK 0x1205 /* (the Steam Deck's built-in controls: kept in the list) */
|
||||
|
||||
/* HOS_STEAM_PADS's value turns the rules off: 0, off, no, false. Not set (NULL), or anything else: on */
|
||||
static inline int steam_pads_off(const char *v) {
|
||||
return v && (!strcmp(v, "0") || !strcmp(v, "off") || !strcmp(v, "no") || !strcmp(v, "false"));
|
||||
}
|
||||
|
||||
/* Whether the environment is the one Steam gives a game it starts with Steam Input: its controller ignore list
|
||||
(ignore: SDL_GAMECONTROLLER_IGNORE_DEVICES) not empty, and its stand-in pads let through (virtual_pad:
|
||||
SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD, set and not 0). A list a player set by hand, without the second, is
|
||||
theirs and is left alone */
|
||||
static inline int steam_pads_from_steam(const char *ignore, const char *virtual_pad) {
|
||||
return ignore && *ignore && virtual_pad && *virtual_pad && strcmp(virtual_pad, "0") != 0;
|
||||
}
|
||||
|
||||
/* SDL's ignore list (0xVVVV/0xPPPP entries split by commas) without Valve's entries but the Steam Deck's, into out (cap
|
||||
bytes, always ended). Returns how many entries came out, or -1 when out is left empty and the list should stay as it
|
||||
is: a list SDL reads from a file (@path), or one too long for out. */
|
||||
static inline int steam_pads_without_valve(const char *in, char *out, size_t cap) {
|
||||
if (!cap) return -1;
|
||||
out[0] = 0;
|
||||
if (!in) return 0;
|
||||
while (*in == ' ' || *in == '\t') in++;
|
||||
if (*in == '@') return -1;
|
||||
size_t n = 0;
|
||||
int dropped = 0;
|
||||
for (const char *p = in; *p;) {
|
||||
const char *end = strchr(p, ',');
|
||||
const size_t len = end ? (size_t)(end - p) : strlen(p);
|
||||
char *after;
|
||||
const unsigned long vendor = strtoul(p, &after, 16); /* (16 takes the 0x too) */
|
||||
const unsigned long product = after < p + len && *after == '/' ? strtoul(after + 1, NULL, 16) : 0;
|
||||
if (after != p && after <= p + len && vendor == STEAM_PADS_VALVE && product != STEAM_PADS_DECK) {
|
||||
dropped++;
|
||||
} else if (len) {
|
||||
if (n + (n ? 1 : 0) + len + 1 > cap) {
|
||||
out[0] = 0;
|
||||
return -1;
|
||||
}
|
||||
if (n) out[n++] = ',';
|
||||
memcpy(out + n, p, len);
|
||||
n += len;
|
||||
out[n] = 0;
|
||||
}
|
||||
p += len;
|
||||
if (*p == ',') p++;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
|
||||
/* Whether a pad is the Steam Deck's built-in controls: Valve's, the Deck's product id, and no Steam Input handle (a
|
||||
stand-in pad's). Its buttons are then the controls' own, so the mouse interface those controls also expose must not
|
||||
count as gameplay input: in the Deck's desktop layout R2 arrives there as a left click, and the pad's own buttons
|
||||
already carry that action. Known and sampled once a poll, not on connection (host/pad_sdl.c). */
|
||||
static inline int steam_pads_deck_builtin(unsigned vendor, unsigned product, unsigned long long steam_handle) {
|
||||
return vendor == STEAM_PADS_VALVE && product == STEAM_PADS_DECK && !steam_handle;
|
||||
}
|
||||
|
||||
/* Whether a pad gives its motion only: a real Valve pad (vendor 0x28de and no Steam Input handle) while a Steam
|
||||
stand-in pad (one with a handle) is open */
|
||||
static inline int steam_pads_motion_only(unsigned vendor, unsigned long long steam_handle, int stand_in_open) {
|
||||
return vendor == STEAM_PADS_VALVE && !steam_handle && stand_in_open;
|
||||
}
|
||||
Reference in New Issue
Block a user