Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix d-pad mapping with a default empty input config #12

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/core/helpers/retroarch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@ export const defaultRetroarchCoresConfig = {
},
}

function getEmptyInputConfig() {
const gamepadButtonNames = [
'a',
'b',
'x',
'y',
'l',
'l2',
'l3',
'r',
'r2',
'r3',
'up',
'down',
'left',
'right',
'select',
'start',
]
const inputConfig = {}
for (const gamepadButtonName of gamepadButtonNames) {
for (let i = 0; i < 4; i++) {
inputConfig[`input_player${i + 1}_${gamepadButtonName}`] = ''
inputConfig[`input_player${i + 1}_${gamepadButtonName}_btn`] = ''
}
}
return inputConfig
}

// eslint-disable-next-line sonarjs/cognitive-complexity
export function getRetroarchConfig() {
const gamepadMappings = PreferenceParser.get('gamepadMappings')
Expand All @@ -63,7 +92,7 @@ export function getRetroarchConfig() {
gamepadMappingsMap.set(name, mapping)
}

const inputConfig = {}
const inputConfig = getEmptyInputConfig()
if (compact(gamepads).length > 0) {
for (const [index, gamepad] of gamepads.entries()) {
const mapping = gamepadMappingsMap.get(gamepad?.id ?? '')
Expand Down