Skip to content

Commit fe07f3d

Browse files
committed
docs: update index.md
1 parent c0aed1c commit fe07f3d

3 files changed

Lines changed: 140 additions & 50 deletions

File tree

‎docs/src/evdev/index.md‎

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
1-
# What is evdev?
2-
3-
`evdev` is a Lua module for working with Linux input devices through the evdev
4-
interface.
5-
6-
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
7-
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`.
11-
12-
## Install
1+
# evdev
2+
3+
<p style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem;">
4+
<a href="https://luarocks.org/modules/BlueLua/bluelua-evdev">
5+
<img src="https://img.shields.io/luarocks/v/BlueLua/bluelua-evdev?color=blue&style=flat-square" alt="LuaRocks">
6+
</a>
7+
<a href="https://github.com/BlueLua/evdev/actions/workflows/test.yml">
8+
<img src="https://img.shields.io/github/actions/workflow/status/BlueLua/evdev/test.yml?style=flat-square" alt="Test Status">
9+
</a>
10+
<img src="https://img.shields.io/badge/lua-5.1%20%7C%205.2%20%7C%205.3%20%7C%205.4%20%7C%205.5%20%7C%20LuaJIT-blue?style=flat-square" alt="Lua Versions">
11+
<img src="https://img.shields.io/badge/platform-linux-blue?style=flat-square" alt="Platform">
12+
<a href="https://github.com/BlueLua/evdev/blob/main/LICENSE">
13+
<img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License">
14+
</a>
15+
</p>
16+
17+
`evdev` is a C-backed Lua module for working with Linux input devices through
18+
the [evdev] interface.
19+
20+
## ✨ Features
21+
22+
- **Device Discovery**: List and search for connected input devices by name,
23+
path, or physical location.
24+
- **Event Stream**: Easily read kernel input events with high-resolution
25+
timestamps.
26+
- **Exclusive Grabbing**: Grab a device to prevent its events from reaching
27+
other applications (like desktop environments).
28+
- **Virtual Devices ([uinput])**: Emulate any hardware input device (mouse,
29+
keyboard, gamepad) programmatically.
30+
- **Event Selector**: Poll multiple input devices concurrently in a single
31+
non-blocking event loop.
32+
- **Multiple Lua Versions**: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
33+
5.5.
34+
35+
## 📦 Installation
1336

1437
::: code-group
1538

@@ -19,33 +42,55 @@ luarocks install bluelua-evdev
1942

2043
:::
2144

22-
## Quick Start
45+
## 🚀 Usage
2346

2447
::: code-group
2548

2649
```lua [list-devices.lua]
2750
local evdev = require "evdev"
2851

52+
-- Discover and list all connected devices
2953
local devs = assert(evdev.devices.list_devices())
30-
for _, info in ipairs(devs) do
31-
print(info.path, info.name)
54+
for _, dev in ipairs(devs) do
55+
print(dev.path, dev.name)
3256
end
3357
```
3458

35-
```lua [open-device.lua]
59+
```lua [read-events.lua]
3660
local evdev = require "evdev"
3761

62+
-- Open a specific input device
3863
local dev = assert(evdev.device.open("/dev/input/event3"))
39-
print("opened:", dev.name)
64+
print("Opened device: " .. dev.name)
65+
66+
-- Read event stream
67+
for e in dev:events() do
68+
if e.events.is_press(e) then
69+
print("Key Pressed! Code: " .. e.code)
70+
end
71+
end
4072
```
4173

42-
```lua [read-events.lua]
74+
```lua [virtual-keyboard.lua]
4375
local evdev = require "evdev"
44-
local dev = assert(evdev.device.open("/dev/input/event3"))
76+
local ecodes = evdev.ecodes
4577

46-
for event in dev:events() do
47-
print(event.type, event.code, event.value)
48-
end
78+
-- Create a virtual keyboard device
79+
local ui = assert(evdev.uinput.create())
80+
81+
-- Press and release Shift + A
82+
ui:emit(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 1)
83+
ui:emit(ecodes.EV_KEY, ecodes.KEY_A, 1)
84+
ui:sync()
85+
86+
ui:emit(ecodes.EV_KEY, ecodes.KEY_A, 0)
87+
ui:emit(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 0)
88+
ui:sync()
89+
90+
ui:close()
4991
```
5092

5193
:::
94+
95+
[evdev]: https://www.freedesktop.org/wiki/Software/libevdev/
96+
[uinput]: https://en.wikipedia.org/wiki/Uinput

‎docs/src/timeutil/index.md‎

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
# What is timeutil?
2-
3-
`timeutil` is a C-backed Lua module for wall-clock time, monotonic time, and
4-
blocking sleep.
5-
6-
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
7-
8-
Use `timeutil` to read Unix wall-clock timestamps, measure elapsed monotonic
9-
time without wall-clock jumps, and sleep for fractional-second durations.
10-
11-
## Install
1+
# timeutil
2+
3+
<p style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem;">
4+
<a href="https://luarocks.org/modules/BlueLua/timeutil">
5+
<img src="https://img.shields.io/luarocks/v/BlueLua/timeutil?color=blue&style=flat-square" alt="LuaRocks">
6+
</a>
7+
<a href="https://github.com/BlueLua/timeutil/actions/workflows/test.yml">
8+
<img src="https://img.shields.io/github/actions/workflow/status/BlueLua/timeutil/test.yml?style=flat-square" alt="Test Status">
9+
</a>
10+
<img src="https://img.shields.io/badge/lua-5.1%20%7C%205.2%20%7C%205.3%20%7C%205.4%20%7C%205.5%20%7C%20LuaJIT-blue?style=flat-square" alt="Lua Versions">
11+
<img src="https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square" alt="Platform">
12+
<a href="https://github.com/BlueLua/timeutil/blob/main/LICENSE">
13+
<img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License">
14+
</a>
15+
</p>
16+
17+
`timeutil` is a high-performance C-backed Lua module providing precision
18+
wall-clock time, monotonic time, and sleep utilities.
19+
20+
## ✨ Features
21+
22+
- **Monotonic Clock**: Measure precise intervals unaffected by [NTP] syncs or
23+
system clock shifts.
24+
- **Wall-Clock Time**: Fetch system real-time with sub-microsecond precision.
25+
- **Fractional Sleep**: Put the execution thread to sleep for fractional seconds
26+
without high CPU utilization.
27+
- **Multiple Lua Versions**: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
28+
5.5.
29+
30+
## 📦 Installation
1231

1332
::: code-group
1433

@@ -18,19 +37,22 @@ luarocks install timeutil
1837

1938
:::
2039

21-
## Quick Start
40+
## 🚀 Usage
2241

2342
::: code-group
2443

2544
```lua [example.lua]
2645
local time = require "timeutil"
2746

47+
-- Measure precise elapsed time
2848
local start = time.mono()
29-
time.sleep(0.05)
49+
time.sleep(0.05) -- sleep for 50ms
3050
local elapsed = time.mono() - start
3151

32-
print(("elapsed: %.3fs"):format(elapsed))
33-
print(("now: %.3f"):format(time.now()))
52+
print(string.format("Elapsed: %.6f seconds", elapsed))
53+
print(string.format("Current Unix timestamp: %.6f", time.now()))
3454
```
3555

3656
:::
57+
58+
[NTP]: https://en.wikipedia.org/wiki/Network_Time_Protocol

‎docs/src/tty/index.md‎

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
# What is tty?
2-
3-
`tty` provides small cross-platform Lua bindings for terminal inspection.
4-
5-
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
6-
7-
Use `tty` to detect whether streams, file handles, or file descriptors are
8-
attached to a terminal, and to read terminal rows and columns for CLI output.
9-
10-
## Install
1+
# tty
2+
3+
<p style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem;">
4+
<a href="https://luarocks.org/modules/BlueLua/tty">
5+
<img src="https://img.shields.io/luarocks/v/BlueLua/tty?color=blue&style=flat-square" alt="LuaRocks">
6+
</a>
7+
<a href="https://github.com/BlueLua/tty/actions/workflows/test.yml">
8+
<img src="https://img.shields.io/github/actions/workflow/status/BlueLua/tty/test.yml?style=flat-square" alt="Test Status">
9+
</a>
10+
<img src="https://img.shields.io/badge/lua-5.1%20%7C%205.2%20%7C%205.3%20%7C%205.4%20%7C%205.5%20%7C%20LuaJIT-blue?style=flat-square" alt="Lua Versions">
11+
<img src="https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square" alt="Platform">
12+
<a href="https://github.com/BlueLua/tty/blob/main/LICENSE">
13+
<img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License">
14+
</a>
15+
</p>
16+
17+
`[tty]` provides lightweight, cross-platform C-backed Lua bindings for terminal
18+
detection and terminal size inspection.
19+
20+
## ✨ Features
21+
22+
- **TTY Verification**: Check if a Lua file handle (like `io.stdout`,
23+
`io.stdin`), standard stream, or raw [file descriptor] is interactive.
24+
- **Window Dimension Query**: Retrieve the current width (columns) and height
25+
(rows) of the active terminal dynamically.
26+
- **Multiple Lua Versions**: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
27+
5.5.
28+
29+
## 📦 Installation
1130

1231
::: code-group
1332

@@ -17,19 +36,23 @@ luarocks install tty
1736

1837
:::
1938

20-
## Quick Start
39+
## 🚀 Usage
2140

2241
::: code-group
2342

2443
```lua [example.lua]
2544
local tty = require "tty"
2645

46+
-- Check if standard output is a TTY
2747
if tty.isatty(io.stdout) then
2848
local rows, cols = tty.size()
29-
print(("terminal: %dx%d"):format(cols, rows))
49+
print(string.format("Terminal size: %dx%d", cols, rows))
3050
else
31-
print("stdout is redirected")
51+
print("Output is redirected")
3252
end
3353
```
3454

3555
:::
56+
57+
[tty]: https://en.wikipedia.org/wiki/Tty_(Unix)
58+
[file descriptor]: https://en.wikipedia.org/wiki/File_descriptor

0 commit comments

Comments
 (0)