Skip to content

Commit c8e833a

Browse files
authored
docs(evdev): update evdev documentation with compatibility and examples
Expanded documentation on evdev module usage and compatibility.
1 parent 01f8a94 commit c8e833a

1 file changed

Lines changed: 40 additions & 16 deletions

File tree

docs/src/evdev/index.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,48 @@
33
`evdev` is a Lua module for working with Linux input devices through the evdev
44
interface.
55

6-
It lets Lua discover Linux input devices, read raw events, grab devices, and
7-
create virtual input devices with uinput.
6+
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
87

9-
## Compatibility
8+
Use `evdev` to read events from keyboards, mice, gamepads, and other
9+
`/dev/input` devices, grab a device while handling input yourself, or create
10+
virtual keyboards, mice, and controllers through `/dev/uinput`.
1011

11-
`evdev` supports:
12+
## Install
1213

13-
- Lua 5.1
14-
- Lua 5.2
15-
- Lua 5.3
16-
- Lua 5.4
17-
- Lua 5.5
18-
- LuaJIT
14+
::: code-group
1915

20-
## Use Cases
16+
```sh [LuaRocks]
17+
luarocks install bluelua-evdev
18+
```
2119

22-
- Build input automation tools.
23-
- Read keyboard, mouse, gamepad, and other Linux input events from Lua.
24-
- Inspect devices under `/dev/input`.
25-
- Grab a device while handling input yourself.
26-
- Create virtual keyboards, mice, or controllers for tests and tooling.
20+
:::
21+
22+
## Quick Start
23+
24+
::: code-group
25+
26+
```lua [lis-devices.lua]
27+
local evdev = require "evdev"
28+
29+
for _, info in ipairs(devices) do
30+
print(info.path, info.name)
31+
end
32+
```
33+
34+
```lua [open-device.lua]
35+
local evdev = require "evdev"
36+
37+
local dev = assert(evdev.device("/dev/input/event3"))
38+
print("opened:", dev.name)
39+
```
40+
41+
```lua [read-events.lua]
42+
local evdev = require "evdev"
43+
local dev = assert(evdev.device("/dev/input/event3"))
44+
45+
for event in dev:events() do
46+
print(event.type, event.code, event.value)
47+
end
48+
```
49+
50+
:::

0 commit comments

Comments
 (0)