@@ -8,13 +8,16 @@ Configuration used to create a `/dev/uinput` virtual device.
88
99## Functions
1010
11- | Function | Description |
12- | ------------------------------------- | ------------------------------------------------ |
13- | [ ` close() ` ] ( #fn-close ) | Destroy and close the virtual device. |
14- | [ ` create(spec?) ` ] ( #fn-create ) | Create a virtual input device. |
15- | [ ` emit(type, code, value) ` ] ( #fn-emit ) | Emit one raw input event. |
16- | [ ` is_open() ` ] ( #fn-is-open ) | Return whether the virtual device is still open. |
17- | [ ` sync() ` ] ( #fn-sync ) | Emit a ` SYN_REPORT ` event. |
11+ | Function | Description |
12+ | --------------------------------------------- | ------------------------------------------------------------- |
13+ | [ ` close() ` ] ( #fn-close ) | Destroy and close the virtual device. |
14+ | [ ` create(spec?) ` ] ( #fn-create ) | Create a virtual input device. |
15+ | [ ` emit(type, code, value) ` ] ( #fn-emit ) | Emit one raw input event. |
16+ | [ ` fd() ` ] ( #fn-fd ) | Get the file descriptor of the virtual device. |
17+ | [ ` get_repeat() ` ] ( #fn-get-repeat ) | Get the current keyboard repeat rate from the virtual device. |
18+ | [ ` is_open() ` ] ( #fn-is-open ) | Return whether the virtual device is still open. |
19+ | [ ` set_repeat(delay, period) ` ] ( #fn-set-repeat ) | Set the keyboard repeat rate on the virtual device. |
20+ | [ ` sync() ` ] ( #fn-sync ) | Emit a ` SYN_REPORT ` event. |
1821
1922<a id =" fn-close " ></a >
2023
@@ -56,10 +59,6 @@ Create a virtual input device.
5659local UInput = evdev .uinput .create
5760local ui = assert (UInput ())
5861
59- -- Give the system a moment to notice the new virtual device.
60- -- Replace this with your preferred sleep helper.
61- os.execute (" sleep 0.5" )
62-
6362ui :emit (evdev .ecodes .EV_KEY , evdev .ecodes .KEY_A , 1 )
6463ui :emit (evdev .ecodes .EV_KEY , evdev .ecodes .KEY_A , 0 )
6564ui :sync ()
@@ -91,10 +90,6 @@ Emit one raw input event.
9190local UInput = evdev .uinput .create
9291local ui = assert (UInput ())
9392
94- -- Give the system a moment to notice the new virtual device.
95- -- Replace this with your preferred sleep helper.
96- os.execute (" sleep 0.5" )
97-
9893local EV_KEY = evdev .ecodes .EV_KEY
9994ui :emit (EV_KEY , evdev .ecodes .KEY_A , 1 )
10095ui :emit (EV_KEY , evdev .ecodes .KEY_A , 0 )
@@ -106,6 +101,47 @@ ui:emit(EV_REL, evdev.ecodes.REL_Y, 10)
106101ui :sync ()
107102```
108103
104+ <a id =" fn-fd " ></a >
105+
106+ ### ` fd() `
107+
108+ Get the file descriptor of the virtual device.
109+
110+ ** Return** :
111+
112+ - ` fd ` (` evdev.fd? ` ): Linux file descriptor.
113+
114+ ** Example** :
115+
116+ ``` lua
117+ local UInput = evdev .uinput .create
118+ local ui = assert (UInput ())
119+ print (ui :fd ())
120+ ```
121+
122+ <a id =" fn-get-repeat " ></a >
123+
124+ ### ` get_repeat() `
125+
126+ Get the current keyboard repeat rate from the virtual device.
127+
128+ ** Return** :
129+
130+ - ` delay ` (` integer? ` ): Repeat delay in milliseconds.
131+ - ` period ` (` integer? ` ): Repeat period in milliseconds.
132+ - ` err ` (` string? ` ): Error message on failure.
133+
134+ ** Example** :
135+
136+ ``` lua
137+ local UInput = evdev .uinput .create
138+ local ui = assert (UInput ())
139+
140+ local delay , period , err = ui :get_repeat ()
141+ assert (delay , err )
142+ print (delay , period )
143+ ```
144+
109145<a id =" fn-is-open " ></a >
110146
111147### ` is_open() `
@@ -127,6 +163,32 @@ if ui:is_open() then
127163end
128164```
129165
166+ <a id =" fn-set-repeat " ></a >
167+
168+ ### ` set_repeat(delay, period) `
169+
170+ Set the keyboard repeat rate on the virtual device.
171+
172+ ** Parameters** :
173+
174+ - ` delay ` (` integer ` ): Delay in milliseconds before key repeat starts.
175+ - ` period ` (` integer ` ): Period in milliseconds between repeated key events.
176+
177+ ** Return** :
178+
179+ - ` ok ` (` true? ` ): ` true ` when the repeat rate is set successfully.
180+ - ` err ` (` string? ` ): Error message on failure.
181+
182+ ** Example** :
183+
184+ ``` lua
185+ local UInput = evdev .uinput .create
186+ local ui = assert (UInput ())
187+
188+ -- Set repeat delay to 500ms, repeat period to 50ms
189+ ui :set_repeat (500 , 50 )
190+ ```
191+
130192<a id =" fn-sync " ></a >
131193
132194### ` sync() `
0 commit comments