mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-11 15:47:47 +02:00
Add Polling rate setting
This commit is contained in:
@@ -202,12 +202,17 @@ const PATCHES = {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nextIndex = str.indexOf('setTimeout(this.pollGamepads', index);
|
||||
if (nextIndex === -1) {
|
||||
const setTimeoutIndex = str.indexOf('setTimeout(this.pollGamepads', index);
|
||||
if (setTimeoutIndex < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let codeBlock = str.substring(index, nextIndex);
|
||||
let codeBlock = str.substring(index, setTimeoutIndex);
|
||||
|
||||
// Patch polling rate
|
||||
const tmp = str.substring(setTimeoutIndex, setTimeoutIndex + 150);
|
||||
const tmpPatched = tmp.replaceAll('Math.max(0,4-', 'Math.max(0,window.BX_CONTROLLER_POLLING_RATE-');
|
||||
str = PatcherUtils.replaceWith(str, setTimeoutIndex, tmp, tmpPatched);
|
||||
|
||||
// Block gamepad stats collecting
|
||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||
@@ -226,7 +231,8 @@ const PATCHES = {
|
||||
codeBlock = codeBlock.replace('this.gamepadTimestamps.set', newCode + 'this.gamepadTimestamps.set');
|
||||
}
|
||||
|
||||
return str.substring(0, index) + codeBlock + str.substring(nextIndex);
|
||||
str = str.substring(0, index) + codeBlock + str.substring(setTimeoutIndex);
|
||||
return str;
|
||||
},
|
||||
|
||||
enableXcloudLogger(str: string) {
|
||||
|
@@ -28,6 +28,7 @@ import { SettingElement, type BxHtmlSettingElement } from "@/utils/setting-eleme
|
||||
import type { RecommendedSettings, SettingDefinition, SuggestedSettingCategory as SuggestedSettingProfile } from "@/types/setting-definition";
|
||||
import { FullscreenText } from "../fullscreen-text";
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
import { updatePollingRate } from "@/utils/gamepad";
|
||||
|
||||
|
||||
type SettingTabContentItem = Partial<{
|
||||
@@ -460,6 +461,9 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
||||
pref: PrefKey.CONTROLLER_VIBRATION_INTENSITY,
|
||||
unsupported: !VibrationManager.supportDeviceVibration(),
|
||||
onChange: () => VibrationManager.updateGlobalVars(),
|
||||
}, isFullVersion() && {
|
||||
pref: PrefKey.CONTROLLER_POLLING_RATE,
|
||||
onChange: () => updatePollingRate(),
|
||||
}],
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user