{"id":16168516,"url":"https://github.com/alex-spataru/qjoysticks","last_synced_at":"2025-04-21T11:33:29.120Z","repository":{"id":49762127,"uuid":"60373832","full_name":"alex-spataru/QJoysticks","owner":"alex-spataru","description":"Joystick input library for Qt","archived":false,"fork":false,"pushed_at":"2024-08-03T21:04:23.000Z","size":6603,"stargazers_count":97,"open_issues_count":6,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T12:54:35.669Z","etag":null,"topics":["cpp","cross-platform","joystick","keyboard","qml","sdl"],"latest_commit_sha":null,"homepage":"","language":"C","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/alex-spataru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-06-03T19:52:14.000Z","updated_at":"2025-03-29T14:59:32.000Z","dependencies_parsed_at":"2024-01-14T11:13:13.064Z","dependency_job_id":"ac5058de-8ab5-4bc4-93d2-2ca0bd955e6f","html_url":"https://github.com/alex-spataru/QJoysticks","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/alex-spataru%2FQJoysticks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-spataru%2FQJoysticks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-spataru%2FQJoysticks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-spataru%2FQJoysticks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alex-spataru","download_url":"https://codeload.github.com/alex-spataru/QJoysticks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250048101,"owners_count":21366176,"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":["cpp","cross-platform","joystick","keyboard","qml","sdl"],"created_at":"2024-10-10T03:12:01.527Z","updated_at":"2025-04-21T11:33:28.023Z","avatar_url":"https://github.com/alex-spataru.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QJoysticks library\n\nThe QJoysticks library allows your Qt application to read input from both real joysticks/gamepads (using SDL) and a virtual joystick (using the keyboard).\n\nSDL binaries and headers for Windows and OS X are already included in this library. Linux uses will need to install libsdl2-dev using the package manager of their distro of choice.\n\nOnline documentation can be found [here](http://frc-utilities.github.io/documentation/qjoysticks/).\n\n![Screenshot](/examples/JoystickList/screenshot.png)\n\n## Integrating QJoysticks with your projects\n1. Copy this folder in your \"3rd-party\" folder.\n2. Include the QJoysticks project include (*pri*) file using the include() function.\n3. That's all! Check the [example project](#example-project) as a reference for your project.\n\n### Note for Windows users\n\nIn some cases, SDL will redefine the *main()* function, which may cause compilation problems.\nIn order to fix this, you may need to use [this ugly hack](/examples/JoystickList/main.cpp#L31).\n\n## QML compatibility\nThis library can be used from QML, just register it as a context property when initializing your QML engine (check the [example](#example-project) for more information).\n\n## Example Project\nI have created a [simple example](/examples/JoystickList) with QML, in which the user can select a joystick and see live feedback from each joystick axis, button and POV.\n\n## WTFs Section\n\n### 1. What are the joystick IDs and how are they assigned?\n\nEach joystick has an numerical ID, which is used by the library and you to access joystick information. The ID is assigned based on the order in which a joystick was attached. Joystick IDs are always congruent to the lists returned by the following functions:\n\n```c++\nQStringList joystickNames = QJoysticks::getInstance()-\u003edeviceNames();\nQList\u003cQJoystickDevice*\u003e joysticks = QJoysticks::getInstance()-\u003einputDevices();\n```\n\n**NOTE:** The virtual joystick will always be the last joystick to be registered, in other words, it will always have the greatest numerical ID.\n\n### 2. What is the virtual joystick?\n\nThe virtual joystick uses your computer keyboard to generate axis, button and POV events. The keyboard mappings are:\n\n| Keyboard Keys       | Joystick Mappings |\n|---------------------|-------------------|\n| W,A,S,D             | Left Stick        |\n| I,J,K,L             | Right Stick       |\n| Arrow Keys          | POV hat           |\n| Q,E                 | Left Trigger      |\n| U,O                 | Right Trigger     |\n| 0,1,2,3,4,5,6,7,8,9 | Joystick Buttons  |\n\n**NOTE:** For the moment, I have not implemented support for custom mappings.\n\nThe virtual joystick can be enabled or disabled with the following function:\n\n```c++\n// Enable the virtual joystick\nQJoysticks::getInstance()-\u003esetVirtualJoystickEnabled (true);\n\n// Disable the virtual joystick\nQJoysticks::getInstance()-\u003esetVirtualJoystickEnabled (false);\n```\n\n### 3. How are joystick events reported?\n\nThe QJosyticks library reports joystick events with the following signals:\n\n```c++\n// Only for C++ applications\nvoid POVEvent (const QJoystickPOVEvent\u0026 event);\nvoid axisEvent (const QJoystickAxisEvent\u0026 event);\nvoid buttonEvent (const QJoystickButtonEvent\u0026 event);\n\n// For C++ applications \u0026 QML applications\nvoid povChanged (const int js, const int pov, const int angle);\nvoid axisChanged (const int js, const int axis, const double value);\nvoid buttonChanged (const int js, const int button, const bool pressed);\n```\n\nFor more info regarding the C++ only signals, check this [file](/src/QJoysticks/JoysticksCommon.h).\n\n### 3. How are axis values reported?\n\nThis library reports an axis value with a range from -1.0 to 1.0 (with 0.0 being neutral).\nYou can customize the axis range of the virtual joystick with the following function:\n\n```c++\nQJoysticks::getInstance()-\u003esetVirtualJoystickAxisRange (0.8);\n```\n\nYou cannot customize the axis range of the SDL joysticks.\n\n## License\nThis project is licensed under the MIT license. For more information, check the [LICENSE](LICENSE.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-spataru%2Fqjoysticks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falex-spataru%2Fqjoysticks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-spataru%2Fqjoysticks/lists"}