Fix dwt ignoring modifiers like shift, alt etc.
This commit is contained in:
parent
ced2ff65dc
commit
20f70dd27a
1 changed files with 4 additions and 2 deletions
|
|
@ -49,6 +49,8 @@ import glob, os, select, struct, time
|
||||||
EVENT_SIZE = struct.calcsize("llHHi")
|
EVENT_SIZE = struct.calcsize("llHHi")
|
||||||
EV_KEY = 0x01
|
EV_KEY = 0x01
|
||||||
DWT_TIMEOUT = 0.3
|
DWT_TIMEOUT = 0.3
|
||||||
|
# Modifier keycodes — don't inhibit touchpad for these
|
||||||
|
MODIFIERS = {42, 54, 29, 97, 56, 100, 125, 126} # L/R Shift, Ctrl, Alt, Super
|
||||||
|
|
||||||
def find_event(name):
|
def find_event(name):
|
||||||
for p in sorted(glob.glob("/sys/class/input/event*/device/name")):
|
for p in sorted(glob.glob("/sys/class/input/event*/device/name")):
|
||||||
|
|
@ -75,8 +77,8 @@ def main():
|
||||||
if r:
|
if r:
|
||||||
data = os.read(f.fileno(), EVENT_SIZE * 64)
|
data = os.read(f.fileno(), EVENT_SIZE * 64)
|
||||||
for off in range(0, len(data) - EVENT_SIZE + 1, EVENT_SIZE):
|
for off in range(0, len(data) - EVENT_SIZE + 1, EVENT_SIZE):
|
||||||
_, _, typ, _, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE])
|
_, _, typ, code, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE])
|
||||||
if typ == EV_KEY and val:
|
if typ == EV_KEY and val and code not in MODIFIERS:
|
||||||
last_key = time.monotonic()
|
last_key = time.monotonic()
|
||||||
if not active:
|
if not active:
|
||||||
open(inhibit, "w").write("1")
|
open(inhibit, "w").write("1")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue