mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Use async/await in TouchController.getCustomLayouts()
This commit is contained in:
parent
c1684abf27
commit
dbe0435669
@ -3534,7 +3534,7 @@ class TouchController {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
static getCustomLayouts(xboxTitleId, retries) {
|
static async getCustomLayouts(xboxTitleId, retries) {
|
||||||
xboxTitleId = '' + xboxTitleId;
|
xboxTitleId = '' + xboxTitleId;
|
||||||
if (xboxTitleId in TouchController.#customLayouts) {
|
if (xboxTitleId in TouchController.#customLayouts) {
|
||||||
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||||
@ -3553,27 +3553,27 @@ class TouchController {
|
|||||||
const url = `${baseUrl}/${xboxTitleId}.json`;
|
const url = `${baseUrl}/${xboxTitleId}.json`;
|
||||||
|
|
||||||
// Get layout info
|
// Get layout info
|
||||||
NATIVE_FETCH(url)
|
try {
|
||||||
.then(resp => resp.json())
|
const resp = await NATIVE_FETCH(url);
|
||||||
.then(json => {
|
const json = await resp.json();
|
||||||
const layouts = {};
|
|
||||||
|
|
||||||
json.layouts.forEach(async file => {
|
const layouts = {};
|
||||||
const layoutUrl = `${baseUrl}/layouts/${file}.json`;
|
|
||||||
const json = await (await NATIVE_FETCH(layoutUrl)).json();
|
|
||||||
Object.assign(layouts, json.layouts);
|
|
||||||
});
|
|
||||||
|
|
||||||
json.layouts = layouts;
|
json.layouts.forEach(async file => {
|
||||||
TouchController.#customLayouts[xboxTitleId] = json;
|
const layoutUrl = `${baseUrl}/layouts/${file}.json`;
|
||||||
|
const json = await (await NATIVE_FETCH(layoutUrl)).json();
|
||||||
|
Object.assign(layouts, json.layouts);
|
||||||
|
});
|
||||||
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
json.layouts = layouts;
|
||||||
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
TouchController.#customLayouts[xboxTitleId] = json;
|
||||||
})
|
|
||||||
.catch(() => {
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
// Retry
|
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
||||||
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
} catch (e) {
|
||||||
});
|
// Retry
|
||||||
|
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user