Skip to content

Commit f89772b

Browse files
A simple example of the lower-level API.
1 parent 5ebd23a commit f89772b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

README

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@ Create and use a new device with key and absolute-axis capability::
8181
abs_axes.move_to(uinput.ABS_X, 15)
8282
keys.click(uinput.BTN_GAMEPAD)
8383

84+
All the above things can also be done through the "lower-level API"::
85+
86+
import uinput
87+
88+
device = uinput.Device()
89+
90+
device.add_capability(uinput.EV_KEY, uinput.KEY_A)
91+
device.add_capability(uinput.EV_KEY, uinput.KEY_B)
92+
93+
device.send(uinput.EV_KEY, uinput.KEY_A, 1) # press
94+
device.send(uinput.EV_KEY, uinput.KEY_A, 0) # release
95+
device.send(uinput.EV_KEY, uinput.KEY_B, 1) # press
96+
device.send(uinput.EV_KEY, uinput.KEY_B, 0) # release
97+
device.send(uinput.EV_KEY, uinput.KEY_B, 1) # press
98+
device.send(uinput.EV_KEY, uinput.KEY_B, 0) # release
99+
device.send(uinput.EV_KEY, uinput.KEY_A, 1) # press
100+
device.send(uinput.EV_KEY, uinput.KEY_A, 0) # release
101+
102+
In other words, uinput.Capabilities descendants provide just higher level API
103+
for the uinput.Device.
104+
84105
Downloading
85106
===========
86107

0 commit comments

Comments
 (0)