{"id":17188042,"url":"https://github.com/cgutman/shieldcontrollerextensions","last_synced_at":"2025-03-25T04:27:16.380Z","repository":{"id":150062357,"uuid":"505592767","full_name":"cgutman/ShieldControllerExtensions","owner":"cgutman","description":"Android library to access rumble and other special functionality on NVIDIA Shield controllers","archived":false,"fork":false,"pushed_at":"2023-10-17T04:25:38.000Z","size":121,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T04:41:34.014Z","etag":null,"topics":["android-library","nvidia","nvidia-shield"],"latest_commit_sha":null,"homepage":"","language":"Java","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/cgutman.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-20T20:44:38.000Z","updated_at":"2023-09-08T18:35:33.000Z","dependencies_parsed_at":"2023-06-06T05:45:48.908Z","dependency_job_id":"a9f4432c-d2e3-4084-be78-8e38ac183492","html_url":"https://github.com/cgutman/ShieldControllerExtensions","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgutman%2FShieldControllerExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgutman%2FShieldControllerExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgutman%2FShieldControllerExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgutman%2FShieldControllerExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgutman","download_url":"https://codeload.github.com/cgutman/ShieldControllerExtensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245398504,"owners_count":20608790,"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":["android-library","nvidia","nvidia-shield"],"created_at":"2024-10-15T01:07:57.898Z","updated_at":"2025-03-25T04:27:16.351Z","avatar_url":"https://github.com/cgutman.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShieldControllerExtensions\n\nThis Android library enables access to rumble and other special functionality on NVIDIA Shield controllers by communicating with the Shield Accessories service included on the NVIDIA Shield Android TV firmware.\n\nThis is required because the NVIDIA Shield Controller does not work with the standard APIs such as `getVibrator()`, `getVibrationManager()`, `getBatteryState()`, etc.\n\n[![](https://jitpack.io/v/cgutman/ShieldControllerExtensions.svg)](https://jitpack.io/#cgutman/ShieldControllerExtensions)\n\n# Getting the library\n\nThe ShieldControllerExtensions library is hosted using [JitPack](https://jitpack.io/).\n\nTo use it, simply add the JitPack repository to your root build.gradle file:\n```gradle\n    allprojects {\n        repositories {\n            maven { url 'https://jitpack.io' }\n        }\n    }\n```\n\nthen add a dependency on the library itself in your app's build.gradle file:\n```gradle\n    dependencies {\n        implementation 'com.github.cgutman:ShieldControllerExtensions:1.0'\n    }\n```\n\n# Usage\n\nThe SceManager class provides the primary interface to the library. It is designed to easily integrate with existing `KeyEvent` and `MotionEvent` processing code because it works exclusively with `InputDevice` references which are easily obtained from such events.\n\n### Instantiating a SceManager\n```java\nsceManager = new SceManager(activity);\nsceManager.start();\n```\n\nYou may add an `SceManager.SceDeviceListener` using `setDeviceListener()` prior to calling `start()`, but this is not required.\n\n### Destroying a SceManager\n```java\nsceManager.stop();\n```\n\n### Listening for device add/remove events\n```java\nsceManager = new SceManager(this);\nsceManager.setDeviceListener(new SceManager.SceDeviceListener() {\n    @Override\n    public void onDeviceAdded(int inputDeviceId) {\n        Log.i(TAG, \"Device added: \" + inputDeviceId);\n    }\n\n    @Override\n    public void onDeviceRemoved(int inputDeviceId) {\n        Log.i(TAG, \"Device removed: \" + inputDeviceId);\n    }\n});\nsceManager.start();\n```\n\nFor your listener to receive the initial `onDeviceAdded()` callbacks for existing devices, it must be registered prior to calling `start()`.\n\n`SceManager.SceDeviceListener` contains support for many additional device state callbacks that can be optionally implemented.\n\n### Determining if an InputDevice is compatible with SceManager APIs\n\n```java\nif (sceManager.isRecognizedDevice(inputDevice)) {\n    // Use SceManager to do something cool\n}\nelse {\n    // This doesn't look like a SHIELD controller\n}\n```\n\n### Rumbling an NVIDIA Shield Controller\n\nThe `rumble()` function provided by `SceManager` behaves similarly to common APIs like `XInputSetState()` or `SDL_GameControllerRumble()`. It takes left and right actuator amplitude in a 0 to 65535 range and rumbles continuously until cancelled by a zero amplitude rumble, or `SceManager.stop()` is called.\n\nThe following code rumbles a Shield Controller for 1 second at maximum amplitude:\n```java\nsceManager.rumble(inputDevice, 65535, 65535);\nThread.sleep(1000);\nsceManager.rumble(inputDevice, 0, 0);\n```\n\nFor a more dynamic example, this `Activity` code will rumble based upon trigger input:\n```java\n    @Override\n    public boolean onGenericMotionEvent(MotionEvent event) {\n        InputDevice device = event.getDevice();\n        if (device != null \u0026\u0026 sceManager.isRecognizedDevice(device)) {\n            float leftTrigger = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);\n            float rightTrigger = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);\n\n            sceManager.rumble(device, (int)(leftTrigger * 65535), (int)(rightTrigger * 65535));\n        }\n\n        return super.onGenericMotionEvent(event);\n    }\n```\n\n### Identifying a device\n\nThe `identify()` function can be used to play a haptic effect or activate some other device-specific method of self-identification.\n\nThe following example triggers identification when the A button is presssed:\n```java\n    @Override\n    public boolean onKeyDown(int keyCode, KeyEvent event) {\n        InputDevice device = event.getDevice();\n        if (device != null \u0026\u0026 sceManager.isRecognizedDevice(device)) {\n            if (keyCode == KeyEvent.KEYCODE_BUTTON_A) {\n                sceManager.identify(device);\n            }\n        }\n\n        return super.onKeyDown(keyCode, event);\n    }\n```\n\n# Code Sample\n\nThis repository includes an [example app](https://github.com/cgutman/ShieldControllerExtensions/blob/main/app/src/main/java/org/cgutman/shieldcontrollerextensionsexample/MainActivity.java) that can be used as a reference for interaction with the library. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgutman%2Fshieldcontrollerextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgutman%2Fshieldcontrollerextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgutman%2Fshieldcontrollerextensions/lists"}