diff --git a/uinputmapper/cinput.py b/uinputmapper/cinput.py index 7294398..8b439ca 100644 --- a/uinputmapper/cinput.py +++ b/uinputmapper/cinput.py @@ -122,6 +122,18 @@ class InputDevice(object): if hasattr(self, '_f'): os.close(self._f) + def grab(self): + """ + Grab input device + """ + fcntl.ioctl(self._f, EVIOCGRAB, 1) + + def ungrab(self): + """ + Release device + """ + fcntl.ioctl(self._f, EVIOCGRAB, 0) + def open_uinput(): try: diff --git a/uinputmapper/linux_input.py b/uinputmapper/linux_input.py index 1f8eaca..6f548a8 100644 --- a/uinputmapper/linux_input.py +++ b/uinputmapper/linux_input.py @@ -164,8 +164,10 @@ EVIOCGABS = lambda _abs: IOR(ord('E'), 0x40 + _abs, ctypes.sizeof(input_absinfo) #EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ #EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ #EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ -# -#EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ + + +# Grab/Release device +EVIOCGRAB = IOW(ord('E'), 0x90, 'i') + # #EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ -