mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 16:17:20 +02:00
Fix double inputs when using emulated MKB with Remote Play
This commit is contained in:
parent
99aec0a60c
commit
a546b921f4
@ -51,6 +51,7 @@ export class MkbHandler {
|
|||||||
#nativeGetGamepads = window.navigator.getGamepads.bind(window.navigator);
|
#nativeGetGamepads = window.navigator.getGamepads.bind(window.navigator);
|
||||||
|
|
||||||
#enabled = false;
|
#enabled = false;
|
||||||
|
#isPolling = false;
|
||||||
|
|
||||||
#prevWheelCode = null;
|
#prevWheelCode = null;
|
||||||
#wheelStoppedTimeout?: number | null;
|
#wheelStoppedTimeout?: number | null;
|
||||||
@ -162,10 +163,16 @@ export class MkbHandler {
|
|||||||
const isKeyDown = e.type === 'keydown';
|
const isKeyDown = e.type === 'keydown';
|
||||||
|
|
||||||
// Toggle MKB feature
|
// Toggle MKB feature
|
||||||
if (isKeyDown && e.code === 'F8') {
|
if (isKeyDown) {
|
||||||
e.preventDefault();
|
if (e.code === 'F8') {
|
||||||
this.toggle();
|
e.preventDefault();
|
||||||
return;
|
this.toggle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.#isPolling) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttonIndex = this.#CURRENT_PRESET_DATA.mapping[e.code]!;
|
const buttonIndex = this.#CURRENT_PRESET_DATA.mapping[e.code]!;
|
||||||
@ -396,6 +403,7 @@ export class MkbHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy = () => {
|
destroy = () => {
|
||||||
|
this.#isPolling = false;
|
||||||
this.#enabled = false;
|
this.#enabled = false;
|
||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
@ -412,6 +420,7 @@ export class MkbHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start = () => {
|
start = () => {
|
||||||
|
this.#isPolling = true;
|
||||||
window.navigator.getGamepads = this.#patchedGetGamepads;
|
window.navigator.getGamepads = this.#patchedGetGamepads;
|
||||||
|
|
||||||
this.#resetGamepad();
|
this.#resetGamepad();
|
||||||
@ -435,6 +444,7 @@ export class MkbHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop = () => {
|
stop = () => {
|
||||||
|
this.#isPolling = false;
|
||||||
|
|
||||||
// Dispatch "gamepaddisconnected" event
|
// Dispatch "gamepaddisconnected" event
|
||||||
const virtualGamepad = this.#getVirtualGamepad();
|
const virtualGamepad = this.#getVirtualGamepad();
|
||||||
|
@ -395,15 +395,47 @@ window.BX_EXPOSED.onPollingModeChanged && window.BX_EXPOSED.onPollingModeChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the next "{" backet
|
// Find the next "{" backet
|
||||||
index = str.indexOf('{', index) + 1;
|
let backetIndex = str.indexOf('{', index);
|
||||||
|
|
||||||
|
// Get param name
|
||||||
|
const params = str.substring(index, backetIndex).match(/\(([^)]+)\)/)![1];
|
||||||
|
const titleInfoVar = params.split(',')[0];
|
||||||
|
|
||||||
const newCode = `
|
const newCode = `
|
||||||
e = window.BX_EXPOSED.modifyTitleInfo(e);
|
${titleInfoVar} = window.BX_EXPOSED.modifyTitleInfo(${titleInfoVar});
|
||||||
console.log(e);
|
console.log(${titleInfoVar});
|
||||||
`;
|
`;
|
||||||
str = str.substring(0, index) + newCode + str.substring(index);
|
str = str.substring(0, backetIndex + 1) + newCode + str.substring(backetIndex + 1);
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
patchRemotePlayMkb(str: string) {
|
||||||
|
const text = 'async homeConsoleConnect';
|
||||||
|
let index = str.indexOf(text);
|
||||||
|
if (index === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the next "{" backet
|
||||||
|
let backetIndex = str.indexOf('{', index);
|
||||||
|
|
||||||
|
// Get param name
|
||||||
|
const params = str.substring(index, backetIndex).match(/\(([^)]+)\)/)![1];
|
||||||
|
const configsVar = params.split(',')[1];
|
||||||
|
|
||||||
|
const newCode = `
|
||||||
|
Object.assign(${configsVar}.inputConfiguration, {
|
||||||
|
enableMouseInput: false,
|
||||||
|
enableKeyboardInput: false,
|
||||||
|
enableAbsoluteMouse: false,
|
||||||
|
});
|
||||||
|
console.log(${configsVar});
|
||||||
|
`;
|
||||||
|
|
||||||
|
str = str.substring(0, backetIndex + 1) + newCode + str.substring(backetIndex + 1);
|
||||||
|
return str;
|
||||||
|
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let PATCH_ORDERS = [
|
let PATCH_ORDERS = [
|
||||||
@ -451,6 +483,7 @@ let PATCH_ORDERS = [
|
|||||||
// Only when playing
|
// Only when playing
|
||||||
const PLAYING_PATCH_ORDERS = [
|
const PLAYING_PATCH_ORDERS = [
|
||||||
['patchXcloudTitleInfo'],
|
['patchXcloudTitleInfo'],
|
||||||
|
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['patchRemotePlayMkb'],
|
||||||
|
|
||||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayConnectMode'],
|
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayConnectMode'],
|
||||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayGuideWorkaround'],
|
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayGuideWorkaround'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user