1717---
1818--- Create and control virtual input devices using `/dev/uinput`.
1919---
20+ --- ## Usage
21+ ---
2022--- ```lua
2123--- local evdev = require "evdev"
24+ ---
2225--- local ecodes = evdev.ecodes
26+ --- local UInput = evdev.uinput.create
2327---
2428---- - Create a virtual keyboard device
25- --- local ui = assert(evdev.uinput.create ())
29+ --- local ui = assert(UInput ())
2630--- print("Virtual device created at: " .. ui.path)
2731---
2832---- - Simulate typing Shift + A
@@ -44,7 +48,6 @@ local M = {}
4448--- Create a virtual input device.
4549---
4650--- ```lua
47- --- local UInput = evdev.uinput.create
4851--- local ui = assert(UInput())
4952---
5053--- ui:emit(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_A, 1)
@@ -85,7 +88,6 @@ local UInput = {}
8588--- Get the file descriptor of the virtual device.
8689---
8790--- ```lua
88- --- local UInput = evdev.uinput.create
8991--- local ui = assert(UInput())
9092--- print(ui:fd())
9193--- ```
@@ -97,7 +99,6 @@ function UInput:fd() end
9799--- Destroy and close the virtual device.
98100---
99101--- ```lua
100- --- local UInput = evdev.uinput.create
101102--- local ui = assert(UInput())
102103--- ui:close()
103104--- ```
@@ -110,9 +111,7 @@ function UInput:close() end
110111--- Return whether the virtual device is still open.
111112---
112113--- ```lua
113- --- local UInput = evdev.uinput.create
114114--- local ui = assert(UInput())
115- ---
116115--- if ui:is_open() then
117116--- ui:close()
118117--- end
@@ -126,7 +125,6 @@ function UInput:is_open() end
126125--- Emit one raw input event.
127126---
128127--- ```lua
129- --- local UInput = evdev.uinput.create
130128--- local ui = assert(UInput())
131129---
132130--- local EV_KEY = evdev.ecodes.EV_KEY
@@ -153,9 +151,7 @@ function UInput:emit(type, code, value) end
153151--- Flush queued input events as one frame.
154152---
155153--- ```lua
156- --- local UInput = evdev.uinput.create
157154--- local ui = assert(UInput())
158- ---
159155--- ui:emit(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_LEFTSHIFT, 0)
160156--- ui:sync()
161157--- ```
@@ -168,9 +164,7 @@ function UInput:sync() end
168164--- Set the keyboard repeat rate on the virtual device.
169165---
170166--- ```lua
171- --- local UInput = evdev.uinput.create
172167--- local ui = assert(UInput())
173- ---
174168---- - Set repeat delay to 500ms, repeat period to 50ms
175169--- ui:set_repeat(500, 50)
176170--- ```
@@ -185,9 +179,7 @@ function UInput:set_repeat(delay, period) end
185179--- Get the current keyboard repeat rate from the virtual device.
186180---
187181--- ```lua
188- --- local UInput = evdev.uinput.create
189182--- local ui = assert(UInput())
190- ---
191183--- local delay, period, err = ui:get_repeat()
192184--- assert(delay, err)
193185--- print(delay, period)
0 commit comments