mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Only request custom touch control when the game is focused
This commit is contained in:
parent
6b090194c9
commit
2142c4a83c
@ -3650,13 +3650,14 @@ class TouchController {
|
|||||||
setTimeout(TouchController.#show, 1000);
|
setTimeout(TouchController.#show, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let focused = false;
|
||||||
dataChannel.addEventListener('message', msg => {
|
dataChannel.addEventListener('message', msg => {
|
||||||
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch a message to display generic touch controller
|
// Dispatch a message to display generic touch controller
|
||||||
if (msg.data.includes('touchcontrols/showtitledefault')) {
|
if (focused && msg.data.includes('touchcontrols/showtitledefault')) {
|
||||||
TouchController.#enable && TouchController.getCustomLayouts(GAME_XBOX_TITLE_ID);
|
TouchController.#enable && TouchController.getCustomLayouts(GAME_XBOX_TITLE_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3667,6 +3668,7 @@ class TouchController {
|
|||||||
const json = JSON.parse(JSON.parse(msg.data).content);
|
const json = JSON.parse(JSON.parse(msg.data).content);
|
||||||
TouchController.#toggleBar(json.focused);
|
TouchController.#toggleBar(json.focused);
|
||||||
|
|
||||||
|
focused = json.focused;
|
||||||
if (!json.focused) {
|
if (!json.focused) {
|
||||||
TouchController.#show();
|
TouchController.#show();
|
||||||
}
|
}
|
||||||
@ -9077,7 +9079,6 @@ function interceptHttpRequests() {
|
|||||||
|
|
||||||
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
||||||
GAME_XBOX_TITLE_ID = xboxTitleId;
|
GAME_XBOX_TITLE_ID = xboxTitleId;
|
||||||
TouchController.getCustomLayouts(xboxTitleId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json = () => Promise.resolve(obj);
|
response.json = () => Promise.resolve(obj);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user