mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-25 17:03:03 +02:00
Use PartialRecord type
This commit is contained in:
parent
7b60ba3a3e
commit
560a4c309c
@ -16,8 +16,8 @@ if (currentGamepad.id in window.BX_STREAM_SETTINGS.controllers) {
|
||||
const MIN_RANGE = 0.1;
|
||||
|
||||
const { mapping, ranges } = controller.customization;
|
||||
const pressedButtons: Partial<Record<keyof XcloudGamepad, number>> = {};
|
||||
const releasedButtons: Partial<Record<keyof XcloudGamepad, number>> = {};
|
||||
const pressedButtons: PartialRecord<keyof XcloudGamepad, number> = {};
|
||||
const releasedButtons: PartialRecord<keyof XcloudGamepad, number> = {};
|
||||
let isModified = false;
|
||||
|
||||
// Limit left trigger range
|
||||
|
@ -40,7 +40,7 @@ export class ControllerCustomizationsManagerDialog extends BaseProfileManagerDia
|
||||
},
|
||||
} satisfies ControllerCustomizationPresetData;
|
||||
|
||||
private selectsMap: Partial<Record<GamepadKey, HTMLSelectElement>> = {};
|
||||
private selectsMap: PartialRecord<GamepadKey, HTMLSelectElement> = {};
|
||||
private selectsOrder: GamepadKey[] = [];
|
||||
|
||||
private isDetectingButton: boolean = false;
|
||||
|
@ -19,7 +19,7 @@ export class ControllerShortcutsManagerDialog extends BaseProfileManagerDialog<C
|
||||
// private readonly LOG_TAG = 'ControllerShortcutsManagerDialog';
|
||||
|
||||
protected $content: HTMLElement;
|
||||
private selectActions: Partial<Record<GamepadKey, HTMLSelectElement>> = {};
|
||||
private selectActions: PartialRecord<GamepadKey, HTMLSelectElement> = {};
|
||||
|
||||
protected readonly BLANK_PRESET_DATA = {
|
||||
mapping: {},
|
||||
|
10
src/types/presets.d.ts
vendored
10
src/types/presets.d.ts
vendored
@ -16,7 +16,7 @@ interface PresetRecords<T extends PresetRecord> {
|
||||
|
||||
// MKB
|
||||
type MkbPresetData = {
|
||||
mapping: Partial<Record<GamepadKey, Array<KeyCode | MouseButtonCode | WheelCode | null>>>;
|
||||
mapping: PartialRecord<GamepadKey, Array<KeyCode | MouseButtonCode | WheelCode | null>>;
|
||||
mouse: Omit<{
|
||||
[index in MkbPresetKey]: number;
|
||||
}, MkbPresetKey.MOUSE_MAP_TO> & {
|
||||
@ -42,7 +42,7 @@ interface ControllerShortcutPresetRecord extends PresetRecord {
|
||||
};
|
||||
|
||||
type ControllerShortcutPresetData = {
|
||||
mapping: Partial<Record<GamepadKey, ShortcutAction>>,
|
||||
mapping: PartialRecord<GamepadKey, ShortcutAction>,
|
||||
};
|
||||
|
||||
// Keyboard shortcuts
|
||||
@ -51,7 +51,7 @@ interface KeyboardShortcutPresetRecord extends PresetRecord {
|
||||
};
|
||||
|
||||
type KeyboardShortcutPresetData = {
|
||||
mapping: Partial<Record<ShortcutAction, KeyEventInfo>>,
|
||||
mapping: PartialRecord<ShortcutAction, KeyEventInfo>,
|
||||
};
|
||||
|
||||
type KeyboardShortcutConvertedPresetData = KeyboardShortcutPresetData & {
|
||||
@ -71,7 +71,7 @@ interface AllPresetsData<T extends PresetRecord> {
|
||||
|
||||
// Controller customization
|
||||
type ControllerCustomizationPresetData = {
|
||||
mapping: Partial<Record<GamepadKey, GamepadKey | false | undefined>>;
|
||||
mapping: PartialRecord<GamepadKey, GamepadKey | false | undefined>;
|
||||
settings: {
|
||||
leftTriggerRange?: [number, number];
|
||||
rightTriggerRange?: [number, number];
|
||||
@ -88,7 +88,7 @@ interface ControllerCustomizationPresetRecord extends PresetRecord {
|
||||
};
|
||||
|
||||
type ControllerCustomizationConvertedPresetData = {
|
||||
mapping: Partial<Record<keyof XcloudGamepad, keyof XcloudGamepad | false>>;
|
||||
mapping: PartialRecord<keyof XcloudGamepad, keyof XcloudGamepad | false>;
|
||||
ranges: {
|
||||
[key in keyof Pick<XcloudGamepad, 'LeftTrigger' | 'RightTrigger' | 'LeftThumb' | 'RightThumb'>]?: [number, number];
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ import { ControllerCustomizationsTable } from "./local-db/controller-customizati
|
||||
|
||||
|
||||
export type StreamSettingsData = {
|
||||
settings: Partial<Record<PrefKey, any>>;
|
||||
settings: PartialRecord<PrefKey, any>;
|
||||
xCloudPollingMode: 'none' | 'callbacks' | 'navigation' | 'all';
|
||||
|
||||
deviceVibrationIntensity: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user