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:
437
host/pad_sdl.c
437
host/pad_sdl.c
@@ -21,14 +21,19 @@
|
||||
#include <windows.h>
|
||||
#include "hos_sdl.h"
|
||||
#include "hd_rumble.h"
|
||||
#include "vibration.h" /* ((Triforce) what plays each pad's vibration) */
|
||||
#include "rumble_renhdrum.h" /* ((Triforce) RenHDrum's backends, when renhdrum.dll is beside the game) */
|
||||
#include "pad_speaker.h" /* ((Triforce) the game's sounds on a DualSense's own speaker) */
|
||||
#include "hos_motion.h"
|
||||
#include "steam_pads.h"
|
||||
#include "../gpu/vk/vk_api.h" /* (HOS_PAD_*) */
|
||||
|
||||
void hos_host_thread_register_self(const char *name); /* hos_prof.c */
|
||||
|
||||
/* (BTN_A ... BTN_RIGHT are HOS_PAD_SOUTH ... HOS_PAD_RIGHT) */
|
||||
enum { BTN_A, BTN_B, BTN_X, BTN_Y, BTN_BACK, BTN_GUIDE, BTN_START, BTN_LSTICK, BTN_RSTICK, BTN_LSHOULDER, BTN_RSHOULDER,
|
||||
BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_MISC1, BTN_N = 21 };
|
||||
BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_MISC1, BTN_RPADDLE1, BTN_LPADDLE1, BTN_RPADDLE2, BTN_LPADDLE2,
|
||||
BTN_TOUCHPAD = 20, BTN_N = 21 };
|
||||
enum { AX_LX, AX_LY, AX_RX, AX_RY, AX_LT, AX_RT };
|
||||
|
||||
#define MAX_PADS 8
|
||||
@@ -46,25 +51,46 @@ static struct {
|
||||
uint8_t trigger_said;
|
||||
int64_t trigger_ns, trigger_retry_ns;
|
||||
uint8_t hd, hd_kind, hd_ever; /* HD rumble (hd_rumble.h): HD_RUMBLE_UNKNOWN / ON / OFF, the pad's kind, sent once */
|
||||
/* ((Triforce) what plays its vibration (host/vibration.h: -1 not chosen yet), the kind of pad and its transport for
|
||||
that; a backend that would not open, and when to try it again; an Xbox pad's four motors as last sent (RenHDrum) */
|
||||
int8_t vib, vib_kind, wireless, vib_failed;
|
||||
int64_t vib_retry_ns, four_ns;
|
||||
uint16_t four[4];
|
||||
uint16_t vib_product; /* (its USB product id whatever HOS_STEAM_PADS says: a Steam Controller (2026) on its cable) */
|
||||
int usb_token; /* (a DualSense's four-channel sound card at the last look, or -1) */
|
||||
int64_t usb_next_look;
|
||||
uint8_t hd_sent[HD_RUMBLE_PACKET_SIZE];
|
||||
int64_t hd_ns;
|
||||
int motion, motion_on;
|
||||
int64_t motion_retry_ns, used_ns;
|
||||
int64_t opened_ns; /* (Triforce) when SDL opened it, for the log's line when it goes */
|
||||
uint64_t input_sig;
|
||||
unsigned rested; /* (hookshot) the sticks' axes seen at rest since it was opened, a bit each: only those steer */
|
||||
unsigned rested; /* (hookshot) the sticks' axes seen at rest since it was opened, a bit each (AX_LX ... AX_RY):
|
||||
only those steer; (Triforce) and its triggers seen let go (AX_LT, AX_RT): only those press */
|
||||
signed char held[4]; /* (the way each axis was last held, -1, 0 or 1: one held the other way has passed its rest) */
|
||||
int64_t trig_held_ns[2]; /* (Triforce) since when each trigger has read held, and let go, without a break (0: not */
|
||||
int64_t trig_rest_ns[2]; /* now), and what the log said of them (trigger_pull) */
|
||||
uint8_t trig_said;
|
||||
uint32_t serial;
|
||||
float bias[3], bias_t;
|
||||
int has_bias;
|
||||
/* ((Triforce) 11-24, host/steam_pads.h) its USB vendor and product, and its Steam Input handle: not 0 for a Steam
|
||||
stand-in pad; motion_only: a real Valve pad while a Steam stand-in pad is open, its motion read and no input */
|
||||
uint16_t vendor, product;
|
||||
uint64_t steam;
|
||||
int motion_only;
|
||||
} pads[MAX_PADS];
|
||||
static uint32_t pads_opened;
|
||||
static SRWLOCK state_lock = SRWLOCK_INIT;
|
||||
static uint64_t state_buttons;
|
||||
static int32_t state_stick[4];
|
||||
static int state_count;
|
||||
static int state_deck_builtin; /* ((Triforce) 11-24) the Steam Deck's built-in controls gave the input of that poll */
|
||||
static char state_name[128]; /* the first controller's name (host/prompts.c: the button prompts' Auto) */
|
||||
static char state_last_name[128]; /* ((Triforce) the name of the open controller used last (used_ns), "" none */
|
||||
/* ((Triforce) and their SDL types (the loaded SDL's own numbers, 0 unknown or none), for Auto's face where a name says no
|
||||
maker's buttons: host/prompts.c face_of_type */
|
||||
static int state_type, state_last_type;
|
||||
/* ((Triforce, 11-19) the scans for controllers done (pads_poll), for Auto's wait at the game's start (host/prompts.c
|
||||
choose_face): -1 when SDL will not run (HOS_NO_SDL, no SDL, or it would not start), 0 while it is starting */
|
||||
static volatile LONG scans;
|
||||
@@ -89,6 +115,20 @@ int32_t hos_stick_axis(int16_t v, int zone); /* nn_hid.c: the menu's Stick dea
|
||||
or at the menu's Stick dead zone when its stick has none) */
|
||||
int hos_stick_own(int stick);
|
||||
int32_t hos_stick_axis_own(int16_t v, int zone, int own);
|
||||
/* ((Triforce) nn_hid.c: a stick cut at its dead zone as a pair, both axes kept outside the zone's circle) */
|
||||
void hos_filter_stick(int16_t x, int16_t y, int zone, int own, int32_t out[2]);
|
||||
|
||||
/* ((Triforce) 11-24) host/steam_pads.h's rules, on unless HOS_STEAM_PADS=0 (off, no, false): read once */
|
||||
static int steam_rules(void) {
|
||||
static volatile LONG on = -1;
|
||||
if (on < 0) {
|
||||
const int now = !steam_pads_off(getenv("HOS_STEAM_PADS"));
|
||||
if (InterlockedCompareExchange(&on, now, -1) == -1 && !now)
|
||||
hos_log("hid: Steam's controllers as before (HOS_STEAM_PADS=0): its ignore list kept, every open pad's "
|
||||
"buttons counted, the mouse beside a Steam Deck's own controls");
|
||||
}
|
||||
return on > 0;
|
||||
}
|
||||
|
||||
static int32_t stick_value(int16_t v, int flip, int zone, int own) {
|
||||
const int32_t a = hos_stick_axis_own(v, zone, own);
|
||||
@@ -129,6 +169,20 @@ static int pads_start(void) {
|
||||
/* (with no window nothing reads SDL's quit event: SDL's own SIGINT/SIGTERM handlers turned a timeout's or a service
|
||||
manager's SIGTERM into that event, and the run went on until SIGKILL. Without them the signals end it as usual) */
|
||||
if (getenv("HOS_HEADLESS")) hos_sdl_hint("SDL_NO_SIGNAL_HANDLERS", "1");
|
||||
/* ((Triforce) 11-24) Valve's own pads taken out of the ignore list Steam sets for the games it starts, so that their
|
||||
motion sensors are read (host/steam_pads.h). Only in Steam's own environment (its list and its stand-in pads'
|
||||
variable, both), and only with an SDL that tells Steam's stand-in pads apart: without that, a real pad and its
|
||||
stand-in would both play. A list emptied or unset in Steam's launch options is left as it is, as is every
|
||||
environment Steam did not make */
|
||||
{
|
||||
const char *list = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
char kept[4096];
|
||||
if (steam_rules() && steam_pads_from_steam(list, getenv("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD")) &&
|
||||
hos_sdl_knows_steam_pads() && steam_pads_without_valve(list, kept, sizeof kept) > 0 &&
|
||||
hos_sdl_hint_override("SDL_GAMECONTROLLER_IGNORE_DEVICES", kept))
|
||||
hos_log("hid: Valve's controllers (not the Steam Deck's) taken out of Steam's ignore list, for their motion "
|
||||
"sensors (HOS_STEAM_PADS=0: the list as Steam set it)");
|
||||
}
|
||||
if (!hos_sdl_init(HOS_SDL_GAMEPAD)) {
|
||||
hos_log("hid: SDL could not start its controller support: %s", hos_sdl_error());
|
||||
InterlockedExchange(&scans, -1);
|
||||
@@ -250,6 +304,114 @@ static int hd_poll(int i, const uint8_t side[3][4], long long now) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---- (Triforce) what plays each pad's vibration (host/vibration.h); RenHDrum's backends are host/rumble_renhdrum.c.
|
||||
Without renhdrum.dll (renhdrum.so) beside the game, Auto is what every pad had before: a Switch pad's own HD rumble,
|
||||
every other pad's motors (with Trigger vibration and Vibration curve as before) ---- */
|
||||
static int vib_force = -1; /* HOS_RUMBLE_BACKEND, read once */
|
||||
/* RenHDrum for a pad of this kind: loaded (once) only for a pad it would play */
|
||||
static int vib_rh_for(int kind) {
|
||||
if (vib_force == VIB_FORCE_HD || vib_force == VIB_FORCE_MOTORS || kind == VIB_PAD_OTHER) return 0;
|
||||
return rh_load();
|
||||
}
|
||||
/* what played pad i lets go of it, and its motors are stopped (whatever plays next sends what is playing) */
|
||||
static void vib_leave(int i, int64_t now) {
|
||||
(void)now;
|
||||
void *gc = pads[i].gc;
|
||||
switch (pads[i].vib) {
|
||||
case VIB_RH_DS_USB: rh_usb_close(); break;
|
||||
case VIB_RH_DS_BT: rh_bt_close(); break;
|
||||
case VIB_RH_XBOX:
|
||||
rh_pad_close(gc);
|
||||
hos_sdl_pad_rumble_triggers(gc, 0, 0, 0);
|
||||
break;
|
||||
case VIB_RH_SWITCH: rh_pad_close(gc); break;
|
||||
case VIB_RH_STEAM: rh_steam_close(); break;
|
||||
default: break;
|
||||
}
|
||||
if (pads[i].vib >= 0) hos_sdl_pad_rumble(gc, 0, 0, 0);
|
||||
if (pads[i].trigger) hos_sdl_pad_rumble_triggers(gc, 0, 0, 0); /* (Trigger vibration's, playing: stopped too) */
|
||||
pads[i].trigger = 0, pads[i].trigger_ns = 0;
|
||||
pads[i].rumble_lo = pads[i].rumble_hi = 0, pads[i].rumble_ns = 0;
|
||||
pads[i].hd_ever = 0;
|
||||
memset(pads[i].four, 0, sizeof pads[i].four), pads[i].four_ns = 0;
|
||||
pads[i].vib = -1;
|
||||
}
|
||||
static void vib_choose(int i, int mode, int64_t now) {
|
||||
void *gc = pads[i].gc;
|
||||
const int kind = pads[i].vib_kind;
|
||||
/* (one that stopped playing: let go, and chosen again below) */
|
||||
if (pads[i].vib == VIB_RH_DS_USB && !rh_usb_alive()) {
|
||||
hos_log("vibration: the DualSense's sound card went away: its motors until it is back");
|
||||
vib_leave(i, now);
|
||||
pads[i].usb_token = -1, pads[i].usb_next_look = now + 2000000000LL;
|
||||
} else if (pads[i].vib == VIB_RH_DS_BT && !rh_bt_alive()) {
|
||||
vib_leave(i, now);
|
||||
pads[i].vib_failed = VIB_RH_DS_BT, pads[i].vib_retry_ns = now + 30000000000LL;
|
||||
} else if (pads[i].vib == VIB_RH_STEAM && !rh_steam_alive()) {
|
||||
vib_leave(i, now);
|
||||
pads[i].vib_failed = VIB_RH_STEAM, pads[i].vib_retry_ns = now + 30000000000LL;
|
||||
}
|
||||
const int rh = vib_rh_for(kind);
|
||||
int ds_usb = 0, ds_hid = 0;
|
||||
if (rh && kind == VIB_PAD_DUALSENSE && mode == VIB_MODE_AUTO) {
|
||||
void *owner = rh_usb_owner();
|
||||
if (owner == gc) ds_usb = 1;
|
||||
else if (!owner && pads[i].wireless != 1) {
|
||||
if (now >= pads[i].usb_next_look) pads[i].usb_token = rh_usb_find(gc), pads[i].usb_next_look = now + 2000000000LL;
|
||||
ds_usb = pads[i].usb_token >= 0;
|
||||
}
|
||||
owner = rh_bt_owner();
|
||||
ds_hid = owner == gc || (!owner && hos_sdl_hid_can() && *hos_sdl_pad_path(gc));
|
||||
} else if (rh && kind == VIB_PAD_STEAM && mode == VIB_MODE_AUTO) { /* (its grips: its HID device, one pad at a time) */
|
||||
void *owner = rh_steam_owner();
|
||||
ds_hid = owner == gc || (!owner && hos_sdl_hid_can() && *hos_sdl_pad_path(gc));
|
||||
}
|
||||
const int hd = pads[i].hd_kind != HD_RUMBLE_NONE && pads[i].hd != HD_RUMBLE_OFF;
|
||||
int want = vibration_pick(mode, vib_force, kind, pads[i].wireless, hd, rh, ds_usb, ds_hid);
|
||||
/* (a Joy-Con alone: our HD rumble merges both sides into it, RenHDrum's engine plays its own side's only. Testers'
|
||||
=renhdrum still gets RenHDrum's) */
|
||||
const int single = pads[i].hd_kind == HD_RUMBLE_JOYCON_LEFT || pads[i].hd_kind == HD_RUMBLE_JOYCON_RIGHT;
|
||||
if (want == VIB_RH_SWITCH && single && vib_force != VIB_FORCE_RENHDRUM) want = hd ? VIB_HD : VIB_MOTORS;
|
||||
if (want == pads[i].vib_failed && now < pads[i].vib_retry_ns) want = VIB_MOTORS; /* (it would not open: not yet) */
|
||||
if (want == pads[i].vib) return;
|
||||
vib_leave(i, now);
|
||||
int ok = 1;
|
||||
if (want == VIB_RH_DS_USB) ok = rh_usb_open(gc, pads[i].usb_token);
|
||||
else if (want == VIB_RH_DS_BT) ok = rh_bt_open(gc, hos_sdl_pad_path(gc));
|
||||
else if (want == VIB_RH_STEAM) ok = rh_steam_open(gc, hos_sdl_pad_path(gc), pads[i].vib_product == VIB_STEAM_CABLE);
|
||||
else if (want == VIB_RH_XBOX || want == VIB_RH_SWITCH)
|
||||
ok = rh_pad_open(gc, want, pads[i].wireless == 1, pads[i].hd_kind == HD_RUMBLE_PRO);
|
||||
if (!ok) {
|
||||
pads[i].vib_failed = (int8_t)want, pads[i].vib_retry_ns = now + 5000000000LL;
|
||||
want = VIB_MOTORS;
|
||||
}
|
||||
if (want != VIB_MOTORS || pads[i].vib_kind != VIB_PAD_OTHER)
|
||||
hos_log("vibration: \"%s\": %s", hos_sdl_pad_name(gc),
|
||||
want == VIB_NONE ? "off" : want == VIB_MOTORS ? "its motors" : want == VIB_HD ? "its own HD rumble" :
|
||||
want == VIB_RH_DS_USB ? "fine haptics on its cable (RenHDrum)" :
|
||||
want == VIB_RH_DS_BT ? "fine haptics over Bluetooth (RenHDrum)" :
|
||||
want == VIB_RH_XBOX ? "four motors (RenHDrum)" :
|
||||
want == VIB_RH_STEAM ? "its grips (RenHDrum, experimental)" : "HD rumble (RenHDrum)");
|
||||
pads[i].vib = (int8_t)want;
|
||||
}
|
||||
/* an Xbox pad's four motors (RenHDrum): sent when RenHDrum says, and again every half second while they turn, as the
|
||||
motor rumble is (SDL's rumble lasts the time it is given). triggers: the Trigger vibration row; off, the triggers' two
|
||||
motors stay still, as they do with the plain motors */
|
||||
static void four_poll(int i, int64_t now, int triggers) {
|
||||
uint16_t m[4];
|
||||
int due = rh_xbox_poll(pads[i].gc, now, m);
|
||||
if (!due) {
|
||||
if (!(pads[i].four[0] | pads[i].four[1] | pads[i].four[2] | pads[i].four[3]) || now - pads[i].four_ns < 500000000LL)
|
||||
return;
|
||||
memcpy(m, pads[i].four, sizeof m);
|
||||
}
|
||||
if (!triggers) m[2] = m[3] = 0;
|
||||
const int on = m[0] || m[1] || m[2] || m[3];
|
||||
hos_sdl_pad_rumble(pads[i].gc, m[0], m[1], on ? 1000 : 0);
|
||||
hos_sdl_pad_rumble_triggers(pads[i].gc, m[2], m[3], on ? 1000 : 0);
|
||||
memcpy(pads[i].four, m, sizeof m), pads[i].four_ns = now;
|
||||
}
|
||||
|
||||
/* (motion) the sensors on while Motion controls is on (HOS_OPT_GYRO, on without the menu), off otherwise; the pad with
|
||||
them that was used last read into the filter. count: the pads open */
|
||||
static void motion_poll(int64_t now, int count) {
|
||||
@@ -284,6 +446,28 @@ static void motion_poll(int64_t now, int count) {
|
||||
float a[3], g[3];
|
||||
const int read = pick >= 0 && hos_sdl_pad_sensor(pads[pick].gc, HOS_SDL_SENSOR_ACCEL, a, 3) &&
|
||||
hos_sdl_pad_sensor(pads[pick].gc, HOS_SDL_SENSOR_GYRO, g, 3);
|
||||
/* (a gyroscope reading the very same values for over a second has stopped when its accelerometer does too: a real
|
||||
accelerometer always moves a little, while a gyroscope may read exactly 0 at rest, as a Steam Deck's in its dock
|
||||
does. Seen with a Steam Controller under Steam after Alt+Tab, when Steam's layout switch left its sensors off while
|
||||
SDL still had them on. Off and on again, as the menu's Motion controls row does, brings it back) */
|
||||
{
|
||||
static float last_a[3], last_g[3];
|
||||
static int64_t same_since, rearm_ns;
|
||||
if (read && !memcmp(g, last_g, sizeof g) && !memcmp(a, last_a, sizeof a)) {
|
||||
if (!same_since) same_since = now;
|
||||
else if (now - same_since > 1200000000LL && now >= rearm_ns) {
|
||||
hos_sdl_pad_sensor_enable(pads[pick].gc, HOS_SDL_SENSOR_ACCEL, 0);
|
||||
hos_sdl_pad_sensor_enable(pads[pick].gc, HOS_SDL_SENSOR_GYRO, 0);
|
||||
pads[pick].motion_on = 0; /* (turned on again by the loop above on the next poll) */
|
||||
hos_log("hid: \"%s\": its gyroscope and accelerometer stopped changing: motion sensors turned off "
|
||||
"and on again", hos_sdl_pad_name(pads[pick].gc));
|
||||
same_since = 0, rearm_ns = now + 3000000000LL;
|
||||
}
|
||||
} else {
|
||||
if (read) memcpy(last_a, a, sizeof a), memcpy(last_g, g, sizeof g);
|
||||
same_since = 0;
|
||||
}
|
||||
}
|
||||
/* (the pad that had motion keeps what its filter learned of its gyroscope's bias, for when it has motion again) */
|
||||
if (motion_pad >= 0 && (!read || pick != motion_pad) && pads[motion_pad].gc && pads[motion_pad].serial == motion_serial &&
|
||||
motion.learned_t > 0) {
|
||||
@@ -350,12 +534,72 @@ static void motion_poll(int64_t now, int count) {
|
||||
ReleaseSRWLockExclusive(&state_lock);
|
||||
}
|
||||
|
||||
/* ((Triforce) 11-24) a motion-only pad's own presses (host/steam_pads.h): they are not the game's input, but they still
|
||||
mark it the pad used last, which motion_poll reads motion from */
|
||||
static void motion_only_used(int i, int64_t now) {
|
||||
int rx_option(int id, int otherwise);
|
||||
const int z = rx_option(11, 0); /* (the menu's Stick dead zone) */
|
||||
uint64_t sig = 0;
|
||||
for (int k = BTN_A; k <= BTN_RIGHT; k++)
|
||||
if (hos_sdl_pad_button(pads[i].gc, k)) sig |= 1ULL << k;
|
||||
for (int k = 0; k < 4; k++) { /* (as the poll's own: a stick by which way it is pushed, a resting one's noise no push) */
|
||||
const int16_t raw = hos_sdl_pad_axis(pads[i].gc, AX_LX + k);
|
||||
const int own = hos_stick_own(k >> 1);
|
||||
const int32_t a = stick_rests(raw, own) ? 0 : stick_value(raw, k & 1, z, own);
|
||||
sig |= (uint64_t)(a > 0 ? 1 : a < 0 ? 2 : 0) << (32 + 2 * k);
|
||||
}
|
||||
if (sig != pads[i].input_sig) pads[i].input_sig = sig, pads[i].used_ns = now;
|
||||
}
|
||||
|
||||
/* (Triforce) Pad i's trigger t (0 left, 1 right) at its reading a (SDL's 0 to 32767): what it gives the game, a, or 0
|
||||
until it counts. It counts once it has read let go (8000 or below) for a second without a break since the pad was
|
||||
opened, as a stick steers once seen at rest. A device whose trigger reads held for good (a ShanWan USB receiver,
|
||||
2563:0575, beside the player's own pad) held ZL and ZR from every pad, kept the Controls page from listening for a
|
||||
binding (it waits for every input to be let go) and, once the Insert menu closed, kept the player's pads from the
|
||||
game (nn_hid.c: an input down at the close waits to be let go). One let-go reading was not enough: with that
|
||||
receiver plugged in, "seen let go once" still let its triggers through (a let-go reading as it opens, or for a moment
|
||||
now and then). A real trigger rests when its pad opens, so it counts after a second. The log says, once each: still
|
||||
not counting 3 s after the pad opened, counting after that, and held 30 s without a break once it counts, with the
|
||||
pad's name and the reading. tests/test_trigger_rest.py */
|
||||
#define TRIGGER_REST_NS 1000000000LL
|
||||
enum { TRIG_SAID_HELD = 1, TRIG_SAID_COUNTS = 4, TRIG_SAID_LONG = 16 }; /* (<< t: the left's bit, then the right's) */
|
||||
static int trigger_pull(int i, int t, int a, int64_t now) {
|
||||
const char *side = t ? "right" : "left";
|
||||
if (a > 8000) {
|
||||
pads[i].trig_rest_ns[t] = 0;
|
||||
if (!pads[i].trig_held_ns[t]) pads[i].trig_held_ns[t] = now;
|
||||
} else {
|
||||
pads[i].trig_held_ns[t] = 0;
|
||||
if (!pads[i].trig_rest_ns[t]) pads[i].trig_rest_ns[t] = now;
|
||||
if (now - pads[i].trig_rest_ns[t] >= TRIGGER_REST_NS) pads[i].rested |= 1u << (AX_LT + t);
|
||||
}
|
||||
const int counts = pads[i].rested >> (AX_LT + t) & 1;
|
||||
if (!counts && now - pads[i].opened_ns >= 3000000000LL && !(pads[i].trig_said & TRIG_SAID_HELD << t)) {
|
||||
pads[i].trig_said |= TRIG_SAID_HELD << t;
|
||||
hos_log("hid: \"%s\": its %s trigger reads %d of 32767 and has not read let go for a second since it was "
|
||||
"opened, so it does not count until it does", hos_sdl_pad_name(pads[i].gc), side, a);
|
||||
}
|
||||
if (counts && (pads[i].trig_said & TRIG_SAID_HELD << t) && !(pads[i].trig_said & TRIG_SAID_COUNTS << t)) {
|
||||
pads[i].trig_said |= TRIG_SAID_COUNTS << t;
|
||||
hos_log("hid: \"%s\": its %s trigger has read let go for a second (%d of 32767): it counts from now",
|
||||
hos_sdl_pad_name(pads[i].gc), side, a);
|
||||
}
|
||||
if (counts && pads[i].trig_held_ns[t] && now - pads[i].trig_held_ns[t] >= 30000000000LL &&
|
||||
!(pads[i].trig_said & TRIG_SAID_LONG << t)) {
|
||||
pads[i].trig_said |= TRIG_SAID_LONG << t;
|
||||
hos_log("hid: \"%s\": its %s trigger has read held (%d of 32767) for 30 s without a break",
|
||||
hos_sdl_pad_name(pads[i].gc), side, a);
|
||||
}
|
||||
return counts ? a : 0;
|
||||
}
|
||||
|
||||
/* one poll: controllers plugged in or gone (each second; (Triforce) each quarter second for the first two, while the
|
||||
button prompts' Auto waits for them: SCANS_FAST), then every open one's buttons, sticks and rumble */
|
||||
#define SCANS_FAST 8
|
||||
static void pads_poll(void) {
|
||||
static int64_t next_scan = 0;
|
||||
static int64_t gone_ns; /* (Triforce) when a controller last disconnected, for the log */
|
||||
if (vib_force < 0) vib_force = vibration_force(getenv("HOS_RUMBLE_BACKEND")); /* ((Triforce) host/vibration.h) */
|
||||
hos_sdl_pads_update();
|
||||
const int64_t now = hos_now_ns();
|
||||
const int scanned = now >= next_scan;
|
||||
@@ -368,6 +612,8 @@ static void pads_poll(void) {
|
||||
hos_log("hid: controller \"%s\" disconnected (SDL), %.0f s after it connected", hos_sdl_pad_name(pads[i].gc),
|
||||
(now - pads[i].opened_ns) / 1e9);
|
||||
gone_ns = now;
|
||||
hos_pad_speaker_forget(pads[i].gc); /* ((Triforce) the controller speaker lets go of it first */
|
||||
vib_leave(i, now); /* (and what played its vibration) */
|
||||
hos_sdl_pad_close(pads[i].gc);
|
||||
pads[i].gc = NULL;
|
||||
pads[i].rumble_lo = pads[i].rumble_hi = 0;
|
||||
@@ -394,26 +640,69 @@ static void pads_poll(void) {
|
||||
pads[slot].trigger = 0, pads[slot].trigger_said = 0;
|
||||
pads[slot].trigger_ns = pads[slot].trigger_retry_ns = 0;
|
||||
hd_open(slot, gc);
|
||||
/* ((Triforce) what plays its vibration is chosen by the poll below, host/vibration.h) */
|
||||
pads[slot].vib = -1, pads[slot].vib_failed = -1, pads[slot].vib_retry_ns = 0;
|
||||
pads[slot].usb_token = -1, pads[slot].usb_next_look = 0;
|
||||
memset(pads[slot].four, 0, sizeof pads[slot].four), pads[slot].four_ns = 0;
|
||||
pads[slot].vib_product = hos_sdl_pad_product(gc);
|
||||
pads[slot].vib_kind = (int8_t)vibration_pad_kind(hos_sdl_load(), hos_sdl_pad_type(gc), hos_sdl_pad_name(gc),
|
||||
hos_sdl_pad_vendor(gc), pads[slot].vib_product);
|
||||
pads[slot].wireless = (int8_t)hos_sdl_pad_wireless(gc);
|
||||
pads[slot].motion = hos_sdl_pad_has_sensor(gc, HOS_SDL_SENSOR_GYRO) && hos_sdl_pad_has_sensor(gc, HOS_SDL_SENSOR_ACCEL);
|
||||
pads[slot].motion_on = 0;
|
||||
pads[slot].motion_retry_ns = 0;
|
||||
pads[slot].used_ns = now, pads[slot].input_sig = 0; /* (just connected: the one about to be used) */
|
||||
pads[slot].rested = 0;
|
||||
memset(pads[slot].held, 0, sizeof pads[slot].held);
|
||||
pads[slot].opened_ns = now; /* ((Triforce) before the first poll: trigger_pull counts from it) */
|
||||
pads[slot].trig_held_ns[0] = pads[slot].trig_held_ns[1] = 0;
|
||||
pads[slot].trig_rest_ns[0] = pads[slot].trig_rest_ns[1] = 0;
|
||||
pads[slot].trig_said = 0;
|
||||
pads[slot].serial = ++pads_opened;
|
||||
pads[slot].has_bias = 0;
|
||||
hos_log("hid: controller \"%s\" connected (SDL)%s", hos_sdl_pad_name(gc),
|
||||
pads[slot].motion ? ", with a gyroscope" : "");
|
||||
/* ((Triforce) 11-24: who it is, for host/steam_pads.h's rules; all 0 with HOS_STEAM_PADS=0, and from an
|
||||
SDL that cannot say, so no rule takes it) */
|
||||
pads[slot].vendor = steam_rules() ? hos_sdl_pad_vendor(gc) : 0;
|
||||
pads[slot].product = steam_rules() ? hos_sdl_pad_product(gc) : 0;
|
||||
pads[slot].steam = steam_rules() ? hos_sdl_pad_steam_handle(gc) : 0;
|
||||
pads[slot].motion_only = 0; /* (the poll below decides, and says so) */
|
||||
hos_sdl_pad_log_connection(gc, pads[slot].motion); /* ((Triforce) with its GUID and mapping: host/hos_sdl.c) */
|
||||
if (pads[slot].steam) hos_log("hid: that controller is Steam Input's");
|
||||
pads[slot].opened_ns = now;
|
||||
if (gone_ns && now - gone_ns < 60000000000LL)
|
||||
hos_log("hid: that is %.1f s after a controller disconnected", (now - gone_ns) / 1e9);
|
||||
}
|
||||
{ /* ((Triforce) the controller speaker follows the DualSense that is open (host/pad_speaker.c): the first known on
|
||||
a cable, else the first whose transport SDL cannot say */
|
||||
void *dualsense = NULL;
|
||||
int wired = 0;
|
||||
for (int i = 0; i < MAX_PADS; i++) {
|
||||
const char *name = pads[i].gc ? hos_sdl_pad_name(pads[i].gc) : NULL;
|
||||
if (!name || hos_sdl_pad_vendor(pads[i].gc) != 0x054c || (!strstr(name, "DualSense") && !strstr(name, "PS5")))
|
||||
continue;
|
||||
const int wireless = hos_sdl_pad_wireless(pads[i].gc);
|
||||
if (wireless == 0) { dualsense = pads[i].gc; wired = 1; break; }
|
||||
if (wireless < 0 && !dualsense) { dualsense = pads[i].gc; wired = 1; }
|
||||
}
|
||||
hos_pad_speaker_pad(dualsense, wired);
|
||||
}
|
||||
}
|
||||
uint64_t b = 0;
|
||||
int32_t s[4] = {0};
|
||||
int count = 0;
|
||||
int rx_option(int id, int otherwise);
|
||||
const int strength = rx_option(9, 100); /* (the menu's Rumble strength: the motors' and HD rumble's) */
|
||||
int strength = rx_option(9, 100); /* (the menu's Rumble strength: the motors' and HD rumble's) */
|
||||
/* ((Triforce) the menu's Vibration (Auto, Basic, Off: host/vibration.h). Rumble strength Off is Vibration Off; its
|
||||
percent is every backend's (RenHDrum's up to 200) */
|
||||
int mode = rx_option(HOS_OPT_VIBRATION, VIB_MODE_AUTO);
|
||||
if (mode < VIB_MODE_AUTO || mode > VIB_MODE_OFF) mode = VIB_MODE_AUTO;
|
||||
if (strength <= 0) mode = VIB_MODE_OFF;
|
||||
/* (RenHDrum's backends: a side gone quiet, the strength, and the menu's DualSense HD Haptics) */
|
||||
{ /* ((Triforce) the cable's voice coils at the ocarina's share while it plays on the pad's speaker, host/pad_speaker.c) */
|
||||
const int rh_strength = strength > 0 ? strength : 100;
|
||||
rh_tick(now, 0, rh_strength, rh_strength * hos_pad_speaker_pad_rumble_percent(rh_usb_owner()) / 100,
|
||||
rx_option(HOS_OPT_DS_HD_HAPTICS, 1) != 0);
|
||||
}
|
||||
/* ((Triforce) the menu's Vibration curve: the motors' alone. A Switch controller's HD rumble has its own,
|
||||
hd_rumble.h's hd_rumble_felt, and plays the game's values by it whatever this row says) */
|
||||
const int curve = rx_option(HOS_OPT_RUMBLE_CURVE, 100);
|
||||
@@ -435,37 +724,87 @@ static void pads_poll(void) {
|
||||
hd_rumble_merge(felt[0], felt[1], felt[2]);
|
||||
hd_rumble_encode(felt[2], strength, side[2]);
|
||||
}
|
||||
int stand_in = 0; /* ((Triforce) 11-24) a Steam stand-in pad open (host/steam_pads.h) */
|
||||
int64_t status_used = -1; /* ((Triforce) the menu's vibration line: the pad used last */
|
||||
int status_pad = -1;
|
||||
int deck_builtin = 0; /* (and the Steam Deck's built-in controls giving input: its mouse must not) */
|
||||
for (int i = 0; i < MAX_PADS; i++) stand_in |= pads[i].gc && pads[i].steam;
|
||||
for (int i = 0; i < MAX_PADS; i++) {
|
||||
void *gc = pads[i].gc;
|
||||
if (!gc) continue;
|
||||
/* ((Triforce) 11-24) a real Valve pad beside its Steam stand-in: its motion is read (motion_poll), its
|
||||
buttons and sticks come through the stand-in as the player's Steam layout maps them, so they are not
|
||||
merged twice, and its rumble goes through Steam too. Its own presses still mark it the pad used last,
|
||||
for motion. Never without a stand-in pad open: every other pad plays as before */
|
||||
const int motion_only = steam_pads_motion_only(pads[i].vendor, pads[i].steam, stand_in);
|
||||
if (motion_only != pads[i].motion_only) {
|
||||
pads[i].motion_only = motion_only;
|
||||
/* ((Triforce) its rumble goes through Steam's stand-in now: what played it here lets go, or it would play
|
||||
twice) */
|
||||
if (motion_only && pads[i].vib >= 0) vib_leave(i, now);
|
||||
/* (a real Valve pad this SDL opens with no gyroscope: an SDL with no driver for it, so the loosened
|
||||
list gives no motion, said once so the next person without motion sees why) */
|
||||
if (motion_only && !pads[i].motion)
|
||||
hos_log("hid: \"%s\": no motion sensors through this SDL, so Motion controls can't read it; "
|
||||
"its buttons come through Steam Input's pad", hos_sdl_pad_name(gc));
|
||||
else
|
||||
hos_log(motion_only ? "hid: \"%s\": motion only, its buttons come through Steam Input's pad"
|
||||
: "hid: \"%s\": its buttons count again (no Steam Input pad is open)",
|
||||
hos_sdl_pad_name(gc));
|
||||
}
|
||||
if (motion_only) {
|
||||
motion_only_used(i, now);
|
||||
continue;
|
||||
}
|
||||
if (steam_pads_deck_builtin(pads[i].vendor, pads[i].product, pads[i].steam)) deck_builtin = 1;
|
||||
count++;
|
||||
for (int k = BTN_A; k <= BTN_RIGHT; k++) /* (SDL3's gamepad buttons are in SDL2's order) */
|
||||
if (hos_sdl_pad_button(gc, k)) b |= 1ULL << k;
|
||||
if (hos_sdl_pad_axis(gc, AX_LT) > 8000) b |= 1ULL << HOS_PAD_LTRIGGER;
|
||||
if (hos_sdl_pad_axis(gc, AX_RT) > 8000) b |= 1ULL << HOS_PAD_RTRIGGER;
|
||||
/* a DualShock 4's or DualSense's touchpad click: with the Menu shortcut row's touchpad choices it opens the Insert
|
||||
menu as F1 does (vk_menu.cpp). SDL numbers it 20 in both SDL2 and SDL3; an SDL or a pad without it answers 0 */
|
||||
if (hos_sdl_pad_button(gc, BTN_TOUCHPAD)) b |= 1ULL << HOS_PAD_TOUCHPAD;
|
||||
/* ((Triforce) 11-24) the rear paddles, SDL's 16 to 19 (SDL2's PADDLE1 to 4 in the same places): inputs a binding
|
||||
can take, HOS_PAD_RPADDLE1 on */
|
||||
for (int k = BTN_RPADDLE1; k <= BTN_LPADDLE2; k++)
|
||||
if (hos_sdl_pad_button(gc, k)) b |= 1ULL << (HOS_PAD_RPADDLE1 + k - BTN_RPADDLE1);
|
||||
/* (Triforce) A trigger presses once it has read let go for a second since the pad was opened (trigger_pull) */
|
||||
for (int t = 0; t < 2; t++)
|
||||
if (trigger_pull(i, t, hos_sdl_pad_axis(gc, AX_LT + t), now) > 8000)
|
||||
b |= 1ULL << (t ? HOS_PAD_RTRIGGER : HOS_PAD_LTRIGGER);
|
||||
const int inv_x = rx_option(16, 0);
|
||||
const int inv_y = rx_option(17, 0);
|
||||
const int z = rx_option(11, 0); /* (the menu's Stick dead zone: nn_hid.c's hos_stick_axis) */
|
||||
const int own[2] = {hos_stick_own(0), hos_stick_own(1)}; /* ((Triforce) each stick's own, -1 none) */
|
||||
const int16_t raw[4] = {hos_sdl_pad_axis(gc, AX_LX), hos_sdl_pad_axis(gc, AX_LY), hos_sdl_pad_axis(gc, AX_RX),
|
||||
hos_sdl_pad_axis(gc, AX_RY)};
|
||||
int32_t v[4] = {stick_value(raw[0], 0, z, own[0]),
|
||||
stick_value(raw[1], 1, z, own[0]),
|
||||
stick_value(raw[2], inv_x, z, own[1]),
|
||||
stick_value(raw[3], inv_y ? 0 : 1, z, own[1])};
|
||||
int32_t v[4]; /* ((Triforce) each stick cut as a pair, so a push near an axis keeps its direction) */
|
||||
hos_filter_stick(raw[0], raw[1], z, own[0], v);
|
||||
hos_filter_stick(raw[2], raw[3], z, own[1], v + 2);
|
||||
v[1] = -v[1], v[3] = -v[3]; /* (SDL's Y axes point down) */
|
||||
/* (hookshot) An axis steers once it has been seen at rest (inside the dead zone) since the pad was opened. The sticks are
|
||||
the strongest of all the pads', so a device whose axis reads held for good (a mapping that puts a trigger or an
|
||||
unused axis on a stick, a second virtual pad) turned the camera or walked Link in circles on its own, with the
|
||||
player's pad at rest (#1673: Xbox 360 pad, CachyOS; #1661: GameSir 2 Lite, wired). A real stick rests at the start. */
|
||||
/* (a worn stick resting just past a small dead zone counts once it is pushed the other way: it went past its rest) */
|
||||
/* ((Triforce) with a dead zone of its stick's own, an axis inside the default one is at rest too: stick_rests) */
|
||||
/* (rest is judged axis by axis, as before the circle: a phantom axis held past the dead zone keeps its partner
|
||||
outside the circle, and the partner must still rest at its own centre) */
|
||||
for (int k = 0; k < 4; k++) {
|
||||
const signed char way = (signed char)(v[k] > 0 ? 1 : v[k] < 0 ? -1 : 0);
|
||||
const int32_t alone = stick_value(raw[k], k & 1, z, own[k >> 1]); /* (the axis by itself, cut as one) */
|
||||
const signed char way = (signed char)(alone > 0 ? 1 : alone < 0 ? -1 : 0);
|
||||
if (!way || (pads[i].held[k] && way != pads[i].held[k]) || stick_rests(raw[k], own[k >> 1]))
|
||||
pads[i].rested |= 1u << k;
|
||||
pads[i].held[k] = way;
|
||||
if (!(pads[i].rested >> k & 1)) v[k] = 0;
|
||||
}
|
||||
/* (an axis held back above no longer counts toward its stick's circle, so its partner's drift stays inside
|
||||
the dead zone. The values are clamped already and the circle keeps them, so nothing else changes) */
|
||||
hos_filter_stick((int16_t)v[0], (int16_t)v[1], z, own[0], v);
|
||||
hos_filter_stick((int16_t)v[2], (int16_t)v[3], z, own[1], v + 2);
|
||||
/* Camera inversion changes output, not whether the physical stick crossed its rest position. Otherwise
|
||||
toggling the setting admits a held phantom axis, which stays admitted after the setting is restored. */
|
||||
if (inv_x) v[2] = -v[2];
|
||||
if (inv_y) v[3] = -v[3];
|
||||
for (int k = 0; k < 4; k++)
|
||||
if ((v[k] < 0 ? -v[k] : v[k]) > (s[k] < 0 ? -s[k] : s[k])) s[k] = v[k];
|
||||
{ /* (motion: the pad last used; a stick counts by which way it is pushed, not by how far) */
|
||||
@@ -478,7 +817,37 @@ static void pads_poll(void) {
|
||||
}
|
||||
if (sig != pads[i].input_sig) pads[i].input_sig = sig, pads[i].used_ns = now;
|
||||
}
|
||||
if (hd_poll(i, side, now)) continue;
|
||||
/* ((Triforce) what plays its vibration: chosen again each poll (host/vibration.h), then played. Without RenHDrum
|
||||
and with Vibration on Auto: HD rumble for a Switch pad, the motors (and Trigger vibration) otherwise, as before */
|
||||
vib_choose(i, mode, now);
|
||||
if (pads[i].used_ns >= status_used) status_used = pads[i].used_ns, status_pad = i;
|
||||
if (pads[i].vib == VIB_NONE) continue;
|
||||
if (pads[i].vib == VIB_HD) /* (refused: its motors this poll, and chosen again at the next) */
|
||||
if (hd_poll(i, side, now)) continue;
|
||||
if (pads[i].vib == VIB_RH_DS_USB || pads[i].vib == VIB_RH_DS_BT) { /* (their own threads play) */
|
||||
/* (HD Haptics' triggers: how far each is pulled, 0 to 255, and whether another button is held) */
|
||||
const int lt = hos_sdl_pad_axis(gc, AX_LT), rt = hos_sdl_pad_axis(gc, AX_RT);
|
||||
rh_ds_triggers(gc, now, lt > 0 ? lt * 255 / 32767 : 0, rt > 0 ? rt * 255 / 32767 : 0,
|
||||
(pads[i].input_sig & 0xFFFFFFFFULL) != 0);
|
||||
continue;
|
||||
}
|
||||
if (pads[i].vib == VIB_RH_STEAM) continue; /* (its own thread plays) */
|
||||
if (pads[i].vib == VIB_RH_XBOX) {
|
||||
four_poll(i, now, triggers);
|
||||
continue;
|
||||
}
|
||||
if (pads[i].vib == VIB_RH_SWITCH) {
|
||||
uint8_t packet[HD_RUMBLE_PACKET_SIZE];
|
||||
if (rh_switch_poll(gc, now, packet)) hos_sdl_pad_effect(gc, packet, sizeof packet);
|
||||
continue;
|
||||
}
|
||||
/* ((Triforce) the ocarina playing on this pad's speaker: its motors at that share, host/pad_speaker.c) */
|
||||
uint16_t pad_motors[2] = {motors[0], motors[1]};
|
||||
const int pad_percent = hos_pad_speaker_pad_rumble_percent(gc);
|
||||
if (pad_percent != 100)
|
||||
rumble_strength(rumble_curve((uint16_t)rumble_low, curve), rumble_curve((uint16_t)rumble_high, curve),
|
||||
strength * pad_percent / 100, pad_motors);
|
||||
const uint16_t lo = pad_motors[0], hi = pad_motors[1]; /* (this pad's: the poll's own, but for that) */
|
||||
if (rumble_due(lo, hi, pads[i].rumble_lo, pads[i].rumble_hi, now, pads[i].rumble_ns)) {
|
||||
hos_sdl_pad_rumble(gc, lo, hi, lo || hi ? 1000 : 0);
|
||||
pads[i].rumble_lo = lo;
|
||||
@@ -487,24 +856,38 @@ static void pads_poll(void) {
|
||||
}
|
||||
trigger_poll(i, triggers ? hi : 0, now); /* ((Triforce) the light motor's rumble, in the triggers too) */
|
||||
}
|
||||
{ /* ((Triforce) the menu's vibration line: what plays the pad used last (host/vibration.h) */
|
||||
void rx_option_set(int id, int value);
|
||||
int st = vibration_status(VIB_PAD_OTHER, VIB_SAY_NO_PAD);
|
||||
if (status_pad >= 0) {
|
||||
const int k = pads[status_pad].vib_kind;
|
||||
st = vibration_status(k, vibration_say(pads[status_pad].vib, k, pads[status_pad].wireless, vib_rh_for(k),
|
||||
mode));
|
||||
}
|
||||
rx_option_set(HOS_OPT_VIBRATION_STATUS, st); /* (each poll: a menu loaded later has it at once) */
|
||||
}
|
||||
motion_poll(now, count);
|
||||
AcquireSRWLockExclusive(&state_lock);
|
||||
state_buttons = b;
|
||||
memcpy(state_stick, s, sizeof s);
|
||||
state_count = count;
|
||||
state_deck_builtin = deck_builtin;
|
||||
state_name[0] = 0;
|
||||
state_type = 0;
|
||||
for (int i = 0; i < MAX_PADS; i++)
|
||||
if (pads[i].gc) {
|
||||
if (pads[i].gc && !pads[i].motion_only) { /* ((Triforce) 11-24: the stand-in's name, not its motion-only pad's) */
|
||||
const char *name = hos_sdl_pad_name(pads[i].gc);
|
||||
snprintf(state_name, sizeof state_name, "%s", name ? name : "");
|
||||
state_type = hos_sdl_pad_type(pads[i].gc); /* ((Triforce) read each time, as the name) */
|
||||
break;
|
||||
}
|
||||
{ /* ((Triforce) the one used last: its name, for the overlay's icons and Auto's next start) */
|
||||
int last = -1;
|
||||
for (int i = 0; i < MAX_PADS; i++)
|
||||
if (pads[i].gc && (last < 0 || pads[i].used_ns > pads[last].used_ns)) last = i;
|
||||
for (int i = 0; i < MAX_PADS; i++) /* ((Triforce) 11-24: the pad that plays, not a motion-only one beside it) */
|
||||
if (pads[i].gc && !pads[i].motion_only && (last < 0 || pads[i].used_ns > pads[last].used_ns)) last = i;
|
||||
const char *name = last >= 0 ? hos_sdl_pad_name(pads[last].gc) : NULL;
|
||||
snprintf(state_last_name, sizeof state_last_name, "%s", name ? name : "");
|
||||
state_last_type = last >= 0 ? hos_sdl_pad_type(pads[last].gc) : 0;
|
||||
}
|
||||
ReleaseSRWLockExclusive(&state_lock);
|
||||
if (scanned && scans >= 0) InterlockedIncrement(&scans); /* (after the names: a scan counted has them) */
|
||||
@@ -564,6 +947,15 @@ int hos_sdl_pads(uint64_t *buttons, int32_t stick[4]) {
|
||||
ReleaseSRWLockShared(&state_lock);
|
||||
return n;
|
||||
}
|
||||
/* ((Triforce) 11-24, nn_hid.c) Whether the Steam Deck's built-in controls gave input in the last poll
|
||||
(host/steam_pads.h steam_pads_deck_builtin): their mouse's buttons and motion are then no control's. 0 without SDL,
|
||||
before its first poll, with HOS_STEAM_PADS=0, and on every PC that is not a Steam Deck */
|
||||
int hos_sdl_pads_deck_builtin(void) {
|
||||
AcquireSRWLockShared(&state_lock);
|
||||
const int deck = state_deck_builtin;
|
||||
ReleaseSRWLockShared(&state_lock);
|
||||
return deck;
|
||||
}
|
||||
|
||||
/* (motion) the latest readings for nn_hid.c's GetSixAxisSensorStates, newest first: up to max, how many there are; 0
|
||||
when there are none (Motion controls off, or no pad with a gyroscope) */
|
||||
@@ -588,6 +980,15 @@ void hos_sdl_pad_last_name(char *out, size_t cap) {
|
||||
snprintf(out, cap, "%s", state_last_name);
|
||||
ReleaseSRWLockShared(&state_lock);
|
||||
}
|
||||
/* ((Triforce) The SDL type of the first open controller (last 0) or of the one used last (last 1): SDL_GetGamepadType's or
|
||||
SDL_GameControllerGetType's number, 0 with none or unknown; *sdl the SDL it is of (3, 2; 0 none loaded) */
|
||||
int hos_sdl_pad_type_of(int last, int *sdl) {
|
||||
AcquireSRWLockShared(&state_lock);
|
||||
const int type = last ? state_last_type : state_type;
|
||||
ReleaseSRWLockShared(&state_lock);
|
||||
*sdl = type ? hos_sdl_load() : 0; /* (loaded already: a pad is open) */
|
||||
return type;
|
||||
}
|
||||
/* ((Triforce) The scans for controllers done so far (pads_poll's: the first at once, then each quarter second for the
|
||||
first SCANS_FAST, then each second); -1 when SDL will not run */
|
||||
int hos_sdl_pad_scans(void) { return (int)scans; }
|
||||
@@ -609,3 +1010,7 @@ void hos_sdl_rumble_hd(int side, const float value[4]) {
|
||||
memcpy(hd_values[side & 1], value, sizeof hd_values[0]);
|
||||
ReleaseSRWLockExclusive(&hd_lock);
|
||||
}
|
||||
|
||||
/* ((Triforce) the game is over: RenHDrum's backends stop and let go of the pads (host/rumble_renhdrum.c); hos_main.c calls
|
||||
it once nnMain has returned */
|
||||
void hos_sdl_vibration_shutdown(void) { rh_shutdown(); }
|
||||
|
||||
Reference in New Issue
Block a user