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

Commit

Permalink
Merge pull request #6 from muesli/grab-release
Browse files Browse the repository at this point in the history
Added support for grabbing and releasing InputDevices
  • Loading branch information
gvalkov authored May 16, 2018
2 parents 87c03aa + 380f27d commit b6f418b
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 b6f418b

Please sign in to comment.