2024-05-11 05:31:48 -07:00
|
|
|
import {GamepadConfig} from "../inputs-controller";
|
2024-05-11 05:51:01 -07:00
|
|
|
import {SettingGamepad} from "#app/system/settings-gamepad";
|
2024-05-11 05:31:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
2024-05-11 05:31:48 -07:00
|
|
|
}
|