Created
July 9, 2019 01:08
-
-
Save cuylerstuwe/d6176a409473b5c834a24ad92fb5e012 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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