UNPKG

gamecontroller.js

Version:

A JavaScript library that lets you handle, configure, and use gamepad and controllers on a browser, using the Gamepad API

19 lines (14 loc) 636 B
const log = (message, type = 'log') => { if (type === 'error') { if (console && typeof console.error === 'function') console.error(message); } else { if (console && typeof console.info === 'function') console.info(message); } }; const error = message => log(message, 'error'); const isGamepadSupported = () => (navigator.getGamepads && typeof navigator.getGamepads === 'function') || (navigator.getGamepads && typeof navigator.webkitGetGamepads === 'function') || false; const emptyEvents = () => ({ action: () => {}, after: () => {}, before: () => {} }); export { isGamepadSupported, log, error, emptyEvents };