{"id":16188445,"url":"https://github.com/konsumer/nim-gamepad","last_synced_at":"2025-03-19T03:30:41.586Z","repository":{"id":162901691,"uuid":"638127030","full_name":"konsumer/nim-gamepad","owner":"konsumer","description":"Cross-platform gamepad library for nim","archived":false,"fork":false,"pushed_at":"2023-05-13T19:50:53.000Z","size":86,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T14:55:46.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konsumer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-05-09T06:25:01.000Z","updated_at":"2025-01-24T23:09:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"9985b04c-805a-4713-9aef-15502c64bde5","html_url":"https://github.com/konsumer/nim-gamepad","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/konsumer%2Fnim-gamepad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnim-gamepad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnim-gamepad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnim-gamepad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/nim-gamepad/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965768,"owners_count":20375916,"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-10-10T07:26:57.635Z","updated_at":"2025-03-19T03:30:41.267Z","avatar_url":"https://github.com/konsumer.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a simple gamepad library for nim. It's a thin, statically-compiled wrapper for [libstem_gamepad]( https://github.com/ThemsAllTook/libstem_gamepad).\n\nIt should work on Windows, Linux, and Mac.\n\n## installation\n\nAdd this to your .nimble file:\n\n```nim\nrequires \"gamepad \u003e= 0.0.16\"\n```\n\n## usage\n\n```nim\nimport gamepad\nimport os\n\nproc onGamepadAttached(device: ptr GamepadDevice, context: pointer) {.cdecl.} =\n  var js = device[]\n  echo \"attached: \" \u0026 $js.deviceID\n\nproc onGamepadRemoved(device: ptr GamepadDevice, context: pointer) {.cdecl.} =\n  var js = device[]\n  echo \"removed: \" \u0026 $js.deviceID\n\nproc onButtonDown (device: ptr GamepadDevice, buttonID: cuint, timestamp: cdouble, context: pointer) {.cdecl.} =\n  var js = device[]\n  echo \"buttonDown: (\" \u0026 $buttonID \u0026 \")\" \u0026 $js.deviceID\n\nproc onButtonUp (device: ptr GamepadDevice, buttonID: cuint, timestamp: cdouble, context: pointer) {.cdecl.} =\n  var js = device[]\n  echo \"buttonUp: (\" \u0026 $buttonID \u0026 \")\" \u0026 $js.deviceID\n\nproc onAxisMoved (device: ptr GamepadDevice, axisID: cuint, value: cfloat, lastValue: cfloat, timestamp: cdouble, context: pointer) {.cdecl.} =\n  var js = device[]\n  echo \"axis: (\" \u0026 $axisID \u0026 \")\" \u0026 $js.deviceID \u0026 \" - \" \u0026 $value\n\n\nconst GAMEPAD_POLL_ITERATION_INTERVAL=30\n\ngamepad.deviceAttachFunc(onGamepadAttached)\ngamepad.deviceRemoveFunc(onGamepadRemoved)\ngamepad.buttonDownFunc(onButtonDown)\ngamepad.buttonUpFunc(onButtonUp)\ngamepad.axisMoveFunc(onAxisMoved)\ngamepad.init()\n\nvar iterationsToNextPoll = 1\nvar close = false\n\n# do your loop however you like\n# this is a simple example that will cleanup on Ctrl-C\n\nproc handler() {.noconv.} =\n  close = true\n  gamepad.shutdown()\nsetControlCHook(handler)\n\necho \"Press Ctrl-C to exit\"\nwhile not close:\n  sleep(100)\n  gamepad.processEvents()\n  dec iterationsToNextPoll\n  if iterationsToNextPoll == 0:\n    gamepad.detectDevices()\n    iterationsToNextPoll = GAMEPAD_POLL_ITERATION_INTERVAL\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnim-gamepad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Fnim-gamepad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnim-gamepad/lists"}