mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-19 01:20:20 +02:00
Merge pull request #79 from FrogTheFrog/main
fix(useQuickAccessVisible): make it work again
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { getFocusNavController } from '../utils';
|
||||
import { getGamepadNavigationTrees } from '../utils';
|
||||
|
||||
function getQuickAccessWindow(): Window | null {
|
||||
try {
|
||||
const navTrees = getFocusNavController()?.m_rgGamepadNavigationTrees;
|
||||
return (
|
||||
navTrees?.find((tree: any) => tree?.id === 'QuickAccess-NA')?.m_Root?.m_element?.ownerDocument.defaultView ?? null
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return null;
|
||||
}
|
||||
const navTrees = getGamepadNavigationTrees();
|
||||
return navTrees.find((tree: any) => tree?.id === 'QuickAccess-NA')?.m_Root?.m_element?.ownerDocument.defaultView ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,8 @@ export function findSP(): Window {
|
||||
// old (SP as host)
|
||||
if (document.title == 'SP') return window;
|
||||
// new (SP as popup)
|
||||
const focusNav = getFocusNavController();
|
||||
const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext;
|
||||
return context.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument
|
||||
.defaultView;
|
||||
const navTrees = getGamepadNavigationTrees();
|
||||
return navTrees.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,3 +31,12 @@ export function findSP(): Window {
|
||||
export function getFocusNavController(): any {
|
||||
return window.GamepadNavTree?.m_context?.m_controller || window.FocusNavController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gamepad navigation trees as Valve seems to be moving them.
|
||||
*/
|
||||
export function getGamepadNavigationTrees(): any {
|
||||
const focusNav = getFocusNavController();
|
||||
const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext;
|
||||
return context.m_rgGamepadNavigationTrees;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user