Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added support for grabbing and releasing InputDevices
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed May 11, 2018
1 parent 87c03aa commit 380f27d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ func (dev *InputDevice) SetRepeatRate(repeat, delay uint) {
ioctl(dev.File.Fd(), uintptr(EVIOCSREP), unsafe.Pointer(repeat_delay))
}

// Grab the input device exclusively.
func (dev *InputDevice) Grab() error {
grab := int(1)
if err := ioctl(dev.File.Fd(), uintptr(EVIOCGRAB), unsafe.Pointer(&grab)); err != 0 {
return err
}

return nil
}

// Release a grabbed input device.
func (dev *InputDevice) Release() error {
if err := ioctl(dev.File.Fd(), uintptr(EVIOCGRAB), unsafe.Pointer(nil)); err != 0 {
return err
}

return nil
}

type CapabilityType struct {
Type int
Name string
Expand Down

0 comments on commit 380f27d

Please sign in to comment.