{"id":37029983,"url":"https://github.com/libgdx/jamepad","last_synced_at":"2026-01-14T03:38:11.257Z","repository":{"id":44952004,"uuid":"293573164","full_name":"libgdx/Jamepad","owner":"libgdx","description":"A better way to use gamepads in Java","archived":false,"fork":true,"pushed_at":"2024-12-18T16:44:12.000Z","size":80327,"stargazers_count":21,"open_issues_count":3,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-18T17:40:42.706Z","etag":null,"topics":["gamecontroller-framework","gamepad","java","sdl2"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MrStahlfelge/Jamepad","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libgdx.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":"2020-09-07T16:04:18.000Z","updated_at":"2024-12-18T16:44:16.000Z","dependencies_parsed_at":"2023-01-16T16:45:24.382Z","dependency_job_id":null,"html_url":"https://github.com/libgdx/Jamepad","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/libgdx/Jamepad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgdx%2FJamepad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgdx%2FJamepad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgdx%2FJamepad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgdx%2FJamepad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libgdx","download_url":"https://codeload.github.com/libgdx/Jamepad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgdx%2FJamepad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["gamecontroller-framework","gamepad","java","sdl2"],"created_at":"2026-01-14T03:38:10.507Z","updated_at":"2026-01-14T03:38:11.243Z","avatar_url":"https://github.com/libgdx.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jamepad Fork\n\n#### A better way to use gamepads in Java.\n\n*This is a fork of and based on the [original work by William Hartman](https://github.com/williamahartman/Jamepad/tree/ae170a95eb7c14d82b19328480b1ab5a45b77001)*.\n\nJamepad is a library for using gamepads in Java. It's based on SDL2 ([here](https://www.libsdl.org/)) and uses jnigen ([more info here](https://libgdx.com/wiki/utils/jnigen)). We also use [this](https://github.com/gabomdq/SDL_GameControllerDB) really nice database of gamepad mappings.\n\nJamepad has:\n  - One library that supports all platforms (Windows, OSX, and Linux)\n  - XInput support on Windows for full Xbox 360 controller support.\n  - Support for plugging/unplugging controllers at runtime.\n  - Support for rumble\n  - Button/Axis mappings for popular controllers.\n  - A permissive license (see below).\n\nThis fork improved the following points compared to last real [Jamepad version 1.3.2](https://github.com/williamahartman/Jamepad/tree/ae170a95eb7c14d82b19328480b1ab5a45b77001):\n* This fork builts the native library on Github Actions. You can see all the magic happen there. Moreover, if you fork this repo and adjust settings, you are immediately ready to go with your own build! We are open for PRs though.\n* New features added, newer SDL version used\n* Natives are smaller in size\n* Natives for arm architecture included\n\n#### Stuff You Should Know About Jamepad\n\n- On Windows (only 7 and up were tested), no special dependencies are needed.\n- On Linux, runtime dependencies are: libevdev, libudev (normally included)\n- On OS X, no special dependencies are needed\n\n#### Current Limitations\n- The order of gamepads on Windows is not necessarily the order they were plugged in. XInput controllers will always appear before DirectInput controllers, regardless of when they were plugged in. This means that the player numbers associated with each controller can change unexpectedly if XInput controllers are plugged in or disconnected while DirectInput controllers are present.\n- If using getState() in ControllerManager, a new ControllerState is instantiated on each call. For some games, this could pose a problem.\n\n\n\n## Using Jamepad\n\nFor usage within libgdx project, take a look at [gdx-controllers](https://github.com/libgdx/gdx-controllers).\nThe following information is only needed for non-gdx Java projects.\n\n### Getting Jamepad\n\n[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/com.badlogicgames.jamepad/jamepad?nexusVersion=2\u0026server=https%3A%2F%2Foss.sonatype.org\u0026label=release)](https://search.maven.org/artifact/com.badlogicgames.jamepad/jamepad)\n[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/com.badlogicgames.jamepad/jamepad?server=https%3A%2F%2Foss.sonatype.org\u0026label=snapshot)](https://oss.sonatype.org/#nexus-search;gav~com.badlogicgames.jamepad~jamepad)\n\n##### gradle\nIf you use gradle, you can pull this package in from Maven Central.\nAdd this line to your dependencies section. Update the version number to whatever the latest release is.\n````\ndependencies {\n  ...\n  compile 'com.badlogicgames.jamepad:jamepad:2.0.14.0'\n}\n````\n##### maven\nIf you use gradle, you can pull this package in from Maven Central.\nAdd this line to your dependencies section. Update the version number to whatever the latest release is.\n````\n\u003cdependencies\u003e\n    ...\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.badlogicgames.jamepad\u003c/groupId\u003e\n        \u003cartifactId\u003ejamepad\u003c/artifactId\u003e\n        \u003cversion\u003e2.0.14.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n````\n\n#### Using Jamepad\nThere are two main ways to use Jamepad. Both rely on a ControllerManager Object.\n\n```java\nControllerManager controllers = new ControllerManager();\ncontrollers.initSDLGamepad();\n```\n\nFor most applications, using the getState() method in ControllerManager is best. This method returns an immutable ControllerState object that describes the state of the controller at the instant the method is called. Using this method, you don't need to litter code with a bunch of exceoption handling or handle the possiblity of controller disconnections at weird times. \n\nIf a controller is disconnected, the returned ControllerState object has the isConnected field set to false. All other fields are either false (for buttons) or 0 (for axes).\n\nHere's a simple example:\n\n```java\n//Print a message when the \"A\" button is pressed. Exit if the \"B\" button is pressed \n//or the controller disconnects.\nwhile(true) {\n  ControllerState currState = controllers.getState(0);\n  \n  if(!currState.isConnected || currState.b) {\n    break;\n  }\n  if(currState.a) {\n    System.out.println(\"\\\"A\\\" on \\\"\" + currState.controllerType + \"\\\" is pressed\");\n  }\n}\n```\n\nFor a select few applications, getState() might not be the best decision. Since ControllerState is immutable, a new one is instantiated on each call to getState(). This should be fine for normal desktop JVMs; both Oracle's JVM and the OpenJDK one should absolutely be able to handle this. What problems do come up could probably be solved with some GC tuning.\n\nIf these allocations do end up being an actual problem, you can access the internal representation of the controllers. This is more complicated to use, and you might need to deal with some exceptions.\n\nHere's a pretty barebones example:\n\n```java\n//Print a message when the \"A\" button is pressed. Exit if the \"B\" button is pressed \n//or the controller disconnects.\nControllerIndex currController = controllers.getControllerIndex(0);\n\nwhile(true) {\n  controllers.update(); //If using ControllerIndex, you should call update() to check if a new controller\n                        //was plugged in or unplugged at this index.\n  try {\n    if(currController.isButtonPressed(ControllerButton.A)) {\n      System.out.println(\"\\\"A\\\" on \\\"\" + currController.getName() + \"\\\" is pressed\");\n    }\n    if(currController.isButtonPressed(ControllerButton.B)) {\n      break;\n    }\n  } catch (ControllerUnpluggedException e) {   \n    break;\n  }\n}\n```\n\nWhen you're finished with your gamepad stuff, you should call quitSDLGamepad() to free the native library.\n\n```java\ncontrollers.quitSDLGamepad();\n```\n\n## Building Jamepad\n\nSee [BUILDING](BUILDING.md)\n\n## License\n\nThe original work by William Hartman is licensed under the permissive zLib license.\nYou can include this use this library in proprietary projects without sharing source, and you are allowed to alter the project.\nThe original license is kept [here](LICENSE_hartman.txt).\n\nlibSDL 2.0 is [zLib licensed](https://libsdl.org/license.php), too.\n\nEvery work done in this fork is licensed under Apache 2 License conditions, see LICENSE file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibgdx%2Fjamepad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibgdx%2Fjamepad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibgdx%2Fjamepad/lists"}