{"id":13528901,"url":"https://github.com/electronstudio/sdl2gdx","last_synced_at":"2025-04-02T13:06:52.934Z","repository":{"id":55121242,"uuid":"160011624","full_name":"electronstudio/sdl2gdx","owner":"electronstudio","description":"Java wrapper for SDL and LibGDX controller API","archived":false,"fork":false,"pushed_at":"2024-10-01T18:59:36.000Z","size":126568,"stargazers_count":77,"open_issues_count":12,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T07:07:32.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electronstudio.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":"2018-12-02T03:58:35.000Z","updated_at":"2025-03-14T19:24:17.000Z","dependencies_parsed_at":"2025-01-15T12:14:24.505Z","dependency_job_id":"d919a484-6d07-4d90-9f43-bffd3a9d43c8","html_url":"https://github.com/electronstudio/sdl2gdx","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fsdl2gdx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fsdl2gdx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fsdl2gdx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fsdl2gdx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electronstudio","download_url":"https://codeload.github.com/electronstudio/sdl2gdx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246819774,"owners_count":20839095,"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":[],"created_at":"2024-08-01T07:00:27.806Z","updated_at":"2025-04-02T13:06:52.918Z","avatar_url":"https://github.com/electronstudio.png","language":"Java","funding_links":[],"categories":["Resources"],"sub_categories":["Controllers"],"readme":"# Advert\n\n[RetroWar: 8-bit Party Battle](https://store.steampowered.com/app/664240/RetroWar_8bit_Party_Battle/?git) is out now.  Defeat up to 15 of your friends in a tournament of 80s-inspired retro mini games.\n\n# sdl2gdx (Java SDL \u0026 GDX Controllers)\n\n## What\n\nThis library provides APIs at three layers:\n1. [A Java wrapper around SDL](https://electronstudio.github.io/sdl2gdx/org/libsdl/SDL.html).  Currently we wrap most of Joystick and GameController.  PRs to wrap further APIs are welcome.  This wrapper is as close to the C source as\npossible, so you should be able to port any SDL examples with no changes.\n2. [An OO wrapper](https://electronstudio.github.io/sdl2gdx/org/libsdl/SDL_Joystick.html) on top of layer 1.  The same functions as provided by SDL, but with a class based API to make them more friendly to use.\n3. [An implementation of LibGDX Controller API](https://electronstudio.github.io/sdl2gdx/uk/co/electronstudio/sdl2gdx/SDL2Controller.html) on top of layer 2.  You can slot this straight in to any LibGDX app, or you can use it directly in a non-LibGDX app.\n\nThanks to [Jamepad](https://github.com/williamahartman/Jamepad) by William Harman for providing the basis, native build system and inspiration for this project.\n\n## Why\n\nCompared to the default LibGDX Controller implementation:\n* __Hotplug__ works.\n* Doesn't quit working when the screenmode changes.\n* __Rumble__!\n* Can get more info, such as device power level and XInput Player LED number.\n* Database of __mappings__ for large number of controllers, so you don't have to worry about it.\n* SDL is recommended by Valve as second best way to do input for __Steam__ (after Steam Input of course!)\n* Supports __Nintendo__ and __Sony__ controllers using USB drivers taken from Steam.\n* Supports more than 4 XInput controllers\n\n## How\n\nAdd the repo if you don't have it in your build.gradle already\n\n```diff\nbuildscript{\n    repositories {\n+        jcenter()\n    }\n```\n\n### For a project not using LibGDX\n\n```diff\n    dependencies {\n+       compile \"uk.co.electronstudio.sdl2gdx:sdl2gdx:1.0.+\"\n    }\n}\n```\n\nSee examples and docs below for how to call the API.\n\n\n### For a LibGDX desktop project\n\n```diff\nproject(\":desktop\") {\n    dependencies {\n        implementation \"com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion\"\n        implementation \"com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop\"\n        implementation \"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop\"\n-       implementation \"com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion\"\n-       implementation \"com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop\"\n    }\n}\n\nproject(\":core\") {\n    dependencies {\n        implementation \"com.badlogicgames.gdx:gdx:$gdxVersion\"\n        implementation \"com.badlogicgames.gdx:gdx-box2d:$gdxVersion\"\n        implementation \"com.badlogicgames.gdx:gdx-controllers:$gdxVersion\"\n+       implementation \"uk.co.electronstudio.sdl2gdx:sdl2gdx:1.0.4\"\n    }\n}\n\n```\n\nThis will use SDL under the hood for all your controllers.  That's it, done, with\nno changes to your code!  See [LibGDX docs](https://github.com/libgdx/libgdx/wiki/Controllers) for how to use controllers.\n\nAdding to the core project means you are free to use the additional SDL2 APIs anywhere in your code, but it won't work if\nyou also have html5 or mobile projects.  In that case add sdl2gdx to just the desktop project and not the core project.\n\n[Example LibGDX project](https://github.com/electronstudio/sdl2gdx-test)\n\n### Rumble\n\nWhat if you want to use a feature of SDL that is not supported by the LibGDX Controller API, e.g. rumble?\n\nIf you didn't add sdl2gdx to your core project, you will need instead to create a file `RumbleController.java` in your core project:\n\n```\npackage uk.co.electronstudio.sdl2gdx;\nimport com.badlogic.gdx.controllers.Controller;\n\npublic interface RumbleController extends Controller {\n    boolean rumble(float leftMagnitude, float rightMagnitude, int duration_ms);\n}\n\n```\n\nThen when you want to use rumble, make sure you're on Desktop platform and typecast:\n\n```\nif(Gdx.app.getType() == Application.ApplicationType.Desktop){\n    RumbleController controller = (RumbleController) Controllers.getControllers().get(0);\n    controller.rumble(1.0f,1.0f,500);\n}\n```\n\nYou could also typecast your Controller to SDL2Controller for other features like power level.\n\n## Documentation\n\n* [API docs](https://electronstudio.github.io/sdl2gdx/)\n* [Hotplug CLI example](src/uk/co/electronstudio/sdl2gdx/tests/SDLHotplugTest.java)\n* [GUI example](src/uk/co/electronstudio/sdl2gdx/tests/SDLTest.java)\n\n\n## You might also like\n* [Jamepad](https://github.com/williamahartman/Jamepad) - Alternate API for accessing sdl2gdx\n* [RetroWar-common](https://github.com/electronstudio/retrowar-common) - LibGDX extension library\n* [RetroWar](http://retrowar.net) - My game\n\n## License\n\nsdl2gdx is distributed under the GPL license with the Classpath Exception to allow linking, the same as OpenJDK itself, so you can use it\nanywhere that you use the JDK, for both free and non-free ('closed source') projects.\n\n## Building from source\n\nSee [BUILDING](BUILDING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectronstudio%2Fsdl2gdx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectronstudio%2Fsdl2gdx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectronstudio%2Fsdl2gdx/lists"}