@@ -466,39 +466,31 @@ def run(self):
466
466
n = matrix .wait (t )
467
467
self .check ()
468
468
469
- if mouse_action :
470
- x , y , wheel = MS_MOVEMENT [mouse_action ]
471
- dt = 1 + (time .monotonic_ns () - mouse_time ) // 8000000
472
- mouse_time = time .monotonic_ns ()
473
- self .move_mouse (x * dt , y * dt , wheel * dt )
469
+ if self .pair_keys :
470
+ # detecting pair keys
471
+ if n == 1 :
472
+ key = matrix .view (0 )
473
+ if key < 0x80 and key in self .pair_keys :
474
+ n = matrix .wait (
475
+ self .pair_delay
476
+ - ms (matrix .time () - matrix .get_keydown_time (key ))
477
+ )
474
478
475
- if n == 0 :
476
- continue
479
+ if n >= 2 :
480
+ pair = {matrix .view (0 ), matrix .view (1 )}
481
+ if pair in self .pairs :
482
+ pair_index = self .pairs .index (pair )
483
+ key1 = self .get ()
484
+ key2 = self .get ()
477
485
478
- # detecting pair keys
479
- if n == 1 :
480
- key = matrix .view (0 )
481
- if key < 0x80 and key in self .pair_keys :
482
- n = matrix .wait (
483
- self .pair_delay
484
- - ms (matrix .time () - matrix .get_keydown_time (key ))
485
- )
486
-
487
- if n >= 2 :
488
- pair = {matrix .view (0 ), matrix .view (1 )}
489
- if pair in self .pairs :
490
- pair_index = self .pairs .index (pair )
491
- key1 = self .get ()
492
- key2 = self .get ()
493
-
494
- dt = ms (
495
- matrix .get_keydown_time (key2 ) - matrix .get_keydown_time (key1 )
496
- )
497
- log ("pair keys {} {}, dt = {}" .format (pair_index , pair , dt ))
498
- try :
499
- self .pairs_handler (dev , pair_index )
500
- except Exception as e :
501
- print (e )
486
+ dt = ms (
487
+ matrix .get_keydown_time (key2 ) - matrix .get_keydown_time (key1 )
488
+ )
489
+ log ("pair keys {} {}, dt = {}" .format (pair_index , pair , dt ))
490
+ try :
491
+ self .pairs_handler (dev , pair_index )
492
+ except Exception as e :
493
+ print (e )
502
494
503
495
while len (matrix ):
504
496
event = self .get ()
@@ -670,3 +662,9 @@ def run(self):
670
662
key , key_name (key ), hex (action_code ), dt , dt2
671
663
)
672
664
)
665
+
666
+ if mouse_action :
667
+ x , y , wheel = MS_MOVEMENT [mouse_action ]
668
+ dt = 1 + (time .monotonic_ns () - mouse_time ) // 8000000
669
+ mouse_time = time .monotonic_ns ()
670
+ self .move_mouse (x * dt , y * dt , wheel * dt )
0 commit comments