mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 11:49:59 -04:00
With NX2NAVI_RUMBLE_HD=1 (live, off by default) the gamepad the game reads, when it is a Switch Pro Controller, a single Joy-Con or a pair of them, gets each side's low and high band with its own frequency and amplitude in the controller's rumble report, and no dual-motor call any more. A Pro Controller and a single Joy-Con take the report through SDL's effect call, over USB and Bluetooth; SDL refuses that call for a combined pair, so a pair's reports are written to its two HID devices directly. Every other gamepad, the Switch 2 controllers included, keeps the motors. The game's thread posts its newest values and a thread of input.c writes the reports: at most one every 15 ms (rumble_hd_ms), a held value again every 30 ms, and the neutral value when the game stops sending for 250 ms, when another gamepad takes over, when the setting is turned off and before the process ends. The rumble strength scales the amplitude and rumble = 0 silences this path as well. With the setting off nothing is written to the controller: the log line at the take names it by its ids, and the first report is the trial. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
20 lines
1.2 KiB
C
20 lines
1.2 KiB
C
// HD rumble for a pair of Joy-Con (input_hd_pair.c): the rumble output report written to each Joy-Con's HID device,
|
|
// next to SDL, which reads the two as one gamepad and takes no rumble data for it. input.c calls it (hd_tick).
|
|
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include "rumble_hd.h"
|
|
|
|
// Looks for a left and a right Joy-Con among the HID devices and keeps their paths for hd_pair_write. 1 when both are
|
|
// there. Opens nothing. Any thread; takes the time of a HID device listing.
|
|
int hd_pair_find(void);
|
|
// Writes one rumble report to each Joy-Con: the left half of data to the left one, the right half to the right one.
|
|
// The first call after hd_pair_find opens the two devices. 0 when a device could not be opened or written (both are
|
|
// closed then, and SDL's error text says why). Blocks for as long as the writes take: the HD rumble thread only.
|
|
int hd_pair_write(const uint8_t data[RUMBLE_HD_DATA]);
|
|
// 1 while the two devices are open.
|
|
int hd_pair_is_open(void);
|
|
// Writes the neutral value to both Joy-Con, when neutral is set, and closes them. wait_ms: how long to wait for a
|
|
// write that is still running on another thread before giving up (the process is ending); 0 waits for it.
|
|
void hd_pair_close(int neutral, unsigned wait_ms);
|