Skip to content

Commit b44feaf

Browse files
committed
docs: update README with features, documentation link, and examples
1 parent 7029898 commit b44feaf

1 file changed

Lines changed: 67 additions & 3 deletions

File tree

README.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,74 @@
11
# evdev
22

3-
Lua bindings for Linux `evdev` input devices and `/dev/uinput` virtual
4-
keyboards, pointers.
3+
Lua bindings for Linux `evdev` input devices and `/dev/uinput` virtual devices
4+
(keyboards, mice, and relative pointers).
55

6-
## Install
6+
Get started with the
7+
[documentation and tutorials](https://bluelua.github.io/evdev).
8+
9+
[![LuaRocks](https://img.shields.io/luarocks/v/BlueLua/bluelua-evdev?color=blue)](https://luarocks.org/modules/BlueLua/bluelua-evdev)
10+
[![License](https://img.shields.io/github/license/BlueLua/evdev?color=lightgrey)](LICENSE)
11+
12+
## 🚀 Features
13+
14+
- **Device Discovery**: List and search for connected input devices by name,
15+
path, or physical location.
16+
- **Event Stream**: Easily read kernel input events with high-resolution
17+
timestamps.
18+
- **Virtual Devices (uinput)**: Emulate any hardware input device (mouse,
19+
keyboard, gamepad) programmatically.
20+
- **Event Selector**: Poll multiple input devices concurrently in a single
21+
non-blocking event loop.
22+
- **Multiple Lua Versions**: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
23+
5.5.
24+
25+
---
26+
27+
## 📦 Installation
28+
29+
Install the library via LuaRocks:
730

831
```bash
932
luarocks install bluelua-evdev
1033
```
34+
35+
## 🛠️ Quick Examples
36+
37+
### Listening to Key Presses
38+
39+
```lua
40+
local evdev = require "evdev"
41+
42+
-- Find and open the primary keyboard
43+
local dev = assert(evdev.device.open("/dev/input/event0"))
44+
print("Opened device: " .. dev.name)
45+
46+
-- Process events in a loop
47+
for event in dev:events() do
48+
if evdev.events.is_press(event) then
49+
print("Key Pressed! Code: " .. event.code)
50+
end
51+
end
52+
```
53+
54+
### Creating a Virtual Keyboard
55+
56+
```lua
57+
local evdev = require "evdev"
58+
local ecodes = evdev.ecodes
59+
60+
-- Create the virtual keyboard
61+
local ui = assert(evdev.uinput.create())
62+
63+
-- Press Shift + A
64+
ui:emit(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 1)
65+
ui:emit(ecodes.EV_KEY, ecodes.KEY_A, 1)
66+
ui:sync()
67+
68+
-- Release Shift + A
69+
ui:emit(ecodes.EV_KEY, ecodes.KEY_A, 0)
70+
ui:emit(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 0)
71+
ui:sync()
72+
73+
ui:close()
74+
```

0 commit comments

Comments
 (0)