{"id":15050047,"url":"https://github.com/mozilla/galaxy.js-mobile-gamepad","last_synced_at":"2026-01-10T20:03:48.588Z","repository":{"id":20529763,"uuid":"23808932","full_name":"mozilla/galaxy.js-mobile-gamepad","owner":"mozilla","description":"INACTIVE - http://mzl.la/ghe-archive - a JS library for controlling an HTML5 game using WebRTC data channels","archived":true,"fork":false,"pushed_at":"2019-03-30T03:57:37.000Z","size":1884,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-10-04T12:36:53.884Z","etag":null,"topics":["inactive","unmaintained"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mozilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-08T21:23:00.000Z","updated_at":"2023-01-28T03:48:42.000Z","dependencies_parsed_at":"2022-07-23T05:47:21.669Z","dependency_job_id":null,"html_url":"https://github.com/mozilla/galaxy.js-mobile-gamepad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mozilla/galaxy.js-mobile-gamepad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Fgalaxy.js-mobile-gamepad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Fgalaxy.js-mobile-gamepad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Fgalaxy.js-mobile-gamepad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Fgalaxy.js-mobile-gamepad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozilla","download_url":"https://codeload.github.com/mozilla/galaxy.js-mobile-gamepad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Fgalaxy.js-mobile-gamepad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28257658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-10T02:00:06.867Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inactive","unmaintained"],"created_at":"2024-09-24T21:24:27.783Z","updated_at":"2026-01-10T20:03:48.570Z","avatar_url":"https://github.com/mozilla.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# galaxy.js-mobile-gamepad 🎮\n\nA JavaScript library for controlling an HTML5 game using WebRTC (falling back to WebSockets).\n\nUsed in conjunction with [galaxy.js](https://github.com/mozilla/galaxy.js).\n\n\u003e __Note:__ This project is not ready for prime time. Not an official Mozilla project. Pre-alpha everything. Anything and everything at your own risk.\n\n![screenshot of NES-inspired gamepad](src/img/gamepad-traditional-screenshot.png \"screenshot of NES-inspired gamepad\")\n\n\n## Downloads\n\n### Client\n\n* [gamepad-client.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-client.js)\n* [gamepad-client.min.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-client.min.js)\n\n### Host\n\n* [gamepad-host.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-host.js)\n* [gamepad-host.min.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-host.min.js)\n\n\n## Use in your own game\n\n\u003e __Disclaimer:__ this isn't ready for prime time yet. Use at your own risk.\n\n1. On the static server, open `client.html` (which will load `gamepad-client.min.js`).\n2. In your game, insert this script:\n\n    ```js\n    \u003cscript src=\"{static_server}/gamepad-host.min.js\"\u003e\n    ```\n\n3. Add a few lines to your game for pairing the gamepad, getting its state, and adding event listeners. Refer to the [sample games](src/examples) for more complete examples. Below is some code to get you started:\n\n    ```js\n    var pad = Gamepad.create();\n\n    pad.pair().then(function (controllerPeer) {\n      console.log('Connected to controller');\n    }).then(initControls).catch(function (e) {\n      console.trace(e.stack ? e.stack : e);\n    });\n\n    function initControls() {\n      window.requestAnimationFrame(function () {\n        // In your game loop check `pad.state`, or you can listen to events.\n      });\n\n      pad.on('buttonpress', function (key) {\n        // Some button pressed.\n      }).on('buttondown', function (key) {\n        // Some button pushed down.\n      }).on('buttonup', function (key) {\n        // Some button released.\n      }).on('buttonchange', function (key, isPressed) {\n        // Some button changed.\n      });\n\n      pad.on('buttonpress.select', function (key) {\n        // SELECT button pressed.\n      }).on('buttondown.select', function (key) {\n        // SELECT button pushed down.\n      }).on('buttonup.select', function (key) {\n        // SELECT button released.\n      }).on('buttonchange.select', function (key, isPressed) {\n        // SELECT button changed.\n      });\n    }\n\n    // Totally optional, but when the user stops playing your game,\n    // for example, you can call `destroyControls` to remove any event\n    // listeners you have set.\n    function destroyControls() {\n      // Remove event listener for a particular listener function.\n      pad.off('buttonpress', buttonpressHandler);\n\n      // Remove all event listeners for a particular event type.\n      pad.off('buttonpress');\n    }\n    ```\n\n## Develop\n\n1. Install Node dependencies:\n\n        npm install\n\n    This installs these production dependencies:\n\n    * [__plink-server__](https://github.com/oztu/plink-server): a simple Node-based WebSocket server – used as a signalling server for WebRTC\n    * [__plink__](https://github.com/oztu/plink): a simple client-side library for WebRTC data channels — used to do peer communication between a game and controllers\n\n    And these developer dependencies:\n\n    * [__browserify__](https://github.com/substack/node-browserify): a tool for packaging Node-flavoured CommonJS modules for the browser — used to compile JS for development and production bundles\n    * [__gulp__](https://github.com/gulpjs/gulp/): a streaming build system and task runner — used for such tasks as browserify compilation, code linting, distribution, and running a development server\n    * [a bunch of related packages for build tasks](package.json)\n\n2. _(Optional)_ Set up symlinks for updating GitHub pages:\n\n        gulp symlink-git-hooks\n\n3. _(Optional)_ To use custom settings for your local setup, first over a settings file:\n\n        cp src/js/settings_local.js{.dist,}\n\n    Any value specified in `src/js/settings_local.js` will override the defaults in `src/js/settings.js`.\n\n4. To rebuild (compile and minify) the scripts while developing and serve the files from a local server:\n\n        npm run-script dev\n\n5. In another terminal session, start up the signalling server (__plink-server__):\n\n        npm run-script signalling-server\n\n6. Load an [example game](http://localhost:3000/examples/HTML5-Keen/?1234).\n\n7. Load the [Nintendo™-inspired controller](http://localhost:3000/examples/HTML5-Keen/?1234).\n\n\n## Distribution\n\nTo build the files for distribution:\n\n    gulp dist\n\nSeveral files will be written to the `dist/` directory, including the main application file (uncompressed and minified):\n\n* [gamepad-client.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-client.js)\n* [gamepad-client.min.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-client.min.js)\n* [gamepad-host.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-host.js)\n* [gamepad-host.min.js](https://raw.githubusercontent.com/mozilla/galaxy.js-mobile-gamepad/master/dist/js/gamepad-host.min.js)\n\n\n## Deploying controller to a production server\n\n1. Install Node dependencies:\n\n        npm install --production\n\n2. Deploy the `dist/` on a server (the \"static server\" we'll call it).\n\n\n## Credits\n\n* [Albin Larsson](http://codepen.io/fullkornslimpa/) (unauthorized use of [HTML5 Nintendo™ controller CodePen](http://codepen.io/fullkornslimpa/pen/jxiHd/))\n* [Ivan Prieto Garrido](https://dribbble.com/shots/1240163-Nintendo-controler-flat-icon-ios7) (unauthorised, temporary use of Nintendo™ controller flat icon for webapp icon; will replace before project is official)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozilla%2Fgalaxy.js-mobile-gamepad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozilla%2Fgalaxy.js-mobile-gamepad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozilla%2Fgalaxy.js-mobile-gamepad/lists"}