Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cuylerstuwe/d6176a409473b5c834a24ad92fb5e012 to your computer and use it in GitHub Desktop.

Select an option

Save cuylerstuwe/d6176a409473b5c834a24ad92fb5e012 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Test for Event-Driven Web Controllers
// @namespace salembeats
// @version 1.51
// @description UPDATE: Genericized to respond well to an additional controller (Logitech F310), plus constructor, plus axes, plus nicknames.
// @author Cuyler Stuwe (salembeats)
// @include *
// @require https://gist.github.com/salembeats/98cd58cfcee694e3bbc08adc3d925080/raw/0a33ea4f15df76fc54163eb12e9674bc120beb64/event-driven-web-controllers-library.js
// @noframes
// ==/UserScript==
InitializeControllerEventLoop();
window.addEventListener("controllerbutton", e => {
console.log("Controller", e.detail.controllerIndex, `(${e.detail.controllerTypeNickname})`,
"button", e.detail.button, `(index ${e.detail.buttonIndex})`,
"pressed?", e.detail.pressed);
});
window.addEventListener("controlleraxis", e => {
console.log("Controller", e.detail.controllerIndex, `(${e.detail.controllerTypeNickname})`,
"stick", e.detail.joystick,
"X:", e.detail.x, "Y:", e.detail.y);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment