Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions docs/api/device.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ One Linux input event returned by `Device:read()`.
| [`flush()`](#fn-flush) | Drain queued events and return how many were discarded. |
| [`get_repeat()`](#fn-get-repeat) | Return the current auto-repeat delay and period in milliseconds. |
| [`grab()`](#fn-grab) | Take exclusive control of the input device. |
| [`is_device(value)`](#fn-is-device) | Return whether a value is an `evdev.Device` instance. |
| [`is_device(value)`](#fn-is-device) | Return whether a value is an [`evdev.Device`] instance. |
| [`is_open()`](#fn-is-open) | Return whether this device handle still has an open file descriptor. |
| [`open(path)`](#fn-open) | Open an input device by path. |
| [`poll()`](#fn-poll) | Wait in the kernel until this device has input available. |
Expand Down Expand Up @@ -76,7 +76,7 @@ Return the underlying Linux file descriptor.

**Return**:

- `fd` (`evdev.fd?`): Linux file descriptor.
- `fd` ([`evdev.fd`]`?`): Linux file descriptor.

**Example**:

Expand Down Expand Up @@ -161,7 +161,7 @@ assert(dev:grab())

### `is_device(value)`

Return whether a value is an `evdev.Device` instance.
Return whether a value is an [`evdev.Device`] instance.

**Parameters**:

Expand Down Expand Up @@ -211,11 +211,11 @@ Open an input device by path.

**Parameters**:

- `path` (`evdev.path`)
- `path` ([`evdev.path`])

**Return**:

- `dev` (`evdev.Device?`): Open input device.
- `dev` ([`evdev.Device`]`?`): Open input device.
- `err` (`string?`): Error message on failure.

**Example**:
Expand Down Expand Up @@ -266,7 +266,7 @@ Read one input event. Returns `nil` when no event is queued.

**Return**:

- `event` (`evdev.event?`): Next queued input event.
- `event` ([`evdev.event`]`?`): Next queued input event.
- `err` (`string?`): Error message on failure.

**Example**:
Expand Down Expand Up @@ -335,3 +335,12 @@ local dev = assert(Device("/dev/input/eventX"))
assert(dev:grab())
assert(dev:ungrab())
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`evdev.Device`]: /evdev/api/device.html
[`evdev.event`]: /evdev/types.html#evdev-event
[`evdev.fd`]: /evdev/types.html#evdev-fd
[`evdev.path`]: /evdev/types.html#evdev-path
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
17 changes: 12 additions & 5 deletions docs/api/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Read metadata for one input device by path.

**Parameters**:

- `path` (`evdev.path`)
- `path` ([`evdev.path`])

**Return**:

- `info` (`evdev.deviceInfo?`)
- `info` ([`evdev.deviceInfo`]`?`)
- `err` (`string?`)

**Example**:
Expand All @@ -54,7 +54,7 @@ Return the first discovered input device matching a path or a device name.

**Return**:

- `dev` (`evdev.deviceInfo?`)
- `dev` ([`evdev.deviceInfo`]`?`)
- `err` (`string?`)

**Example**:
Expand Down Expand Up @@ -86,7 +86,7 @@ Return all discovered input devices matching a path, alias, or device name.

**Return**:

- `devs` (`evdev.deviceInfo[]?`)
- `devs` ([`evdev.deviceInfo`]`[]?`)
- `err` (`string?`)

**Example**:
Expand All @@ -113,7 +113,7 @@ List evdev input devices under `/dev/input`.

**Return**:

- `devs` (`evdev.deviceInfo[]?`)
- `devs` ([`evdev.deviceInfo`]`[]?`)
- `err` (`string?`)

**Example**:
Expand All @@ -124,3 +124,10 @@ for _, dev in ipairs(devs) do
print(dev.path, dev.name)
end
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`evdev.deviceInfo`]: /evdev/types.html#evdev-deviceinfo
[`evdev.path`]: /evdev/types.html#evdev-path
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
20 changes: 13 additions & 7 deletions docs/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Return whether an event has type `EV_ABS`.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -57,7 +57,7 @@ Return whether an event has type `EV_KEY`.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -78,7 +78,7 @@ Return whether an event is a key/button press.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -99,7 +99,7 @@ Return whether an event has type `EV_REL`.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -120,7 +120,7 @@ Return whether an event is a key/button release.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -141,7 +141,7 @@ Return whether an event is a key repeat.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -162,7 +162,7 @@ Return whether an event has type `EV_SYN`.

**Parameters**:

- `event` (`evdev.event`)
- `event` ([`evdev.event`])

**Return**:

Expand All @@ -174,3 +174,9 @@ Return whether an event has type `EV_SYN`.
local e = { type = evdev.ecodes.EV_SYN }
print(evdev.events.is_syn(e)) --> true
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`evdev.event`]: /evdev/types.html#evdev-event
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
67 changes: 37 additions & 30 deletions docs/api/selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,39 @@ Selector for polling and reading from multiple devices.

| Function | Description |
| ------------------------------ | -------------------------------------------------------------- |
| [`new(devices?)`](#fn-new) | Create a selector from an optional list of devices. |
| [`add(device)`](#fn-add) | Add a device to this selector. |
| [`clear()`](#fn-clear) | Remove all devices from this selector. |
| [`events()`](#fn-events) | Return an iterator that yields events from registered devices. |
| [`new(devices?)`](#fn-new) | Create a selector from an optional list of devices. |
| [`poll()`](#fn-poll) | Wait until at least one registered device has input available. |
| [`remove(device)`](#fn-remove) | Remove a device from this selector. |

<a id="fn-new"></a>

### `new(devices?)`

Create a selector from an optional list of devices.

**Parameters**:

- `devices?` ([`evdev.Device`]`[]`)

**Return**:

- **value** ([`evdev.Selector`])

**Example**:

```lua
local evdev = require "evdev"
local Device = evdev.device.open
local Selector = evdev.selector.new

local kb1 = assert(Device("/dev/input/event5"))
local kb2 = assert(Device("/dev/input/event10"))
local sel = Selector({ kb1, kb2 })
```

<a id="fn-add"></a>

### `add(device)`
Expand All @@ -24,7 +50,7 @@ Add a device to this selector.

**Parameters**:

- `device` (`evdev.Device`)
- `device` ([`evdev.Device`])

**Return**:

Expand Down Expand Up @@ -91,32 +117,6 @@ for dev, e in sel:events() do
end
```

<a id="fn-new"></a>

### `new(devices?)`

Create a selector from an optional list of devices.

**Parameters**:

- `devices?` (`evdev.Device[]`)

**Return**:

- **value** (`evdev.Selector`)

**Example**:

```lua
local evdev = require "evdev"
local Device = evdev.device.open
local Selector = evdev.selector.new

local kb1 = assert(Device("/dev/input/event5"))
local kb2 = assert(Device("/dev/input/event10"))
local sel = Selector({ kb1, kb2 })
```

<a id="fn-poll"></a>

### `poll()`
Expand All @@ -125,7 +125,7 @@ Wait until at least one registered device has input available.

**Return**:

- `devs` (`evdev.Device[]?`)
- `devs` ([`evdev.Device`]`[]?`)
- `err` (`string?`)

**Example**:
Expand All @@ -151,7 +151,7 @@ Remove a device from this selector.

**Parameters**:

- `device` (`evdev.Device`)
- `device` ([`evdev.Device`])

**Return**:

Expand All @@ -169,3 +169,10 @@ local sel = Selector({ kb1, kb2 })

sel:remove(kb2)
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`evdev.Device`]: /evdev/api/device.html
[`evdev.Selector`]: /evdev/api/selector.html
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
27 changes: 20 additions & 7 deletions docs/api/uinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Create a virtual input device.

**Parameters**:

- `spec?` (`evdev.uinputSpec`): Virtual device configuration.
- `spec?` ([`evdev.uinputSpec`]): Virtual device configuration.

**Return**:

- `dev` (`evdev.UInput?`): Open virtual device.
- `dev` ([`evdev.UInput`]`?`): Open virtual device.
- `err` (`string?`): Error message on failure.

**Example**:
Expand All @@ -73,10 +73,10 @@ Emit one raw input event.

**Parameters**:

- `type` (`evdev.ecodes.ev`): Event type to emit.
- `code` (`evdev.ecodes.key|evdev.ecodes.btn|evdev.ecodes.rel`): Event code
within the selected type.
- `value` (`evdev.eventValue`): Event value to send.
- `type` ([`evdev.ecodes.ev`]): Event type to emit.
- `code` ([`evdev.ecodes.key`] | [`evdev.ecodes.btn`] | [`evdev.ecodes.rel`]):
Event code within the selected type.
- `value` ([`evdev.eventValue`]): Event value to send.

**Return**:

Expand Down Expand Up @@ -108,7 +108,7 @@ Get the file descriptor of the virtual device.

**Return**:

- `fd` (`evdev.fd?`): Linux file descriptor.
- `fd` ([`evdev.fd`]`?`): Linux file descriptor.

**Example**:

Expand Down Expand Up @@ -210,3 +210,16 @@ local ui = assert(UInput())
ui:emit(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_LEFTSHIFT, 0)
ui:sync()
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`evdev.UInput`]: /evdev/api/uinput.html
[`evdev.ecodes.btn`]: /evdev/api/ecodes.html
[`evdev.ecodes.ev`]: /evdev/api/ecodes.html
[`evdev.ecodes.key`]: /evdev/api/ecodes.html
[`evdev.ecodes.rel`]: /evdev/api/ecodes.html
[`evdev.eventValue`]: /evdev/types.html#evdev-eventvalue
[`evdev.fd`]: /evdev/types.html#evdev-fd
[`evdev.uinputSpec`]: /evdev/types.html#evdev-uinputspec
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
Loading