{"id":13491141,"url":"https://github.com/donmccurdy/aframe-gamepad-controls","last_synced_at":"2025-10-08T21:31:51.929Z","repository":{"id":57174157,"uuid":"48832928","full_name":"donmccurdy/aframe-gamepad-controls","owner":"donmccurdy","description":":video_game: Gamepad controls for A-Frame VR.","archived":true,"fork":false,"pushed_at":"2018-09-23T00:41:32.000Z","size":121,"stargazers_count":68,"open_issues_count":0,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-13T11:11:20.960Z","etag":null,"topics":["aframe","gamepad","webvr"],"latest_commit_sha":null,"homepage":"https://donmccurdy.github.io/aframe-gamepad-controls/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donmccurdy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-31T04:16:26.000Z","updated_at":"2024-11-04T22:08:57.000Z","dependencies_parsed_at":"2022-09-02T12:11:02.628Z","dependency_job_id":null,"html_url":"https://github.com/donmccurdy/aframe-gamepad-controls","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donmccurdy%2Faframe-gamepad-controls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donmccurdy%2Faframe-gamepad-controls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donmccurdy%2Faframe-gamepad-controls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donmccurdy%2Faframe-gamepad-controls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donmccurdy","download_url":"https://codeload.github.com/donmccurdy/aframe-gamepad-controls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235399024,"owners_count":18983817,"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","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":["aframe","gamepad","webvr"],"created_at":"2024-07-31T19:00:53.966Z","updated_at":"2025-10-08T21:31:51.617Z","avatar_url":"https://github.com/donmccurdy.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","JavaScript"],"sub_categories":["Uncategorized"],"readme":"# A-Frame `gamepad-controls`\n\n\u003e **NOTICE**: This project is no longer maintained. I recommend using `movement-controls` from [A-Frame Extras](https://github.com/donmccurdy/aframe-extras) instead.\n\nGamepad controls for A-Frame.\n\nDemo: https://donmccurdy.github.io/aframe-gamepad-controls/\n\n## Overview\n\nSupports one or more gamepads, attached to an A-Frame scene. When used on a mobile device, `gamepad-controls` can also receive input from a gamepad connected to a host machine, using [ProxyControls.js](https://proxy-controls.donmccurdy.com).\n\nThis component uses the HTML5 [Gamepad API](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API). The underlying API supports Firefox, Chrome, Edge, and Opera ([as of 01/2016](http://caniuse.com/#search=gamepad)). Safari and Internet Explorer do not currently support gamepads.\n\n## Usage (script)\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003c!-- A-Frame Library --\u003e\n    \u003cscript src=\"https://aframe.io/releases/0.3.1/aframe.min.js\"\u003e\u003c/script\u003e\n\n    \u003c!-- Component --\u003e\n    \u003cscript src=\"dist/aframe-gamepad-controls.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ca-scene\u003e\n      \u003c!-- ... --\u003e\n      \u003ca-entity camera gamepad-controls\u003e\u003c/a-entity\u003e\n    \u003c/a-scene\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Usage (NPM)\n\nInstall NPM module.\n\n```\n$ npm install aframe-gamepad-controls\n```\n\nRegister `gamepad-controls` component.\n\n```javascript\nvar AFRAME = require('aframe');\nvar GamepadControls = require('aframe-gamepad-controls');\nAFRAME.registerComponent('gamepad-controls', GamepadControls);\n```\n\nAdd markup.\n\n```html\n\u003c!-- First-person controls --\u003e\n\u003ca-entity camera gamepad-controls\u003e\u003c/a-entity\u003e\n\n\u003c!-- Third-person controls --\u003e\n\u003ca-cube gamepad-controls=\"lookEnabled: false\"\u003e\u003c/a-cube\u003e\n\n\u003c!-- Two players --\u003e\n\u003ca-obj-model src=\"player1.obj\" gamepad-controls=\"controller: 0; lookEnabled: false\"\u003e\u003c/a-obj-model\u003e\n\u003ca-obj-model src=\"player2.obj\" gamepad-controls=\"controller: 1; lookEnabled: false\"\u003e\u003c/a-obj-model\u003e\n```\n\n## Development\n\nTo edit the component or play with examples, [download the project](https://github.com/donmccurdy/aframe-gamepad-controls/archive/master.zip) and run:\n\n```shell\nnpm install\nnpm run dev\n```\n\nThe demo will run at [http://localhost:8000/](http://localhost:8000/).\n\n## Mobile / Cardboard + Gamepad\n\nIn Chrome on Android, USB gamepads can be connected with an OTG adapter. For a Nexus 5X, I use [this](http://www.amazon.com/gp/product/B00XHOGEZG). I'm not aware of a way to connect a gamepad in iOS, but definitely let me know if there's something I'm missing.\n\nThe `gamepad-controls` component can also receive remote events with WebRTC, if a `proxy-controls` element is attached to the scene. [More details about ProxyControls.js](https://proxy-controls.donmccurdy.com).\n\nExample:\n\n```html\n\u003ca-scene proxy-controls\u003e\n  \u003ca-entity camera\n            gamepad-controls\u003e\n  \u003c/a-entity\u003e\n\u003c/a-scene\u003e\n```\n\n## Gear VR\n\nA-Frame supports the Gear VR controller with `gear-vr-controller`, but for Gear VR's without a controller, this component can be used to handle it's trackpad events.\n\nFor a cursor-based setup, `downEvents` must be set to `gamepadbuttondown`. For example:\n\n```html\n\u003ca-entity cursor=\"downEvents: gamepadbuttondown; upEvents: gamepadbuttonup;\"\u003e\u003c/a-entity\u003e\n```\n\n## Button Events\n\nWhen buttons are pressed on the gamepad, a [GamepadButtonEvent](https://github.com/donmccurdy/aframe-gamepad-controls/blob/master/lib/GamepadButtonEvent.js) is emitted on the element. Components and entities may listen for these events and modify behavior as needed. Example:\n\n```javascript\nel.addEventListener('gamepadbuttondown', function (e) {\n  console.log('Button \"%d\" has been pressed.', e.index);\n});\n```\n\n**GamepadButtonEvent:**\n\nProperty | Type    | Description\n---------|---------|--------------\ntype     | string  | Either `gamepadbuttondown` or `gamepadbuttonup`.\nindex    | int     | Index of the button affected, 0..N.\npressed  | boolean | Whether or not the button is currently pressed.\nvalue    | float   | Distance the button was pressed, if applicable. Value will be 0 or 1 in most cases, but may return a float on the interval [0..1] for trigger-like buttons.\n\n**Markup-only Binding:**\n\nFor convenience, additional events are fired including the button index, providing a way to bind events to specific buttons using only markup. To play `pew-pew.wav` when `Button 7` is pressed (right trigger on an Xbox controller), you might do this:\n\n```html\n\u003ca-entity gamepad-controls\n          sound=\"src: pew-pew.wav;\n                 on: gamepadbuttondown:7\"\u003e\n\u003c/a-entity\u003e\n```\n\nFinally, your code may call the `gamepad-controls` component directly to request the state of a button, as a [GamepadButton](https://developer.mozilla.org/en-US/docs/Web/API/GamepadButton) instance:\n\n```javascript\nel.components['gamepad-controls'].getButton(index);\n// Returns a GamepadButton instance.\n```\n\n## Options\n\nProperty          | Default | Description\n------------------|---------|-------------\ncontroller        | 0       | Which controller (0..3) the object should be attached to.\nenabled           | true    | Enables all events on this controller.\nmovementEnabled   | true    | Enables movement via the left thumbstick.\nlookEnabled       | true    | `true`, or `false`. Enables view rotation via the right thumbstick.\nflyEnabled        | false   | Whether or not movement is restricted to the entity’s initial plane.\ninvertAxisY       | false   | Invert Y axis of view rotation thumbstick.\ndebug             | false   | When true, shows debugging info in the console.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonmccurdy%2Faframe-gamepad-controls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonmccurdy%2Faframe-gamepad-controls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonmccurdy%2Faframe-gamepad-controls/lists"}