Skip to content

Commit 3d90ad4

Browse files
author
Benjamin Dahlmanns
committed
Improve documentation
1 parent d3f0187 commit 3d90ad4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

uinput.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@ A virtual mouse input device is just as easy to create and use:
4646
Example (trigger a right click):
4747
err = vm.RightClick()
4848
49+
3. Close the device
50+
Example: err = vm.Close()
51+
52+
53+
If you'd like to use absolute input events (move the cursor to specific positions on screen), use the touch pad.
54+
Note that you'll need to specify the size of the screen area you want to use when you initialize the
55+
device. Here are a few examples of how to use the virtual touch pad:
56+
57+
1. Initialize the device:
58+
Example: vt, err := CreateTouchPad("/dev/uinput", "DontTouchThis", 0, 1024, 0, 768)
59+
60+
2. Move the cursor around and issue click events
61+
Example (move cursor to the top left corner of the screen):
62+
err = vt.MoveTo(0, 0)
63+
64+
Example (move cursor to the position x: 100, y: 250):
65+
err = vt.MoveTo(100, 250)
66+
67+
Example (trigger a left click):
68+
err = vt.LeftClick()
69+
70+
Example (trigger a right click):
71+
err = vt.RightClick()
72+
73+
3. Close the device
74+
Example: err = vt.Close()
75+
4976
*/
5077
package uinput
5178

@@ -166,7 +193,8 @@ func (vTouch vTouchPad) LeftClick() error {
166193
if err != nil {
167194
return fmt.Errorf("sync to device file failed: %v", err)
168195
}
169-
return nil}
196+
return nil
197+
}
170198

171199
func (vTouch vTouchPad) RightClick() error {
172200
err := sendBtnEvent(vTouch.deviceFile, evBtnRight, btnStatePressed)

0 commit comments

Comments
 (0)