Skip to content

Commit

Permalink
make gamescope qam opt in, as it broke in the latest gamescope update
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed May 2, 2024
1 parent bfc99f3 commit 2244b68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hhd/controller/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, ctx=None) -> None:
self._controller_cb = None
self._qam_cb = None
self.ctx = ctx
self.use_legacy_qam = bool(os.environ.get("HHD_QAM_LEGACY", None))
self.use_legacy_qam = not bool(os.environ.get("HHD_QAM_GAMESCOPE", None))

def send_qam(self):
with self.intercept_lock:
Expand Down
15 changes: 13 additions & 2 deletions src/hhd/plugins/overlay/x11.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class CachedValues(NamedTuple):
touch: int | None


QAM_DELAY = 0.35


class QamHandler:

def __init__(
Expand Down Expand Up @@ -73,6 +76,7 @@ def _send_qam(self, expanded=False):
fake_input(disp, X.KeyPress, KCTRL) # , root=steam)
fake_input(disp, X.KeyPress, KEY) # , root=steam)
disp.sync()
time.sleep(QAM_DELAY)
fake_input(disp, X.KeyRelease, KCTRL) # , root=steam)
fake_input(disp, X.KeyRelease, KEY) # , root=steam)
disp.sync()
Expand Down Expand Up @@ -150,10 +154,11 @@ def get_overlay_display(displays: Sequence[str], ctx=None):
restore_priviledge(old)


def find_win(display: display.Display, win: list[str], atoms: list[str] = []):
def find_wins(display: display.Display, win: list[str], atoms: list[str] = []):
n = display.get_atom("WM_CLASS")
a_ids = [display.get_atom(a, only_if_exists=True) for a in atoms]

wins = []
for w in display.screen().root.query_tree().children:
# Check the window has the proper class
v = w.get_property(n, Xatom.STRING, 0, 50)
Expand All @@ -174,7 +179,13 @@ def find_win(display: display.Display, win: list[str], atoms: list[str] = []):
found = False

if found:
return w
wins.append(w)
return wins


def find_win(display: display.Display, win: list[str], atoms: list[str] = []):
out = find_wins(display, win, atoms)
return out[0] if out else None


def register_changes(display, win):
Expand Down

0 comments on commit 2244b68

Please sign in to comment.