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")
|
||||
EV_KEY = 0x01
|
||||
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):
|
||||
for p in sorted(glob.glob("/sys/class/input/event*/device/name")):
|
||||
|
|
@ -75,8 +77,8 @@ def main():
|
|||
if r:
|
||||
data = os.read(f.fileno(), EVENT_SIZE * 64)
|
||||
for off in range(0, len(data) - EVENT_SIZE + 1, EVENT_SIZE):
|
||||
_, _, typ, _, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE])
|
||||
if typ == EV_KEY and val:
|
||||
_, _, typ, code, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE])
|
||||
if typ == EV_KEY and val and code not in MODIFIERS:
|
||||
last_key = time.monotonic()
|
||||
if not active:
|
||||
open(inhibit, "w").write("1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue