|
@@ -3,56 +3,47 @@ import os
|
|
import select
|
|
import select
|
|
import time
|
|
import time
|
|
|
|
|
|
-from rescriptoon.actions import *
|
|
|
|
|
|
+import psutil
|
|
|
|
+import Xlib.display
|
|
|
|
+from Xlib import XK, X, Xatom
|
|
|
|
|
|
-try:
|
|
|
|
- import psutil
|
|
|
|
-except ImportError:
|
|
|
|
- psutil = False
|
|
|
|
-try:
|
|
|
|
- import Xlib.display
|
|
|
|
- from Xlib import X, XK, Xatom
|
|
|
|
-except ImportError:
|
|
|
|
- Xlib = False
|
|
|
|
|
|
+from rescriptoon.actions import *
|
|
|
|
|
|
EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME = "grave"
|
|
EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME = "grave"
|
|
EXTENDED_CONTROLS_PID_XPROPERTY_NAME = "_TOONCHER_EXTENDED_CONTROLS_PID"
|
|
EXTENDED_CONTROLS_PID_XPROPERTY_NAME = "_TOONCHER_EXTENDED_CONTROLS_PID"
|
|
TOONTOWN_WINDOW_NAME = "Toontown Rewritten"
|
|
TOONTOWN_WINDOW_NAME = "Toontown Rewritten"
|
|
|
|
|
|
-if Xlib:
|
|
|
|
- EXTENDED_CONTROLS_DEFAULT_KEYSYM_MAPPINGS = {
|
|
|
|
- XK.XK_w: RewriteKeyEventAction(keysym=XK.XK_Up, target_engine_index=0),
|
|
|
|
- XK.XK_a: RewriteKeyEventAction(keysym=XK.XK_Left, target_engine_index=0),
|
|
|
|
- XK.XK_s: RewriteKeyEventAction(keysym=XK.XK_Down, target_engine_index=0),
|
|
|
|
- XK.XK_d: RewriteKeyEventAction(keysym=XK.XK_Right, target_engine_index=0),
|
|
|
|
- XK.XK_Control_L: RewriteKeyEventAction(
|
|
|
|
- keysym=XK.XK_Control_L, target_engine_index=0
|
|
|
|
- ),
|
|
|
|
- XK.XK_v: RewriteKeyEventAction(keysym=XK.XK_Delete, target_engine_index=0),
|
|
|
|
- XK.XK_i: RewriteKeyEventAction(keysym=XK.XK_Up, target_engine_index=1),
|
|
|
|
- XK.XK_j: RewriteKeyEventAction(keysym=XK.XK_Left, target_engine_index=1),
|
|
|
|
- XK.XK_k: RewriteKeyEventAction(keysym=XK.XK_Down, target_engine_index=1),
|
|
|
|
- XK.XK_l: RewriteKeyEventAction(keysym=XK.XK_Right, target_engine_index=1),
|
|
|
|
- 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, 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
|
|
|
|
- }
|
|
|
|
|
|
+EXTENDED_CONTROLS_DEFAULT_KEYSYM_MAPPINGS = {
|
|
|
|
+ XK.XK_w: RewriteKeyEventAction(keysym=XK.XK_Up, target_engine_index=0),
|
|
|
|
+ XK.XK_a: RewriteKeyEventAction(keysym=XK.XK_Left, target_engine_index=0),
|
|
|
|
+ XK.XK_s: RewriteKeyEventAction(keysym=XK.XK_Down, target_engine_index=0),
|
|
|
|
+ XK.XK_d: RewriteKeyEventAction(keysym=XK.XK_Right, target_engine_index=0),
|
|
|
|
+ XK.XK_Control_L: RewriteKeyEventAction(
|
|
|
|
+ keysym=XK.XK_Control_L, target_engine_index=0
|
|
|
|
+ ),
|
|
|
|
+ XK.XK_v: RewriteKeyEventAction(keysym=XK.XK_Delete, target_engine_index=0),
|
|
|
|
+ XK.XK_i: RewriteKeyEventAction(keysym=XK.XK_Up, target_engine_index=1),
|
|
|
|
+ XK.XK_j: RewriteKeyEventAction(keysym=XK.XK_Left, target_engine_index=1),
|
|
|
|
+ XK.XK_k: RewriteKeyEventAction(keysym=XK.XK_Down, target_engine_index=1),
|
|
|
|
+ XK.XK_l: RewriteKeyEventAction(keysym=XK.XK_Right, target_engine_index=1),
|
|
|
|
+ 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, 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
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
def x_find_window(parent_window, filter_callback):
|
|
def x_find_window(parent_window, filter_callback):
|
|
@@ -94,30 +85,6 @@ class ExtendedControls:
|
|
primary_engine_window_name=None,
|
|
primary_engine_window_name=None,
|
|
toggle_keysym_name=EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME,
|
|
toggle_keysym_name=EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME,
|
|
):
|
|
):
|
|
- if not psutil:
|
|
|
|
- raise Exception(
|
|
|
|
- "\n".join(
|
|
|
|
- [
|
|
|
|
- "Extended keyboard controls require the python lib psutil to be installed.",
|
|
|
|
- "Depending on your system run",
|
|
|
|
- "\t$ sudo apt-get install python3-psutil",
|
|
|
|
- "or",
|
|
|
|
- "\t$ pip3 install --user psutil",
|
|
|
|
- ]
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- if not Xlib:
|
|
|
|
- raise Exception(
|
|
|
|
- "\n".join(
|
|
|
|
- [
|
|
|
|
- "Extended keyboard controls require xlib for python to be installed.",
|
|
|
|
- "Depending on your system run",
|
|
|
|
- "\t$ sudo apt-get install python3-xlib",
|
|
|
|
- "or",
|
|
|
|
- "\t$ pip3 install --user xlib",
|
|
|
|
- ]
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
self._primary_engine_pid = primary_engine_pid
|
|
self._primary_engine_pid = primary_engine_pid
|
|
self._primary_engine_window_name = primary_engine_window_name
|
|
self._primary_engine_window_name = primary_engine_window_name
|
|
self._xdisplay = Xlib.display.Display()
|
|
self._xdisplay = Xlib.display.Display()
|