mirror of
https://github.com/Andre-Bzk/twitch4steamdeck.git
synced 2026-11-15 15:43:08 +01:00
Fix: Entdoppelte Gamepad-Eingaben bei externen Controllern
- Browser-Gamepad-Pfad unter Linux deaktiviert - nahezu zeitgleiche identische Eingaben aus mehreren /dev/input/js*-Devices entdoppelt - doppelte D-Pad-Bewegungen bei Bluetooth-/USB-Controllern verhindert
This commit is contained in:
@@ -36,6 +36,9 @@ const REPEAT_INTERVAL_MS = 150
|
||||
// L2/R2 Trigger: kein Auto-Repeat, da 300s-Spruenge nicht wiederholt werden sollen.
|
||||
const NO_REPEAT_AXES = new Set([2, 5])
|
||||
const SCAN_INTERVAL_MS = 3000
|
||||
// Bluetooth-/Steam-Setups liefern dieselbe Eingabe teils über mehrere js*-Devices.
|
||||
// Nahezu zeitgleiche identische Events werden deshalb global entdoppelt.
|
||||
const DUPLICATE_EVENT_WINDOW_MS = 40
|
||||
|
||||
interface AxisState {
|
||||
key: string | null
|
||||
@@ -177,8 +180,14 @@ export function startGamepadReader(getWindow: () => BrowserWindow | null): () =>
|
||||
if (process.platform !== 'linux') return () => {}
|
||||
|
||||
const readers = new Map<string, JoystickReader>()
|
||||
const lastKeyAt = new Map<string, number>()
|
||||
|
||||
const onKey = (key: string): void => {
|
||||
const now = Date.now()
|
||||
const lastAt = lastKeyAt.get(key) ?? 0
|
||||
if (now - lastAt < DUPLICATE_EVENT_WINDOW_MS) return
|
||||
lastKeyAt.set(key, now)
|
||||
|
||||
const win = getWindow()
|
||||
if (!win || win.isDestroyed()) return
|
||||
win.webContents.send('gamepad-input', key)
|
||||
|
||||
@@ -22,6 +22,7 @@ export default function App(): JSX.Element {
|
||||
|
||||
// Browser Gamepad API (funktioniert im Desktop-Modus / Windows)
|
||||
useEffect(() => {
|
||||
if (navigator.userAgent.toLowerCase().includes('linux')) return
|
||||
gamepadService.start()
|
||||
return () => gamepadService.stop()
|
||||
}, [])
|
||||
|
||||
Reference in New Issue
Block a user