// 1. Create a fake event object that mimics a GamepadEvent
const fakeEvent = new Event('gamepadconnected');
// 2. Duck-type the gamepad property onto the event
fakeEvent.gamepad = {
axes: [0, 0, 0, 0],
buttons: Array(16).fill({ pressed: false, value: 0 }),
connected: true,
id: "Standard Gamepad (Mocked)",
index: 0,
mapping: "standard",
timestamp: performance.now()
};
// 3. Override the navigator method so the site's loop finds it
navigator.getGamepads = () => [fakeEvent.gamepad, null, null, null];
// 4. Dispatch it
window.dispatchEvent(fakeEvent);
console.log("Mock gamepad event dispatched successfully.");