{"id":22805118,"url":"https://github.com/thebitlink/webhid-ds4","last_synced_at":"2025-04-22T10:39:13.269Z","repository":{"id":38359496,"uuid":"219035635","full_name":"TheBITLINK/WebHID-DS4","owner":"TheBITLINK","description":"High Level API for DualShock 4 controllers powered by WebHID","archived":false,"fork":false,"pushed_at":"2023-01-07T04:23:58.000Z","size":847,"stargazers_count":39,"open_issues_count":6,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T08:30:40.566Z","etag":null,"topics":["library","sony-dualshock-controllers","webhid"],"latest_commit_sha":null,"homepage":"https://thebitlink.github.io/WebHID-DS4/","language":"TypeScript","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/TheBITLINK.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":"2019-11-01T17:51:21.000Z","updated_at":"2024-09-28T13:20:18.000Z","dependencies_parsed_at":"2023-02-06T11:46:11.486Z","dependency_job_id":null,"html_url":"https://github.com/TheBITLINK/WebHID-DS4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheBITLINK%2FWebHID-DS4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheBITLINK%2FWebHID-DS4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheBITLINK%2FWebHID-DS4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheBITLINK%2FWebHID-DS4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheBITLINK","download_url":"https://codeload.github.com/TheBITLINK/WebHID-DS4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229366808,"owners_count":18061776,"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":["library","sony-dualshock-controllers","webhid"],"created_at":"2024-12-12T10:12:59.726Z","updated_at":"2024-12-12T10:13:00.590Z","avatar_url":"https://github.com/TheBITLINK.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebHID-DS4\n\nA browser API for Sony DualShock 4 controllers built over the WebHID API.\n\nProvides high level APIs to access most of the controller's features over USB and Bluetooth.\n\n### Supported Features\n\n - USB and Bluetooth connectivity\n - Gyro \u0026 Accelerometer data\n - Touchpad Input\n - Buttons \u0026 Analogs\n - Lightbar RGB values\n - Rumble motors\n \n### Known Issues\n\n - Setting the lightbar colors and rumble intensity over Bluetooth is currently broken.\n - There's currently no way to detect if a controller has been disconnected.\n - There's currently no way to detect if a controller has already been connected either.\n - Not all DS4 Models are supported by this library. I only have a CUH-ZCT2U, so that's what i used to test. Support for third party controllers is not guaranteed.\n\n### Installation\n\n```npm install --save webhid-ds4```\n\n### Usage Example\n\n```js\nimport { DualShock4 } from 'webhid-ds4'\n\n// The WebHID device can only be requested upon user interaction\ndocument.getElementById('connectButton').addEventListener('click', async () =\u003e {\n  const DS4 = new DualShock4()\n  // This will request the WebHID device and initialize the controller\n  await DS4.init()\n  // Define a custom lightbar color\n  await DS4.lightbar.setColorRGB(170, 255, 0)\n  // The state object is updated periodically with the current controller state\n  function logInputs () {\n    requestAnimationFrame(logInputs)\n    document.getElementById('triangle').innerText = `Triangle Button: ${DS4.state.buttons.triangle}`\n    document.getElementById('circle').innerText = `Circle Button: ${DS4.state.buttons.circle}`\n    document.getElementById('cross').innerText = `Cross Button: ${DS4.state.buttons.cross}`\n    document.getElementById('square').innerText = `Square Button: ${DS4.state.buttons.square}`\n\n    document.getElementById('leftStick').innerText = `Left Stick: ${DS4.state.axes.leftStickX}, ${DS4.state.axes.leftStickY}`\n    document.getElementById('rightStick').innerText = `Right Stick: ${DS4.state.axes.rightStickX}, ${DS4.state.axes.rightStickY}`\n  }\n  logInputs()\n})\n```\n\n### Documentation\n\nAPI Documentation is available [here](https://thebitlink.github.io/WebHID-DS4/api/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebitlink%2Fwebhid-ds4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebitlink%2Fwebhid-ds4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebitlink%2Fwebhid-ds4/lists"}