mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-01 10:56:42 +02:00
Add Polling rate setting
This commit is contained in:
@@ -33,3 +33,7 @@ export function showGamepadToast(gamepad: Gamepad) {
|
||||
|
||||
Toast.show(text, status, {instant: false});
|
||||
}
|
||||
|
||||
export function updatePollingRate() {
|
||||
window.BX_CONTROLLER_POLLING_RATE = getPref(PrefKey.CONTROLLER_POLLING_RATE);
|
||||
}
|
||||
|
@@ -160,8 +160,8 @@ export class SettingElement {
|
||||
|
||||
let controlValue = value;
|
||||
|
||||
const MIN = setting.min!;
|
||||
const MAX = setting.max!;
|
||||
const MIN = options.reverse ? -setting.max! : setting.min!;
|
||||
const MAX = options.reverse ? -setting.min! : setting.max!;
|
||||
const STEPS = Math.max(setting.steps || 1, 1);
|
||||
|
||||
const renderTextValue = (value: any) => {
|
||||
@@ -216,7 +216,7 @@ export class SettingElement {
|
||||
type: 'range',
|
||||
min: MIN,
|
||||
max: MAX,
|
||||
value: value,
|
||||
value: options.reverse ? -value : value,
|
||||
step: STEPS,
|
||||
tabindex: 0,
|
||||
});
|
||||
@@ -225,13 +225,16 @@ export class SettingElement {
|
||||
|
||||
$range.addEventListener('input', e => {
|
||||
value = parseInt((e.target as HTMLInputElement).value);
|
||||
const valueChanged = controlValue !== value;
|
||||
if (options.reverse) {
|
||||
value *= -1;
|
||||
}
|
||||
|
||||
const valueChanged = controlValue !== value;
|
||||
if (!valueChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
controlValue = value;
|
||||
controlValue = options.reverse ? -value : value;
|
||||
updateButtonsVisibility();
|
||||
$text.textContent = renderTextValue(value);
|
||||
|
||||
@@ -324,7 +327,7 @@ export class SettingElement {
|
||||
// Custom method
|
||||
$wrapper.setValue = (value: any) => {
|
||||
$text.textContent = renderTextValue(value);
|
||||
$range.value = value;
|
||||
$range.value = options.reverse ? -value : value;
|
||||
};
|
||||
|
||||
$btnDec.addEventListener('click', onClick);
|
||||
|
@@ -388,6 +388,29 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.CONTROLLER_POLLING_RATE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('polling-rate'),
|
||||
type: SettingElementType.NUMBER_STEPPER,
|
||||
default: 4,
|
||||
min: 4,
|
||||
max: 40,
|
||||
steps: 4,
|
||||
params: {
|
||||
reverse: true,
|
||||
customTextValue(value: any) {
|
||||
value = parseInt(value);
|
||||
|
||||
let text = +(1000 / value).toFixed(2) + ' Hz';
|
||||
if (value === 4) {
|
||||
text = `${t('default')} (${text})`;
|
||||
}
|
||||
|
||||
return text;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.MKB_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-mkb'),
|
||||
|
@@ -188,6 +188,7 @@ const Texts = {
|
||||
"playing": "Playing",
|
||||
"playtime": "Playtime",
|
||||
"poland": "Poland",
|
||||
"polling-rate": "Polling rate",
|
||||
"position": "Position",
|
||||
"powered-off": "Powered off",
|
||||
"powered-on": "Powered on",
|
||||
|
Reference in New Issue
Block a user