pokerogue/src/configs/gamepad-utils.ts

24 lines
801 B
TypeScript
Raw Normal View History

import {GamepadConfig} from "../inputs-controller";
2024-05-11 05:51:01 -07:00
import {SettingGamepad} from "#app/system/settings-gamepad";
export function getKeyForButtonIndex(config: GamepadConfig, index: integer): String {
for (const key of Object.keys(config.gamepadMapping)) {
const id = config.gamepadMapping[key];
if (id === index) return key;
}
return null;
}
export function getIconForCustomIndex(config: GamepadConfig, index: integer): String {
const key = getKeyForButtonIndex(config, index);
return config.icons[key];
2024-05-11 05:51:01 -07:00
}
export function getKeyForSettingName(config: GamepadConfig, settingName: SettingGamepad) {
for (const key of Object.keys(config.setting)) {
const name = config.setting[key];
if (name === settingName) return key;
}
return null;
}