Browse Source

extended controls refactor: derive SelectGagAction from CenterClickAction, determine factor_x from column_index

Fabian Peter Hammerle 6 years ago
parent
commit
5a50551bda
2 changed files with 18 additions and 5 deletions
  1. 14 1
      tooncher/actions.py
  2. 4 4
      tooncher/controls.py

+ 14 - 1
tooncher/actions.py

@@ -32,7 +32,7 @@ class EngineAction:
             self.execute_on_window(extended_controls, xkeyevent, target_window)
 
 
-class SelectGagAction(EngineAction):
+class CenterClickAction(EngineAction):
 
     def __init__(self, target_engine_index, factor_x, factor_y):
         super().__init__(
@@ -69,6 +69,19 @@ class SelectGagAction(EngineAction):
         engine_window.send_event(e)
 
 
+class SelectGagAction(CenterClickAction):
+
+    X_OFFSET = -0.286
+    X_FACTOR = 0.081
+
+    def __init__(self, target_engine_index, column_index, factor_y):
+        super().__init__(
+            target_engine_index=target_engine_index,
+            factor_x=self.X_OFFSET + self.X_FACTOR * column_index,
+            factor_y=factor_y,
+        )
+
+
 class RewriteKeyEventAction(EngineAction):
 
     def __init__(self, target_engine_index, keysym=None):

+ 4 - 4
tooncher/controls.py

@@ -30,10 +30,10 @@ if Xlib:
         XK.XK_slash:     RewriteKeyEventAction(keysym=XK.XK_Control_L,  target_engine_index=1),
         XK.XK_n:         RewriteKeyEventAction(keysym=XK.XK_Delete,     target_engine_index=1),
         XK.XK_space:     RewriteKeyEventAction(keysym=XK.XK_Control_L,  target_engine_index=TargetEngine.All),
-        XK.XK_e:         SelectGagAction(target_engine_index=0, factor_x=0.038, factor_y=-0.047),  # elephant trunk
-        XK.XK_o:         SelectGagAction(target_engine_index=1, factor_x=0.038, factor_y=-0.047),  # elephant trunk
-        XK.XK_f:         SelectGagAction(target_engine_index=0, factor_x=0.119, factor_y=-0.047),  # foghorn
-        XK.XK_semicolon: SelectGagAction(target_engine_index=1, factor_x=0.119, factor_y=-0.047),  # foghorn
+        XK.XK_e:         SelectGagAction(target_engine_index=0, column_index=4, factor_y=-0.047),  # elephant trunk
+        XK.XK_o:         SelectGagAction(target_engine_index=1, column_index=4, factor_y=-0.047),  # elephant trunk
+        XK.XK_f:         SelectGagAction(target_engine_index=0, column_index=5, factor_y=-0.047),  # foghorn
+        XK.XK_semicolon: SelectGagAction(target_engine_index=1, column_index=5, factor_y=-0.047),  # foghorn
     }