{"id":16194486,"url":"https://github.com/muniftanjim/lua-evdev","last_synced_at":"2026-02-09T17:01:20.869Z","repository":{"id":45230104,"uuid":"441731638","full_name":"MunifTanjim/lua-evdev","owner":"MunifTanjim","description":"LuaJIT FFI Bindings for libevdev.","archived":false,"fork":false,"pushed_at":"2022-08-27T12:49:40.000Z","size":55,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-24T17:44:59.582Z","etag":null,"topics":["evdev","ffi","libevdev","luajit"],"latest_commit_sha":null,"homepage":"https://luarocks.org/modules/MunifTanjim/lua-evdev","language":"Lua","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/MunifTanjim.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":"2021-12-25T17:59:19.000Z","updated_at":"2023-02-26T11:03:00.000Z","dependencies_parsed_at":"2022-09-05T18:12:18.756Z","dependency_job_id":null,"html_url":"https://github.com/MunifTanjim/lua-evdev","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/MunifTanjim/lua-evdev","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MunifTanjim%2Flua-evdev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MunifTanjim%2Flua-evdev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MunifTanjim%2Flua-evdev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MunifTanjim%2Flua-evdev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MunifTanjim","download_url":"https://codeload.github.com/MunifTanjim/lua-evdev/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MunifTanjim%2Flua-evdev/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29273139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["evdev","ffi","libevdev","luajit"],"created_at":"2024-10-10T08:19:32.672Z","updated_at":"2026-02-09T17:01:20.842Z","avatar_url":"https://github.com/MunifTanjim.png","language":"Lua","readme":"# lua-evdev\n\nLuaJIT FFI Bindings for [`libevdev`](https://gitlab.freedesktop.org/libevdev/libevdev).\n\n## Usage\n\n### Initializing a Device\n\n```lua\nlocal Device = require(\"evdev.device\")\n\n---@param dev Device\nlocal function print_device(dev)\n  local name = dev:name():gsub(\"\\n\", \" | \")\n  print(\"============\", \"===\")\n  print(\"=     Name: \", name)\n  print(\"=     Phys: \", dev:phys())\n  print(\"=     Uniq: \", dev:uniq())\n  print(\"=  Product: \", dev:product_id())\n  print(\"=   Vendor: \", dev:vendor_id())\n  print(\"=  Bustype: \", dev:bustype())\n  print(\"=  Version: \", dev:version())\n  print(\"============\", \"===\")\nend\n\nlocal dev = Device:new(\"/dev/input/event7\")\n\nprint_device(dev)\n```\n\n### Reading Events from a Device\n\n```lua\nlocal Event = require(\"evdev.event\")\nlocal Device = require(\"evdev.device\")\nlocal libevdev = require(\"evdev.libevdev\")\nlocal input = require(\"evdev.linux.input\")\n\nlocal enum = libevdev.enum\nlocal input_constant = input.constant\n\n---@param ev Event\nlocal function print_event(ev)\n  print(string.format(\"{'%s', '%s', %d};\", ev:type_name(), ev:code_name(), ev:value()))\nend\n\n---@param dev Device\n---@param initial_state table\nlocal function events(dev, initial_state)\n  initial_state = initial_state or {}\n\n  if not initial_state.read_flag then\n    initial_state.read_flag = initial_state.read_flag or enum.libevdev_read_flag.NORMAL\n  end\n\n  if not initial_state.should_skip then\n    initial_state.should_skip = function()\n      return false\n    end\n  end\n\n  ---@return Event\n  local function iter(state)\n    local rc, ev = 0, Event:new()\n\n    repeat\n      rc, ev = dev:next_event(state.read_flag, ev)\n      if (rc == enum.libevdev_read_status.SUCCESS) or (rc == enum.libevdev_read_status.SYNC) then\n        if not state.should_skip(ev) then\n          return ev, state\n        end\n      end\n    until rc ~= enum.libevdev_read_status.SUCCESS and rc ~= enum.libevdev_read_status.SYNC and rc ~= -11\n\n    return nil, state\n  end\n\n  return iter, initial_state\nend\n\nlocal dev = Device:new(\"/dev/input/event7\")\n\nlocal initial_state = {\n  ---@param ev Event\n  should_skip = function(ev)\n    ev:is_type(input_constant.EV_KEY)\n  end,\n}\n\nfor ev in events(dev, initial_state) do\n  print_event(ev)\nend\n```\n\n### Initializing a UInputDevice\n\n```lua\nlocal Device = require(\"evdev.device\")\nlocal UIDevice = require(\"evdev.uinput-device\")\n\n---@param uidev UInputDevice\nlocal function print_uinput_device(uidev)\n  print(\"============\", \"===\")\n  print(\"=       FD: \", uidev:fd())\n  print(\"=  SysPath: \", uidev:syspath())\n  print(\"=  DevNode: \", uidev:devnode())\n  print(\"============\", \"===\")\nend\n\nlocal dev = Device:new(\"/dev/input/event7\")\n\nlocal uidev = UIDevice:new(dev)\n\nprint_uinput_device(uidev)\n```\n\n## License\n\nLicensed under the MIT License. Check the [LICENSE](./LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuniftanjim%2Flua-evdev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuniftanjim%2Flua-evdev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuniftanjim%2Flua-evdev/lists"}