useGamepad ​
Hook for getting information about gamepad
browser
test coverage
Last changed: last month
TIP
This hook uses navigator.getGamepads browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api
Installation ​
Library
CLI
Manual
typescript
import { useGamepad } from '@siberiacancode/reactuse';
Usage ​
typescript
const { supported, gamepads, active } = useGamepad();
Demo ​
Api ​
Returns
UseGamepadStateReturn
Type declaration ​
typescript
interface Gamepad {
hapticActuators?: GamepadHapticActuator[];
}
export interface UseGamepadStateReturn {
/** The gamepad active status */
active: boolean;
/** The gamepad state */
gamepads: Gamepad[];
/** The gamepad supported status */
supported: boolean;
}
Source ​
Source • DemoContributors ​
D